Class CycleDetectingLock.CycleDetectingLockFactory<ID>

java.lang.Object
com.google.inject.internal.CycleDetectingLock.CycleDetectingLockFactory<ID>
Enclosing interface:
CycleDetectingLock<ID>

public static class CycleDetectingLock.CycleDetectingLockFactory<ID> extends Object
Wraps locks so they would never cause a deadlock. On each CycleDetectingLock.lockOrDetectPotentialLocksCycle() we check for dependency cycles within locks created by the same factory. Either we detect a cycle and return it or take it atomically.

Important to note that we do not prevent deadlocks in the client code. As an example: Thread A takes lock L and creates singleton class CA depending on the singleton class CB. Meanwhile thread B is creating class CB and is waiting on the lock L. Issue happens due to client code creating interdependent classes and using locks, where no guarantees on the creation order from Guice are provided.

Instances of these locks are not intended to be exposed outside of SingletonScope.