InsertKoinIO / koin

Koin - a pragmatic lightweight dependency injection framework for Kotlin & Kotlin Multiplatform
https://insert-koin.io
Apache License 2.0
9.08k stars 719 forks source link

checkKoinModules produce ConcurrentModificationException #1744

Closed do-kuznetsov closed 9 months ago

do-kuznetsov commented 10 months ago

Test environment with checkKoinModules produce kotlin.ConcurrentModificationException.

Stacktrace:

  1. checkKoinModules
  2. Koin.checkModules
  3. Koin.close
  4. ScopeRegistry.closeAllScopes Attention: _scopes.values.forEach
  5. Scope.close Attention: _koin.scopeRegistry.deleteScope(this)
  6. ScopeRegistry.deleteScope Attention: _scopes.remove(scope.id) // ConcurrentModificationException _scopes is a HashMap from Kotlin/Native and starts from 1.9.20 it has a checkForComodification that produce exception when collection changed in forEach loop.

Koin module and version: Starts from Kotlin 1.9.20

Snippet or Sample project to help reproduce

Снимок экрана 2023-12-27 в 01 11 39

Maybe in test environment we need use special mechanism for scopes that avoid problem with ConcurrentModificationException, but docs doesn't have info about it: https://insert-koin.io/docs/reference/koin-test/checkmodules

do-kuznetsov commented 9 months ago

duplicates: https://github.com/InsertKoinIO/koin/issues/1711