fix(core): close CallableStatement in DerbySnapshotOperation to prevent JDBC resource leak#14743
Merged
KomachiSion merged 1 commit intoMar 31, 2026
Conversation
…ackup The CallableStatement was not included in the try-with-resources block, causing a JDBC resource leak on each Derby backup operation. This moves it into the try-with-resources declaration to ensure proper cleanup.
|
Thanks for your this PR. 🙏 感谢您提交的PR。 🙏 |
KomachiSion
approved these changes
Mar 31, 2026
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.
Problem
In
DerbySnapshotOperation.doDerbyBackup(), theCallableStatementis created inside a try-with-resources block that only manages theConnection. The statement itself is never closed, causing a JDBC resource leak on each Derby snapshot backup operation.Root Cause
The
CallableStatementwas created as a local variable inside the try block rather than being declared in the try-with-resources header:While closing the
Connectionmay implicitly close associated statements in some JDBC drivers, the JDBC specification does not guarantee this behavior, and relying on it is a resource management anti-pattern.Fix
CallableStatementdeclaration into the try-with-resources header so it is automatically closed after use, consistent with JDBC best practices.Tests Added
testOnSnapshotSaveWithMocks()— addedverify(callableStatement).close()to confirm the statement is properly closed after backup executionImpact
Only affects Derby embedded database backup operations. No behavioral change — backups work identically, but the
CallableStatementis now properly closed after each use.