Flush global plugin config on plugin reload
Global plugin configuration files are cached so that they don't need to be parsed on every access. Flush the global plugin config from the cache when the plugin is reloaded. Change-Id: I0e37095f4e31f0cc87d0385f57abc8d6737ee221 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -102,6 +102,7 @@ import com.google.gerrit.server.mail.VelocityRuntimeProvider;
|
||||
import com.google.gerrit.server.patch.PatchListCacheImpl;
|
||||
import com.google.gerrit.server.patch.PatchScriptFactory;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||
import com.google.gerrit.server.plugins.ReloadPluginListener;
|
||||
import com.google.gerrit.server.project.AccessControlModule;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.CommentLinkInfo;
|
||||
@@ -121,6 +122,7 @@ import com.google.gerrit.server.util.IdGenerator;
|
||||
import com.google.gerrit.server.util.ThreadLocalRequestContext;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.internal.UniqueAnnotations;
|
||||
|
||||
import org.apache.velocity.runtime.RuntimeInstance;
|
||||
|
||||
@@ -270,5 +272,9 @@ public class GerritGlobalModule extends FactoryModule {
|
||||
|
||||
bind(new TypeLiteral<List<CommentLinkInfo>>() {})
|
||||
.toProvider(CommentLinkProvider.class).in(SINGLETON);
|
||||
|
||||
bind(ReloadPluginListener.class)
|
||||
.annotatedWith(UniqueAnnotations.create())
|
||||
.to(PluginConfigFactory.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ package com.google.gerrit.server.config;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.git.ProjectLevelConfig;
|
||||
import com.google.gerrit.server.plugins.Plugin;
|
||||
import com.google.gerrit.server.plugins.ReloadPluginListener;
|
||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
@@ -35,7 +37,7 @@ import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
public class PluginConfigFactory {
|
||||
public class PluginConfigFactory implements ReloadPluginListener {
|
||||
private static final Logger log =
|
||||
LoggerFactory.getLogger(PluginConfigFactory.class);
|
||||
|
||||
@@ -210,7 +212,7 @@ public class PluginConfigFactory {
|
||||
* be returned
|
||||
* @return the plugin configuration from the 'etc/<plugin-name>.config' file
|
||||
*/
|
||||
public Config getGlobalPluginConfig(String pluginName) {
|
||||
public synchronized Config getGlobalPluginConfig(String pluginName) {
|
||||
if (pluginConfigs.containsKey(pluginName)) {
|
||||
return pluginConfigs.get(pluginName);
|
||||
}
|
||||
@@ -336,4 +338,9 @@ public class PluginConfigFactory {
|
||||
}
|
||||
return projectState.getConfig(pluginName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onReloadPlugin(Plugin oldPlugin, Plugin newPlugin) {
|
||||
pluginConfigs.remove(oldPlugin.getName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user