This is an automated email from the ASF dual-hosted git repository.

yao pushed a commit to branch branch-1.4
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git


The following commit(s) were added to refs/heads/branch-1.4 by this push:
     new 18c422b  [KYUUBI #2078] `logCaptureThread` does not catch sparksubmit 
exception
18c422b is described below

commit 18c422b6ba4505537295d71a698270da718a2625
Author: SteNicholas <[email protected]>
AuthorDate: Thu Mar 10 15:00:29 2022 +0800

    [KYUUBI #2078] `logCaptureThread` does not catch sparksubmit exception
    
    ### _Why are the changes needed?_
    
    `logCaptureThread` does not catch sparksubmit exception.
    
    ### _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
    
    - [x] [Run 
test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests)
 locally before make a pull request
    
    Closes #2090 from SteNicholas/KYUUBI-2078.
    
    Closes #2078
    
    11ff6824 [SteNicholas] [KYUUBI #2078] logCaptureThread does not catch 
sparksubmit exception
    
    Authored-by: SteNicholas <[email protected]>
    Signed-off-by: Kent Yao <[email protected]>
    (cherry picked from commit cf014ee282d28e717acb6e243522944e7bbb07cd)
    Signed-off-by: Kent Yao <[email protected]>
---
 .../src/main/scala/org/apache/kyuubi/engine/ProcBuilder.scala | 11 +++++++----
 .../apache/kyuubi/engine/spark/SparkProcessBuilderSuite.scala | 10 ++++++++++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ProcBuilder.scala 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ProcBuilder.scala
index bf1ca92..eda8cbc 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ProcBuilder.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ProcBuilder.scala
@@ -123,14 +123,14 @@ trait ProcBuilder {
         val maxErrorSize = conf.get(KyuubiConf.ENGINE_ERROR_MAX_SIZE)
         while (true) {
           if (reader.ready()) {
-            var line: String = reader.readLine
-            if (containsIgnoreCase(line, "Exception:") &&
+            var line: String = reader.readLine.trim
+            if (containsException(line) &&
               !line.contains("at ") && !line.startsWith("Caused by:")) {
               val sb = new StringBuilder(line)
               error = KyuubiSQLException(sb.toString() + s"\n See more: 
$engineLog")
-              line = reader.readLine()
+              line = reader.readLine().trim
               while (sb.length < maxErrorSize && line != null &&
-                (containsIgnoreCase(line, "Exception:") ||
+                (containsException(line) ||
                   line.startsWith("\tat ") ||
                   line.startsWith("Caused by: "))) {
                 sb.append("\n" + line)
@@ -201,6 +201,9 @@ trait ProcBuilder {
       case other => other
     }
   }
+
+  private def containsException(log: String): Boolean =
+    containsIgnoreCase(log, "Exception:") || containsIgnoreCase(log, 
"Exception in thread")
 }
 
 object ProcBuilder extends Logging {
diff --git 
a/kyuubi-server/src/test/scala/org/apache/kyuubi/engine/spark/SparkProcessBuilderSuite.scala
 
b/kyuubi-server/src/test/scala/org/apache/kyuubi/engine/spark/SparkProcessBuilderSuite.scala
index d50b75a..80c6a89 100644
--- 
a/kyuubi-server/src/test/scala/org/apache/kyuubi/engine/spark/SparkProcessBuilderSuite.scala
+++ 
b/kyuubi-server/src/test/scala/org/apache/kyuubi/engine/spark/SparkProcessBuilderSuite.scala
@@ -95,6 +95,16 @@ class SparkProcessBuilderSuite extends KerberizedTestHelper {
       assert(error1.getMessage.contains("See more: "))
       assert(!error1.getMessage.contains(msg), "stack trace shall be 
truncated")
     }
+
+    val pb3 =
+      new SparkProcessBuilder("kentyao", conf.set("spark.kerberos.principal", 
testPrincipal))
+    pb3.start
+    eventually(timeout(90.seconds), interval(500.milliseconds)) {
+      val error1 = pb3.getError
+      assert(!error1.getMessage.contains("Failed to detect the root cause"))
+      assert(error1.getMessage.contains("See more: "))
+      assert(error1.getMessage.contains("Exception in thread"))
+    }
   }
 
   test("proxy user or keytab") {

Reply via email to