Is it possible for Dagger to deadlock while providing for dependencies? For example, if there is a circular dependency between Class A and Class B because both inject each other like this:
class ClassA @Inject constructor(classB: Provider<ClassB>) {
fun logSomeMetrics() {
// ...
classB.get().writeSomething();
// ...
}
}
class ClassB @Inject constructor(classA: Provider<ClassA>) {
fun writeSomething() {
// ...
classA.get().logSomeMetrics();
// ...
}
}
The Provider was used in each class to try to break the circular dependency. Is there ever a race condition or scenario where two threads will deadlock because one is trying to resolve dependency (lazily through get()) for Class A, while the other is trying to resolve dependency (lazily through get()) for Class B?
Or is it guaranteed that both dependencies will be resolved properly without deadlock?
Is it possible for Dagger to deadlock while providing for dependencies? For example, if there is a circular dependency between Class A and Class B because both inject each other like this:
The Provider was used in each class to try to break the circular dependency. Is there ever a race condition or scenario where two threads will deadlock because one is trying to resolve dependency (lazily through
get()) for Class A, while the other is trying to resolve dependency (lazily throughget()) for Class B?Or is it guaranteed that both dependencies will be resolved properly without deadlock?