Index start/activate command: fix unknown name use
Before this fix, using the IndexStartCommand [1] while passing an invalid or unknown index name with the --force option led to an NPE in the log, thus a fatal error in user's console. Also, using an unknown index name either without --force or through the sibling IndexActivateCommand [2] used to display an inaccurate console message. This fix always shows a clearer message to the user, upon passing an unknown index name to either [1] or [2]. It also now prevents that NPE. [1] https://gerrit-review.googlesource.com/Documentation/cmd-index-start.html [2] https://gerrit-review.googlesource.com/Documentation/cmd-index-activate.html Bug: Issue 8715 Change-Id: I16cb800fbe9af00e47bb22105d1c4d4bf044fdc5
This commit is contained in:
@@ -121,6 +121,16 @@ public abstract class AbstractVersionManager implements LifecycleListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if an index with this name is currently known or not.
|
||||
*
|
||||
* @param name index name
|
||||
* @return true if index is known and can be used, otherwise false.
|
||||
*/
|
||||
public boolean isKnownIndex(String name) {
|
||||
return defs.get(name) != null;
|
||||
}
|
||||
|
||||
protected <K, V, I extends Index<K, V>> void initIndex(
|
||||
IndexDefinition<K, V, I> def, GerritIndexStatus cfg) {
|
||||
TreeMap<Integer, Version<V>> versions = scanVersions(def, cfg);
|
||||
|
||||
Reference in New Issue
Block a user