-
Notifications
You must be signed in to change notification settings - Fork 426
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 | Fix possible Statement Leak in SQLServerConnection.isValid() API #955
Fix | Fix possible Statement Leak in SQLServerConnection.isValid() API #955
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #955 +/- ##
============================================
- Coverage 50.58% 50.56% -0.02%
- Complexity 2915 2918 +3
============================================
Files 120 120
Lines 27987 27989 +2
Branches 4678 4679 +1
============================================
- Hits 14156 14154 -2
- Misses 11535 11542 +7
+ Partials 2296 2293 -3
Continue to review full report at Codecov.
|
I am afraid that PR changes the code semantics. The valid=true is set before the close, the following comment explicitly says that an exception on close is also invalid. Maybe it is easier to add a return false to the catch and remove the flag completely. This also allows for nicer logging |
I added |
it's unnecessary as valid was init to false, so unless set to true it would already still be false |
As long as isValid=true is inside the try block it will be executed before the auto close. If the autoclose fails the catch is executed while isValid is already true. So setting it to false is one possible fix to keep the old semantic. (Personally i don’t like single-exit because of exactly that kind of problem but imguess its a good idea to stay consistent with existing conventions) |
Would you re-run the CI? Seems like it fails on ConnectionDriverTest? |
f5fd4be
Fixes #954
SQLServerStatement
in try-with-resources block.