You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ul...@apache.org on 2022/04/20 01:36:27 UTC

[incubator-kyuubi] branch master updated: [KYUUBI #2422] Wrap close session with try-finally

This is an automated email from the ASF dual-hosted git repository.

ulyssesyou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new 70a3005ea [KYUUBI #2422] Wrap close session with try-finally
70a3005ea is described below

commit 70a3005ea7893d1065b33ee2dcd6ddfe454db723
Author: wforget <64...@qq.com>
AuthorDate: Wed Apr 20 09:36:16 2022 +0800

    [KYUUBI #2422] Wrap close session with try-finally
    
    ### _Why are the changes needed?_
    
    close #2422
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [ ] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #2423 from wForget/KYUUBI-2422.
    
    Closes #2422
    
    94ac9ed1 [wforget] [KYUUBI-2422] Wrap close session with try-finally
    
    Authored-by: wforget <64...@qq.com>
    Signed-off-by: ulysses-you <ul...@apache.org>
---
 .../src/main/scala/org/apache/kyuubi/session/SessionManager.scala  | 7 +++++--
 .../scala/org/apache/kyuubi/session/KyuubiSessionManager.scala     | 7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/session/SessionManager.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/session/SessionManager.scala
index c0025f9b0..ccc263915 100644
--- a/kyuubi-common/src/main/scala/org/apache/kyuubi/session/SessionManager.scala
+++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/session/SessionManager.scala
@@ -118,8 +118,11 @@ abstract class SessionManager(name: String) extends CompositeService(name) {
       throw KyuubiSQLException(s"Invalid $sessionHandle")
     }
     info(s"$sessionHandle is closed, current opening sessions $getOpenSessionCount")
-    session.close()
-    deleteOperationLogSessionDir(sessionHandle)
+    try {
+      session.close()
+    } finally {
+      deleteOperationLogSessionDir(sessionHandle)
+    }
   }
 
   private def deleteOperationLogSessionDir(sessionHandle: SessionHandle): Unit = {
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionManager.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionManager.scala
index 404a2d4e0..97ba4fddf 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionManager.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionManager.scala
@@ -95,8 +95,11 @@ class KyuubiSessionManager private (name: String) extends SessionManager(name) {
 
   override def closeSession(sessionHandle: SessionHandle): Unit = {
     val session = getSession(sessionHandle)
-    super.closeSession(sessionHandle)
-    limiter.foreach(_.decrement(UserIpAddress(session.user, session.ipAddress)))
+    try {
+      super.closeSession(sessionHandle)
+    } finally {
+      limiter.foreach(_.decrement(UserIpAddress(session.user, session.ipAddress)))
+    }
   }
 
   def openBatchSession(