You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ul...@apache.org on 2022/04/14 01:42:08 UTC

[incubator-kyuubi] branch master updated: [KYUUBI #2354] Fix NPE in process builder log capture thread

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

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


The following commit(s) were added to refs/heads/master by this push:
     new d11866df4 [KYUUBI #2354] Fix NPE in process builder log capture thread
d11866df4 is described below

commit d11866df45ff5e0684dc9ebef065b0b8d36a5ade
Author: Fei Wang <fw...@ebay.com>
AuthorDate: Thu Apr 14 09:41:56 2022 +0800

    [KYUUBI #2354] Fix NPE in process builder log capture thread
    
    ### _Why are the changes needed?_
    
    I saw NPE in UT.
    ```
    Exception in thread "process-logger-capture: Thread-1972" java.lang.NullPointerException
            at org.apache.kyuubi.engine.ProcBuilder.$anonfun$start$1(ProcBuilder.scala:204)
            at java.base/java.lang.Thread.run(Thread.java:829)
    ```
    
    For BufferedReader::readLine method,
    ```
    Returns:
    A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached
    ```
    
    ### _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
    
    - [ ] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #2354 from turboFei/npe_line_read.
    
    Closes #2354
    
    26716577 [Fei Wang] Fix npe in log capture thread
    
    Authored-by: Fei Wang <fw...@ebay.com>
    Signed-off-by: ulysses-you <ul...@apache.org>
---
 .../src/main/scala/org/apache/kyuubi/engine/ProcBuilder.scala         | 4 ++--
 1 file changed, 2 insertions(+), 2 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 d6cf9426e..2919dbb91 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
@@ -196,12 +196,12 @@ trait ProcBuilder {
         val maxErrorSize = conf.get(KyuubiConf.ENGINE_ERROR_MAX_SIZE)
         while (true) {
           if (reader.ready()) {
-            var line: String = reader.readLine.trim
+            var line: String = reader.readLine()
             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().trim
+              line = reader.readLine()
               while (sb.length < maxErrorSize && line != null &&
                 (containsException(line) ||
                   line.startsWith("\tat ") ||