Fix NPE when scanning change index versions if 'index' dir is missing
If the 'index' directory in the review site is missing the scanning for the change index versions failed with a NullPointerException since 'sitePaths.index_dir.listFiles()' returns null in this case. The 'index' directory is not created if a new site is initialized but only when the indexes are generated by running the reindex command. Hence initializing a new site and switching on Lucene indexing in the gerrit.config without generating the indexes leads to this error. Check if the 'index' directory exists and print out an error that the indexes need to be generated if it is missing. Change-Id: I9ffff8f643cfecb64ae6014e6451282d06743a28 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -114,6 +114,13 @@ class LuceneVersionManager implements LifecycleListener {
|
||||
throw fail(e);
|
||||
}
|
||||
|
||||
if (!sitePaths.index_dir.exists()) {
|
||||
throw new ProvisionException("No index versions ready; run Reindex");
|
||||
} else if (!sitePaths.index_dir.isDirectory()) {
|
||||
log.warn("Not a directory: %s", sitePaths.index_dir.getAbsolutePath());
|
||||
throw new ProvisionException("No index versions ready; run Reindex");
|
||||
}
|
||||
|
||||
TreeMap<Integer, Version> versions = scanVersions(cfg);
|
||||
// Search from the most recent ready version.
|
||||
// Write to the most recent ready version and the most recent version.
|
||||
|
||||
Reference in New Issue
Block a user