Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 84dbc7b2 authored by Jason Monk's avatar Jason Monk Committed by android-build-merger
Browse files

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

am: 157017c8

Change-Id: Ia6feb2f2e41ce6f4551cd6cd8713e09b0f5c5275
parents 5d6deab0 157017c8
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -34,17 +34,21 @@ public class PluginDependencyProvider extends DependencyProvider {
    }

    public <T> void allowPluginDependency(Class<T> cls, T obj) {
        synchronized (mDependencies) {
            mDependencies.put(cls, obj);
        }
    }

    @Override
    <T> T get(Plugin p, Class<T> cls) {
        if (!mManager.dependsOn(p, cls)) {
            throw new IllegalArgumentException(p.getClass() + " does not depend on " + cls);
        }
        synchronized (mDependencies) {
            if (!mDependencies.containsKey(cls)) {
                throw new IllegalArgumentException("Unknown dependency " + cls);
            }
            return (T) mDependencies.get(cls);
        }
    }
}