AbhishekPathania commented on code in PR #1504:
URL: https://github.com/apache/arrow-java/pull/1504#discussion_r4631600985


##########
flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/client/ArrowFlightSqlClientHandler.java:
##########
@@ -291,22 +296,31 @@ public long executeUpdate(final String query) {
 
   @Override
   public void close() throws SQLException {
-    if (catalog.isPresent()) {
+    final CallOption[] baseOptions = getOptions();
+    final CallOption[] closeSessionOptions = Arrays.copyOf(baseOptions, 
baseOptions.length + 1);
+    closeSessionOptions[baseOptions.length] = CLOSE_SESSION_TIMEOUT;
+    try {
+      if (builder.ownsSession) {
+        sqlClient.closeSession(new CloseSessionRequest(), closeSessionOptions);
+      }
+    } catch (FlightRuntimeException fre) {
+      if (catalog.isPresent()) {
+        handleBenignCloseException(
+            fre, "Failed to close Flight SQL session.", "closing Flight SQL 
session");
+      } else {
+        // Without a catalog the driver never asked for a session; the server 
may not support them.
+        logSuppressedCloseException(fre, "closing Flight SQL session");

Review Comment:
   Thanks, fair point. I narrowed it. Without a catalog, close now only ignores 
statuses that mean there's no session to close:
   - `UNIMPLEMENTED`: servers without CloseSession (the Java, Go and C++ 
defaults)
   - `INVALID_ARGUMENT`: servers that don't know the action, like all Rust 
servers today 
(https://github.com/apache/arrow-rs/blob/9951b625879a19844ecd0b2dd352347a87ea26dd/arrow-flight/src/sql/server.rs#L451)
 and older Java/Go ones
   - `NOT_FOUND`: `ServerSessionMiddleware` when no session was created
   - `UNAUTHENTICATED`: the client isn't (or is no longer) authenticated, so 
there's no session. Without it, existing tests that connect without credentials 
(e.g. `ConnectionTest#testGetBasicClientNoAuthShouldOpenConnection`) fail on 
close.
   
   Everything else goes through the catalog path.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to