-
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
Fixes all statement leaks in the driver. #455
Conversation
@peterbae, |
} | ||
finally { | ||
if (null != orgCat) { | ||
if (null != rs) | ||
rs.close(); |
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.
this method returns the resultset, so we should not close this resultset here
@@ -1035,6 +1036,10 @@ else if (resultSet != null) { | |||
SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), null, true); | |||
} | |||
} | |||
finally { | |||
if (null != stmt) | |||
stmt.close(); |
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.
this statement creates resultset which will be returned, closing this statement also closes the returned resultset, which is not what we want
…ng statements when it's return type
Codecov Report
@@ Coverage Diff @@
## dev #455 +/- ##
======================================
Coverage ? 46.36%
Complexity ? 2202
======================================
Files ? 108
Lines ? 25258
Branches ? 4175
======================================
Hits ? 11710
Misses ? 11529
Partials ? 2019
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## dev #455 +/- ##
============================================
+ Coverage 46.33% 46.36% +0.03%
+ Complexity 2202 2198 -4
============================================
Files 108 108
Lines 25248 25264 +16
Branches 4170 4176 +6
============================================
+ Hits 11698 11714 +16
+ Misses 11531 11523 -8
- Partials 2019 2027 +8
Continue to review full report at Codecov.
|
…nd added a statement field that can be closed after the prepared statement is closed.
} | ||
finally { | ||
if (null != orgCat) { | ||
if (null != orgCat) |
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.
I think we always omit the bracket when we can, so i did the same here.
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.
actually we started adding back the brackets even with one line of code, so lets keep the brackets here 😄
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.
done.
@@ -563,6 +563,8 @@ private void checkClosed() throws SQLServerException { | |||
assert null != st; | |||
stmtParent = st; | |||
con = st.connection; | |||
SQLServerStatement s = null; |
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.
i guess s doesnt need to be instantiated to null but i did it for consistency
@@ -98,6 +98,9 @@ | |||
|
|||
/** The prepared statement handle returned by the server */ | |||
private int prepStmtHandle = 0; | |||
|
|||
/** Statement used for getMetadata(). Declared as a field to facilitate closing the statement. */ | |||
private SQLServerStatement internalStmt = null; |
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.
having internalStmt as a field is the only way to close it after the user is done working with the ResultsetMetadata.
Close all statements in the driver that are initialized locally but are never / sometimes not closed.
Fixes issue #308.