Unverified Commit 70a3005e authored by wforget's avatar wforget Committed by ulysses-you
Browse files

[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: default avatarwforget <643348094@qq.com>
Signed-off-by: default avatarulysses-you <ulyssesyou@apache.org>
No related merge requests found
Showing with 10 additions and 4 deletions
+10 -4
......@@ -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 = {
......
......@@ -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(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment