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

Commit 157017c8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents ed8051b5 25f3db72
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -34,17 +34,21 @@ public class PluginDependencyProvider extends DependencyProvider {
    }
    }


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


    @Override
    @Override
    <T> T get(Plugin p, Class<T> cls) {
    <T> T get(Plugin p, Class<T> cls) {
        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);
        }
        }
        synchronized (mDependencies) {
            if (!mDependencies.containsKey(cls)) {
            if (!mDependencies.containsKey(cls)) {
                throw new IllegalArgumentException("Unknown dependency " + cls);
                throw new IllegalArgumentException("Unknown dependency " + cls);
            }
            }
            return (T) mDependencies.get(cls);
            return (T) mDependencies.get(cls);
        }
        }
    }
    }
}