Skip to content

Commit a843b94

Browse files
committed
Suppress IllegalStateException when closing closed JDBC connection
The `LazyConnection#delegate` method throws `IllegalStateException` if the connection is already closed, we should ensure that such exceptions are caught and suppressed during connection close to avoid unnecessary propagation.
1 parent 2a0ff84 commit a843b94

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcPageSink.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ public void abort()
238238
connection.close();
239239
}
240240
}
241+
catch (IllegalStateException e) {
242+
if (e.getMessage().equals("Connection is already closed")) {
243+
return;
244+
}
245+
throw new TrinoException(JDBC_ERROR, e);
246+
}
241247
catch (SQLException e) {
242248
throw new TrinoException(JDBC_ERROR, e);
243249
}

0 commit comments

Comments
 (0)