Skip to content

Commit d11866d

Browse files
turboFeiulysses-you
authored andcommitted
[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 2671657 [Fei Wang] Fix npe in log capture thread Authored-by: Fei Wang <fwang12@ebay.com> Signed-off-by: ulysses-you <ulyssesyou@apache.org>
1 parent 659d981 commit d11866d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ProcBuilder.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ trait ProcBuilder {
196196
val maxErrorSize = conf.get(KyuubiConf.ENGINE_ERROR_MAX_SIZE)
197197
while (true) {
198198
if (reader.ready()) {
199-
var line: String = reader.readLine.trim
199+
var line: String = reader.readLine()
200200
if (containsException(line) &&
201201
!line.contains("at ") && !line.startsWith("Caused by:")) {
202202
val sb = new StringBuilder(line)
203203
error = KyuubiSQLException(sb.toString() + s"\n See more: $engineLog")
204-
line = reader.readLine().trim
204+
line = reader.readLine()
205205
while (sb.length < maxErrorSize && line != null &&
206206
(containsException(line) ||
207207
line.startsWith("\tat ") ||

0 commit comments

Comments
 (0)