-
-
Notifications
You must be signed in to change notification settings - Fork 67
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I have found the following behavior related to scopes and @Qualifier
annotation. Suppose we have the component:
@Scope
annotation class Singleton
@Qualifier
annotation class FirstClient
@Qualifier
annotation class SecondClient
interface ClientComponent {
@Singleton
@Provides
@FirstClient
fun provideFirstClient(): HttpClient {
return HttpClient()
}
@Singleton
@Provides
@SecondClient
fun provideSecondClient(
@FirstClient
firstClient: HttpClient,
): HttpClient {
return firstClient.newBuilder().build()
}
}
If we create this Api class with this particular order of dependencies
@Inject
class Api(
@SecondClient
val secondClient: HttpClient,
@FirstClient
val firstClient: HttpClient,
)
then FirstClient is not scoped and two instances are created. On the other hand if we create the same class but with different dependency order:
@Inject
class Api(
@FirstClient
val firstClient: HttpClient,
@SecondClient
val secondClient: HttpClient,
)
then FirstClient gets its scope and only one instance is created.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working