-
Notifications
You must be signed in to change notification settings - Fork 696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: EXPOSED-373 Close ResultSet before closing Statement to suppress Agroal leak warning #2247
Conversation
suppresses "JDBC resources leaked" warning with agroal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much for going ahead and opening this PR @ivan-gomes !
Please also add the same fix to the 2 other query ResultIterator
s: ReturningStatement and ExplainQuery.
Normally in an attempt to keep improving coverage, I'd also ask for a test, but I'll have to deal with that in the backlog. Based on my tests (using AgroalDataSource
from agroal-pool
with h2
), the leak warnings only start from version 2.3+, which requires at minimum jdk 11 and we have to keep using jdk 8 atm.
Thanks again and, once the changes above are made, this fix should make it into the upcoming release.
@ivan-gomes From my tests, I'm also seeing that insert statements that return auto-generated keys may produce a leak. |
address review comments
Done, and checked for any other unhandled occurrences of
Done, went with the latter so the assignment and cleanup are colocated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for the contribution @ivan-gomes !
Description
Summary of the change:
Close ResultSet before closing Statement. Motivation is to suppress "JDBC resource leaked" warning when used with agroal.
Detailed description:
Agroal, a popular
javax.sql.DataSource
implementation as used by Quarkus and others, issues a "leak report" before automatically closing tracked ResultSets and Statements. If a Statement is closed before related ResultSets are closed it will trigger a leak report - ref.ex.
This warning occurs on every query with results and can cause developers concern - ref.
The following is a trace of the "leaked" ResultSet being accounted.
Type of Change
Please mark the relevant options with an "X":
Updates/remove existing public API methods:
Affected databases:
Checklist
Related Issues
EXPOSED-373