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
Getting an error when using submodules that throws an exception.
To Reproduce
Steps to reproduce the behavior:
Use the includes keyword:
val commonModule = module {
includes(infrastructureModule, viewModels, useCases, repositories)
}
private val infrastructureModule = module {
single { CoroutineErrorCatcher(get()) }
single { DispatcherProvider(get<CoroutineErrorCatcher>().coroutineExceptionHandler) }
}
private val viewModels = module {
}
private val useCases = module {
}
private val repositories = module {
}
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List org.koin.core.module.Module.getIncludedModules()' on a null object reference
Expected behavior
Not throw exception
Koin module and version:
[e.g]: koin-core:4.0.0-RC1
The text was updated successfully, but these errors were encountered:
@OptIn(KoinInternalApi::class)
fun flatten(modules: List<Module>): Set<Module> {
// This is actually a DFS traversal of the module graph,
// but we're using a stack instead of recursion to avoid stack overflows and performance overhead.
val flatten = linkedSetOf<Module>()
// I added a filter not null to get ride of this even though it should not be possible to have a null in that list.
val stack = ArrayDeque(modules.asReversed().filterNotNull())
while (stack.isNotEmpty()) {
/* The problem is here some how it is getting a null module */
val current = stack.removeLast()
// If the module is already in the set, that means we've already visited it, so we can skip it.
if (!flatten.add(current)) {
continue
}
// Add all the included modules to the stack if they haven't been visited yet.
for (module in current.includedModules) {
if (module !in flatten) {
stack += module
}
}
}
return flatten
}
Getting an error when using submodules that throws an exception.
To Reproduce
Steps to reproduce the behavior:
Use the includes keyword:
val commonModule = module {
includes(infrastructureModule, viewModels, useCases, repositories)
}
private val infrastructureModule = module {
single { CoroutineErrorCatcher(get()) }
}
private val viewModels = module {
}
private val useCases = module {
}
private val repositories = module {
}
Expected behavior
Not throw exception
Koin module and version:
[e.g]:
koin-core:4.0.0-RC1
The text was updated successfully, but these errors were encountered: