Filter out types used in DynamicItem when copying bindings to plugins
This avoids Guice creation errors when a plugin tries to bind its own implementation of a type that gerrit core already implemented. Change-Id: I2f989c944f5d22a21a19f6d122e5d80e7aca8e2e
This commit is contained in:
@@ -469,9 +469,13 @@ public class PluginGuiceEnvironment {
|
||||
|
||||
private Module copy(Injector src) {
|
||||
Set<TypeLiteral<?>> dynamicTypes = Sets.newHashSet();
|
||||
Set<TypeLiteral<?>> dynamicItemTypes = Sets.newHashSet();
|
||||
for (Map.Entry<Key<?>, Binding<?>> e : src.getBindings().entrySet()) {
|
||||
TypeLiteral<?> type = e.getKey().getTypeLiteral();
|
||||
if (type.getRawType() == DynamicSet.class
|
||||
if (type.getRawType() == DynamicItem.class) {
|
||||
ParameterizedType t = (ParameterizedType) type.getType();
|
||||
dynamicItemTypes.add(TypeLiteral.get(t.getActualTypeArguments()[0]));
|
||||
} else if (type.getRawType() == DynamicSet.class
|
||||
|| type.getRawType() == DynamicMap.class) {
|
||||
ParameterizedType t = (ParameterizedType) type.getType();
|
||||
dynamicTypes.add(TypeLiteral.get(t.getActualTypeArguments()[0]));
|
||||
@@ -488,6 +492,8 @@ public class PluginGuiceEnvironment {
|
||||
// using DynamicSet<F> or DynamicMap<F> internally. That should be
|
||||
// exported to plugins.
|
||||
continue;
|
||||
} else if (dynamicItemTypes.contains(e.getKey().getTypeLiteral())) {
|
||||
continue;
|
||||
} else if (shouldCopy(e.getKey())) {
|
||||
bindings.put(e.getKey(), e.getValue());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user