pan3793 commented on code in PR #5111:
URL: https://github.com/apache/kyuubi/pull/5111#discussion_r1280033293


##########
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiConnection.java:
##########
@@ -981,6 +986,43 @@ public void close() throws SQLException {
     }
   }
 
+  /**
+   * close the connection within timeout forcibly
+   *
+   * @param closeTimeout timeout for closing connection in seconds
+   * @throws SQLException
+   */
+  public void close(int closeTimeout) throws SQLException {
+    checkArgument(closeTimeout > 0, "closeTimeout must be greater than 0");
+    ExecutorService executor = Executors.newSingleThreadExecutor();
+    try {
+      SimpleTimeLimiter.create(executor)
+          .runWithTimeout(
+              () -> {
+                if (!isClosed) {
+                  TCloseSessionReq closeReq = new TCloseSessionReq(sessHandle);
+                  try {
+                    client.CloseSession(closeReq);
+                  } catch (TException e) {
+                    throw new RuntimeException(e);
+                  }
+                }
+              },
+              closeTimeout,
+              TimeUnit.SECONDS);
+    } catch (Exception e) {
+      LOG.error("Error while closing connection with in timeout", e);
+    } finally {
+      executor.shutdownNow();

Review Comment:
   > Once we abandoned a jammed JDBC connection on client side, we want to 
release and destroy the connection and the member instances inside the 
connection, like the transport and the client. How to achieve that?
   
   Abandon the whole `Connection` instance, and make sure to call 
`Connection#close` before losing reference.
   
   > And what's `cancel` for a JDBC connection?
   
   typo, I mean `close`



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to