You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by "turboFei (via GitHub)" <gi...@apache.org> on 2023/05/13 09:39:49 UTC

[GitHub] [kyuubi] turboFei commented on a diff in pull request #4837: Refactor code to prevent exception leak in operation that makes operations always pending

turboFei commented on code in PR #4837:
URL: https://github.com/apache/kyuubi/pull/4837#discussion_r1192956743


##########
kyuubi-common/src/main/scala/org/apache/kyuubi/operation/AbstractOperation.scala:
##########
@@ -165,10 +165,34 @@ abstract class AbstractOperation(session: Session) extends Operation with Loggin
 
   protected def afterRun(): Unit
 
+  protected def onError(): PartialFunction[Throwable, Unit]
+
+  protected def submitInBackground(r: Runnable): Future[_] = {
+    val onErrorRunnable = new Runnable {
+      override def run(): Unit =
+        try {
+          r.run()
+        } catch onError()
+    }
+    try {
+      session.sessionManager.submitBackgroundOperation(onErrorRunnable)
+    } catch {
+      case e: RejectedExecutionException =>
+        throw new KyuubiException(s"Error submitting $opType in background, request rejected", e)
+    }
+  }
+
   override def run(): Unit = {
-    beforeRun()
+    try {
+      beforeRun()
+    } catch {
+      onError()
+    }
+
     try {
       runInternal()
+    } catch {
+      onError()

Review Comment:
   the main change is in this class



-- 
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: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org