Fix plugin reloading for DynamicItems

Since DynamicItems could only ever be loaded by a single
plugin at a time (they are singletons), the code enforcing
this prevented those plugins from being reloaded.

Test Plan: reload the following plugins:

* gravatar-avatar-provider
* websession-flatfile

Bug: issue 2895
Change-Id: I52a07f34d1fa0b756f4cc22d0d83d2ef6906840e
(cherry picked from commit 9a5e78aa73)
This commit is contained in:
David Ostrovsky
2014-09-21 12:31:56 +02:00
committed by David Ostrovsky
parent 068511b2d4
commit d134e79fb1

View File

@@ -184,7 +184,13 @@ public class DynamicItem<T> {
NamedProvider<T> old = null;
while (!ref.compareAndSet(old, item)) {
old = ref.get();
if (old != null && !"gerrit".equals(old.pluginName)) {
if (old != null
&& !"gerrit".equals(old.pluginName)
&& !pluginName.equals(old.pluginName)) {
// We allow to replace:
// 1. Gerrit core items, e.g. websession cache
// can be replaced by plugin implementation
// 2. Reload of current plugin
throw new ProvisionException(String.format(
"%s already provided by %s, ignoring plugin %s",
this.key.getTypeLiteral(), old.pluginName, pluginName));