You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When creating multiple koinApplication { ... } instances with the same module, each application should produce its own set of instances. However, I’m observing that two distinct Koin contexts return what appears to be the exact same instance, even though they should be isolated. This occurs even with a simple configuration (e.g., a single module providing a single).
To Reproduce
Steps to reproduce the behavior:
Run the following minimal code snippet (see below) in a clean environment.
Observe that calling koin1.get() and koin2.get() returns the same object reference.
Expected behavior
Each new koinApplication should create fresh instances independently. I would expect foo1 === foo2 to be false, since each application context is isolated.
Koin module and version: koin-core:3.5.6
Snippet or Sample project to help reproduce
import org.koin.dsl.module
import org.koin.core.context.koinApplication
import kotlin.test.assertNotEquals
class Foo
fun main() {
val moduleDefinition = module {
single<Foo> { Foo() }
}
val koin1 = koinApplication {
modules(moduleDefinition)
}.koin
val koin2 = koinApplication {
modules(moduleDefinition)
}.koin
val foo1 = koin1.get<Foo>()
val foo2 = koin2.get<Foo>()
println("identityHashCode(foo1): ${System.identityHashCode(foo1)}")
println("identityHashCode(foo2): ${System.identityHashCode(foo2)}")
println("Are they the same instance? ${foo1 === foo2}")
// Expect false, but it prints true
assertNotEquals(foo1, foo2)
}
The text was updated successfully, but these errors were encountered:
Describe the bug
When creating multiple koinApplication { ... } instances with the same module, each application should produce its own set of instances. However, I’m observing that two distinct Koin contexts return what appears to be the exact same instance, even though they should be isolated. This occurs even with a simple configuration (e.g., a single module providing a single).
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Each new koinApplication should create fresh instances independently. I would expect foo1 === foo2 to be false, since each application context is isolated.
Koin module and version:
koin-core:3.5.6
Snippet or Sample project to help reproduce
The text was updated successfully, but these errors were encountered: