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.
this method returns the resultset, so we should not close this resultset here
| } | ||
| finally { | ||
| if (null != stmt) | ||
| stmt.close(); |
There was a problem hiding this comment.
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.
I think we always omit the bracket when we can, so i did the same here.
There was a problem hiding this comment.
actually we started adding back the brackets even with one line of code, so lets keep the brackets here 😄
| assert null != st; | ||
| stmtParent = st; | ||
| con = st.connection; | ||
| SQLServerStatement s = null; |
There was a problem hiding this comment.
i guess s doesnt need to be instantiated to null but i did it for consistency
| 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.
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.