Repository navigation
Conversation
KoinApplication.close stays final. Updates the koin-core API dump. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-4.3 # Conflicts: # docs/reference/koin-core/start-koin.md # docs/reference/koin-core/starting-koin.md
assertFailsWith's string argument is the assertion's failure message, so the
exception tests accepted any IllegalStateException. Assert the message instead,
and cover close() after use { } on Koin and KoinApplication.
6 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #2374 (closed as stale), rebased onto
4.3.0.Summary
KoinandKoinApplicationnow implementAutoCloseable, enabling Kotlin'suse { }pattern for safe resource cleanupclose()already existed with the right signature on both classes, so the change is the interface declaration plusoverrideKoinApplication.close()is declaredfinal override, so it stays non-overridable as before (KoinApplicationis an open class)koin-core.apiis updated: both classes now listjava/lang/AutoCloseableas a supertypeMotivation
Koin's
KoinandKoinApplicationhaveclose()methods but don't implementAutoCloseable, so developers can't use Kotlin'suse { }and must write manualtry/finallyblocks.With this change:
koinApplication { modules(myModule) }.use { app -> val service: MyService = app.koin.get() // work with service } // app.close() called automatically, even on exceptionsChanges
Koin.kt:AutoCloseableinterface andoverrideonclose()KoinApplication.kt:AutoCloseableinterface andfinal overrideonclose()koin-core.api: API dump updatedKoinAutoCloseableTest.kt: four tests coveringuse { }and close-on-exception for both classesstart-koin.md/starting-koin.md:use { }examplesCompatibility
KoinApplication.close()stays finalclose()keeps its existing semanticsAutoCloseableis available in the Kotlin stdlib for all targetsTest plan
./gradlew :core:koin-core:jvmTest --tests 'org.koin.core.KoinAutoCloseableTest'(4 tests pass)./gradlew :core:koin-core:apiCheckpasses🤖 Generated with Claude Code