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


##########
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:
   Lets agree to disagree. In fact, looking at the 
[documentation](https://arrow.apache.org/docs/format/FlightSql.html#flight-server-session-management),
 it's debatable if `closeSession` should always be sent. Probably it would make 
more sense to send it only when there are session options set. 
   
   Possibly, this is the reason for why it only sent `closeSession` when there 
was a `catalog` set. I'd say this is a future improvement



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