summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2016-01-21 06:55:39 +0100
committerDavid Ostrovsky <david.ostrovsky@gmail.com>2016-01-22 17:11:29 +0000
commita5f2037a42a5275c0581b8b4afcb76db0445ad07 (patch)
treecbd00c1f1d0213049bce70a7e2125d22833449d0
parenta533b1519c62f99cc0329dac4bb98049df3db6c4 (diff)
Expose IndexCollection in plugin guice injector
Secondary index underwent quite some evolution, by adding new fields or turning search predicates that (uncorrectly) used database to produce matches to use secondary index. When new index version is added, the previous index version must still be supported because of online reindexing feature. On very big site, reindexing may take hours, clearly such a long offline time is non acceptable, that why online reindexing feature was invented. To make online reindexing work, schema version must be fetched to route the current search predicate to use old (legacy) or new field. For that IndexCollection is accessed and the current schema version is read. Unfortunately, IndexCollection implements LifecycleListener and these classes are not copied in guice plugin injector when the plugin is loaded. This makes secondary index machinery not usable from within a plugin listener. For the reasons explained above some search predicates would try to retrieve the secondary index version but because singleton IndexCollection instance wasn't made available in plugin's guice injector, the correct instance is not found and guice injector creates new virgin IndexCollection instance where change index (and the schema version) is not set. As the consequence we are getting a NPE when secondary index is tried to be used from within plugin listener. To rectify, expose IndexCollection to plugin guice injector. Bug: Issue 3768 Change-Id: I2f9c40aa43aa7b1b954d8fa318df54e45dffcd95
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/plugins/PluginGuiceEnvironment.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/plugins/PluginGuiceEnvironment.java b/gerrit-server/src/main/java/com/google/gerrit/server/plugins/PluginGuiceEnvironment.java
index 3fbbfa9b0d..5f33e387a8 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/plugins/PluginGuiceEnvironment.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/plugins/PluginGuiceEnvironment.java
@@ -553,7 +553,9 @@ public class PluginGuiceEnvironment {
return false;
}
Class<?> type = key.getTypeLiteral().getRawType();
- if (LifecycleListener.class.isAssignableFrom(type)) {
+ if (LifecycleListener.class.isAssignableFrom(type)
+ // This is needed for secondary index to work from plugin listeners
+ && !is("com.google.gerrit.server.index.IndexCollection", type)) {
return false;
}
if (StartPluginListener.class.isAssignableFrom(type)) {