Skip to content

Commit 70a3005

Browse files
wForgetulysses-you
authored andcommitted
[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 94ac9ed [wforget] [KYUUBI-2422] Wrap close session with try-finally Authored-by: wforget <643348094@qq.com> Signed-off-by: ulysses-you <ulyssesyou@apache.org>
1 parent 6017917 commit 70a3005

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

kyuubi-common/src/main/scala/org/apache/kyuubi/session/SessionManager.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,11 @@ abstract class SessionManager(name: String) extends CompositeService(name) {
118118
throw KyuubiSQLException(s"Invalid $sessionHandle")
119119
}
120120
info(s"$sessionHandle is closed, current opening sessions $getOpenSessionCount")
121-
session.close()
122-
deleteOperationLogSessionDir(sessionHandle)
121+
try {
122+
session.close()
123+
} finally {
124+
deleteOperationLogSessionDir(sessionHandle)
125+
}
123126
}
124127

125128
private def deleteOperationLogSessionDir(sessionHandle: SessionHandle): Unit = {

kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionManager.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ class KyuubiSessionManager private (name: String) extends SessionManager(name) {
9595

9696
override def closeSession(sessionHandle: SessionHandle): Unit = {
9797
val session = getSession(sessionHandle)
98-
super.closeSession(sessionHandle)
99-
limiter.foreach(_.decrement(UserIpAddress(session.user, session.ipAddress)))
98+
try {
99+
super.closeSession(sessionHandle)
100+
} finally {
101+
limiter.foreach(_.decrement(UserIpAddress(session.user, session.ipAddress)))
102+
}
100103
}
101104

102105
def openBatchSession(

0 commit comments

Comments
 (0)