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

Commit 25f3db72 authored by Jason Monk's avatar Jason Monk
Browse files

Make sure to synchronize on references to plugin dependencies

Test: make
Change-Id: I361cb3e4ac4ff5d19e2b0322531c8c614f5b7635
Fixes: 36867744
parent 2242ff73
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);
        }
    }
}