Merge "Make sure to synchronize on references to plugin dependencies" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
157017c8a8
@@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user