Fix proxying null value result set#745
Merged
markt-asf merged 1 commit intoapache:mainfrom Aug 22, 2024
Merged
Conversation
When invoking a method on a proxied statement returns `null`, that statement's proxy should also return `null`. In particular, `Statement#getResultSet` should not return a `ResultSetProxy` when the proxied statement returns `null`. Otherwise, that `ResultSet` proxy has a `null` delegate and calling methods on the proxy that lead to calling methods on the delegate could result in a `SqlException` with message "ResultSet closed." Only prevent creation of `ResultSetProxy` for `null` return values when invoking a method on `Statement`. In particular, don't do an early return for `void` methods like `#close` because there's cleanup code for that `close` method.
This was referenced Aug 18, 2024
Contributor
Author
|
Created bug ticket for this issue. |
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.
When invoking a method on a proxied statement returns
null, that statement's proxy should also returnnull.In particular,
Statement#getResultSetshould not return aResultSetProxywhen the proxied statement returnsnull. Otherwise, thatResultSetproxy has anulldelegate and calling methods on the proxy that lead to calling methods on the delegate could result in aSqlExceptionwith message "ResultSet closed."We found this issue because our Spring + MyBatis application started throwing
SqlExceptions when calling stored procedures after upgrading to Tomcat v. 10.1.28, whereas it didn't in version 10.1.26.Looking in the MyBatis code, it checks if a
Statement'sResultSetisnullor not. If it isn't—and it isn't when theResultSetis proxied with anulldelegate—, it later calls methodResultSet#getMetaData(). And that method now responds with theSqlExceptionwith message "ResultSet closed.".I think the new behavior was introduced in #742.