Merge "Make sure to synchronize on references to plugin dependencies" into oc-dev

This commit is contained in:
TreeHugger Robot
2017-04-07 17:24:57 +00:00
committed by Android (Google) Code Review

View File

@@ -34,7 +34,9 @@ public class PluginDependencyProvider extends DependencyProvider {
} }
public <T> void allowPluginDependency(Class<T> cls, T obj) { public <T> void allowPluginDependency(Class<T> cls, T obj) {
mDependencies.put(cls, obj); synchronized (mDependencies) {
mDependencies.put(cls, obj);
}
} }
@Override @Override
@@ -42,9 +44,11 @@ public class PluginDependencyProvider extends DependencyProvider {
if (!mManager.dependsOn(p, cls)) { if (!mManager.dependsOn(p, cls)) {
throw new IllegalArgumentException(p.getClass() + " does not depend on " + cls); throw new IllegalArgumentException(p.getClass() + " does not depend on " + cls);
} }
if (!mDependencies.containsKey(cls)) { synchronized (mDependencies) {
throw new IllegalArgumentException("Unknown dependency " + cls); if (!mDependencies.containsKey(cls)) {
throw new IllegalArgumentException("Unknown dependency " + cls);
}
return (T) mDependencies.get(cls);
} }
return (T) mDependencies.get(cls);
} }
} }