Close the database connection pool when the plugin is disabled - #98
Merged
Merged
Conversation
The HikariCP pool built in onEnable was never closed, so it survived every plugin disable that was not a full server shutdown with its connections and housekeeping threads intact, while the next onEnable built a second pool beside it. Closes #97 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
|
Self-review rubric, scored against the diff and command output rather than intent:
Findings folded in from reading the diff, none of which changes the verdict:
This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
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.
Summary
onDisableis now declared onAlternateAccountFinderand closes the HikariCP pool built during startup. The pool was previously never closed, so every disable short of a full server shutdown —/reload, and any plugin manager that disables and re-enables the plugin — left its connections and housekeeping threads running while the nextonEnablebuilt a second pool beside them.closeDataSource(DataSource, Logger), following thePlayerJoinListener.parseValidUuidsprecedent for logic that would otherwise be locked behindJavaPlugin. A pool that was never built (anonEnablethat threw before the assignment) and aDataSourcethat is not closeable are both no-ops; a close that throws is logged atWARNINGrather than rethrown, since an exception out ofonDisableis reported by Bukkit as a plugin fault.HikariDataSourceover in-memory H2 is asserted closed, and the null, not-closeable and throwing paths are asserted not to throw.Fixedentry was added under[Unreleased]inCHANGELOG.md.No behaviour visible to a command, a config key or the stored data changes, and no IP address reaches any new output or log path.
Test plan
./gradlew clean buildpasses locally, including the four new tests.closeDataSourcereplaced by an early return,closesAPoolThatIsCloseableandwarnsRatherThanThrowsWhenTheCloseFailsboth fail; both pass once it is restored./reload confirmis run twice, and a thread dump (or/dpm-style disable and re-enable) is inspected forHikariPool-*housekeeping threads. Exactly one pool should be present afterwards rather than one per reload, and noFailed to close the database connection poolwarning should appear in the log.Coverage gap
The
Buildworkflow exercises the JVM build against H2 only and cannot start a Bukkit server, so theonDisablewiring — as opposed to the helper it calls — is not verified by CI. The manual step above is what covers it.Backlog deferred this cycle
The rest of the open backlog was left untouched because every item is gated on a human: #89 is down to its branch-protection item, which needs repository-settings access; #62 requires authorization to edit agent-loaded configuration (
.github/copilot-instructions.md); and epic #47 is awaiting confirmation that its scope is fully covered.Closes #97
This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson