Skip to content

Commit face72f

Browse files
GH-1502: [JDBC] Return early from closeSession when the session is not owned
1 parent 6ff3aff commit face72f

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/client/ArrowFlightSqlClientHandler.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,14 @@ public void close() throws SQLException {
320320
}
321321

322322
private void closeSession() throws SQLException {
323+
if (!builder.ownsSession) {
324+
return;
325+
}
323326
final CallOption[] baseOptions = getOptions();
324327
final CallOption[] closeSessionOptions = Arrays.copyOf(baseOptions, baseOptions.length + 1);
325328
closeSessionOptions[baseOptions.length] = CLOSE_SESSION_TIMEOUT;
326329
try {
327-
if (builder.ownsSession) {
328-
sqlClient.closeSession(new CloseSessionRequest(), closeSessionOptions);
329-
}
330+
sqlClient.closeSession(new CloseSessionRequest(), closeSessionOptions);
330331
} catch (FlightRuntimeException fre) {
331332
if (catalog.isEmpty() && NO_SESSION_STATUS_CODES.contains(fre.status().code())) {
332333
logSuppressedCloseException(fre, "closing Flight SQL session");

‎flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/client/ArrowFlightSqlClientHandlerTest.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ private static Object[] testCloseSessionWithoutCatalog() {
187187
new Object[] {FlightStatusCode.UNAVAILABLE, true},
188188
new Object[] {FlightStatusCode.UNAUTHENTICATED, true},
189189
new Object[] {FlightStatusCode.UNKNOWN, false},
190+
new Object[] {FlightStatusCode.TIMED_OUT, false},
190191
};
191192
}
192193

0 commit comments

Comments
 (0)