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


##########
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:
   @xborder I think the driver needs to handle it, since most servers don't 
implement CloseSession today, including the reference Java, Go, C++ and Rust 
ones. If close() always sends it, it has to treat "not supported" as nothing to 
close, otherwise close() fails on all of them. ADBC's Go driver handles it in 
the driver too: 
https://github.com/apache/arrow-adbc/blob/40323c6da8cd22079439cec704e1b9ea67e94003/go/adbc/driver/flightsql/flightsql_connection.go#L1329-L1339
   
   On new status codes, the list only has the ones that mean there's no session 
to close, so a new code isn't on it and fails like any other error. Adding one 
later is a one-line change if a server needs it.



-- 
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