Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public static Connection getConnectionFromSqlObject(final Object obj) {
return !stmt.isClosed() ? stmt.getConnection() : null;
} else if (obj instanceof ResultSet) {
final ResultSet rs = (ResultSet) obj;
final Statement stmt = rs.getStatement();
final Statement stmt = !rs.isClosed() ? rs.getStatement() : null;
return stmt != null && !stmt.isClosed() ? stmt.getConnection() : null;
}
} catch (final SQLException | UnsupportedOperationException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ void getConnectionFromSqlObjectChecksStatementNotClosed() throws Exception {
assertNull(rsConn);
}

@Test
void getConnectionFromSqlObjectChecksResultSetNotClosed() throws Exception {
final ResultSet mockResultSet = mock(ResultSet.class);
when(mockResultSet.isClosed()).thenReturn(true);
when(mockResultSet.getStatement()).thenThrow(IllegalStateException.class);

final Connection rsConn = WrapperUtils.getConnectionFromSqlObject(mockResultSet);
assertNull(rsConn);
}

@Test
void testStatementWrapper() throws InstantiationException {
ConnectionPluginManager mockPluginManager = mock(ConnectionPluginManager.class);
Expand Down