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


##########
flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/client/ArrowFlightSqlClientHandler.java:
##########
@@ -291,22 +306,30 @@ 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.isEmpty() && 
NO_SESSION_STATUS_CODES.contains(fre.status().code())) {

Review Comment:
   Why is catalog such a relevant piece of information here? I don't understand 
why close was only called when there was a catalog and I don't understand why 
we surpress errors if it is empty.
   
   This seems tuned to a specific server implementation



##########
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:
   @AbhishekPathania, I understand what it does. What I'm still wondering is 
why the driver should be the one handling incomplete server implementations. I 
know AI makes it easy to cover edge cases like this, but conceptually I'd like 
to push back a bit on the decision. If new FlightStatusCode get added, it's 
unclear if they should also be part of `NO_SESSION_STATUS_CODES` or not



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