aws / aws-advanced-jdbc-wrapper

The Amazon Web Services JDBC Driver has been redesigned as an advanced JDBC wrapper. This wrapper is complementary to and extends the functionality of an existing JDBC driver to help an application take advantage of the features of clustered databases such as Amazon Aurora.
Apache License 2.0
217 stars 46 forks source link

Don't get Statement from closed ResultSet #1130

Closed finlaycurran closed 1 month ago

finlaycurran commented 1 month ago

Summary

Don't attempt to get a statement from a closed ResultSet in getConnectionFromSqlObject.

Description

It's possible that getConnectionFromSqlObject is called on a ResultSet that is already closed, e.g. in DefaultConnectionPlugin when calling .close on a ResultSet. With some implementations, such as PgResultSet, calling getStatement on a closed ResultSet throws an SQLException. There is a performance overhead associated with creating and catching these exceptions everytime a ResultSet is used, and closed, so it should be avoided.

This is similar to an earlier issue fixed here: https://github.com/aws/aws-advanced-jdbc-wrapper/pull/682

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

sergiyvamz commented 1 month ago

Hi @finlaycurran

Thank you for your PR! We appreciate your help! Your PR is approved but it seems it's not up-to-date and needs to be rebased. Could you please rebase it?

Thank you!

finlaycurran commented 1 month ago

@sergiyvamz done!