Scope is resurrected with its instances
See original GitHub issueSTR:
- Create a scope
- Declare an instance on that scope
- Close the scope
- Create a new scope the same way
- Declare an instance on that scope (same way as in step 2)
ER: Instance is successfully declared AR: Created scope already contains the instance
package com.test
import org.junit.Test
import org.koin.core.qualifier.named
import org.koin.dsl.koinApplication
import org.koin.dsl.module
class ScopeTest {
val baseUrl = "base_url"
val baseUrlKey = named("BASE_URL_KEY")
val scopeId = "user_scope"
val scopeKey = named("KEY")
val koin = koinApplication {
modules(
module {
scope(scopeKey) {
}
}
)
}.koin
@Test
fun `recreate a scope`() {
val scope = koin.createScope(scopeId, scopeKey)
scope.declare(baseUrl, baseUrlKey)
scope.close()
val scope2 = koin.createScope(scopeId, scopeKey)
scope2.declare(baseUrl, baseUrlKey)
}
}
org.koin.core.error.DefinitionOverrideException: Trying to override existing definition '[Single:'java.lang.String',qualifier:q:'BASE_URL_KEY',scope:q:'KEY']' with new definition typed 'class kotlin.String'
The issue was not observed on v2.0.1 but appeared after upgrading to 2.1.4
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Have Mercy on Those Who Doubt | Desiring God
Suffice it to say, strange encounters with the resurrected Son of God and the scope of the mission he was giving them, colliding...
Read more >Rule 611. Mode and Order of Examining Witnesses and ...
(b) Scope of Cross-Examination. Cross-examination should not go beyond the subject matter of the direct examination and matters affecting the witness's ...
Read more >Object.Finalize Method (System) - Microsoft Learn
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
Read more >Resurrection difference in using Object Initializer
Essentially i'm trying to demonstrate the use of the c# finalizer and make an object that cannot die, I called it Zombie. Now,...
Read more >The Whole Creation Has Been Groaning - Baylor University
cosmic scope of God´s salvation in Jesus Christ. What ... perfected, so that it shares in the glory of the resurrected children of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks to @StanislavChumarin for investigation.
Maybe “deep copy” is not the accurate/right term here, but the idea is that a newly created scope should be only seeded with the compile time definitions (versus using the object directly as is). Scopes should not share among themselves the same seeded compile time definitions object, otherwise setting a new definition in runtime on a particular scope effectively sets it to all scopes (even future ones).