diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala index 7946a6266..47e75df00 100644 --- a/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala +++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/service/FrontendService.scala @@ -217,11 +217,12 @@ class FrontendService private (name: String, be: BackendService, oomHook: Runnab try { be.closeSession(handle) resp.setStatus(OK_STATUS) - Option(CURRENT_SERVER_CONTEXT.get()).foreach(_.setSessionHandle(null)) } catch { case e: Exception => warn("Error closing session: ", e) resp.setStatus(KyuubiSQLException.toTStatus(e)) + } finally { + Option(CURRENT_SERVER_CONTEXT.get()).foreach(_.setSessionHandle(null)) } info(s"Finished closing $handle") resp