pan3793 commented on code in PR #2819:
URL: https://github.com/apache/kyuubi/pull/2819#discussion_r1234781424


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala:
##########
@@ -204,14 +229,45 @@ private[v1] class BatchesResource extends 
ApiRequestContext with Logging {
         throw new NotAllowedException(t.getMessage)
     }
 
-    if (!session.user.equals(userName)) {
-      throw new NotAllowedException(
-        s"$userName is not allowed to close the session belong to 
${session.user}")
+    Option(sessionManager.getBatchSessionImpl(sessionHandle)).map { 
batchSession =>
+      if (userName != batchSession.user) {
+        throw new NotAllowedException(
+          s"$userName is not allowed to close the session belong to 
${batchSession.user}")
+      }
+      sessionManager.closeSession(batchSession.handle)
+      val (success, msg) = batchSession.batchJobSubmissionOp.getKillMessage
+      new CloseBatchResponse(success, msg)
+    }.getOrElse {
+      Option(sessionManager.getBatchSessionMetadata(batchId)).map { metadata =>
+        if (userName != metadata.username) {
+          throw new NotAllowedException(
+            s"$userName is not allowed to close the session belong to 
${metadata.username}")
+        } else if 
(OperationState.isTerminal(OperationState.withName(metadata.state)) ||

Review Comment:
   should `||` be replaced with `&&`? @turboFei 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to