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 69203c209c2..6b07653588f 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 @@ -90,8 +90,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 = {