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

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


The following commit(s) were added to refs/heads/master by this push:
     new 7336fbc06 [KYUUBI #6534] Fix checkEngineConnectionAlive may throw NPE
7336fbc06 is described below

commit 7336fbc06537dca53c5df4f45fea7a6cd6a54b37
Author: Cheng Pan <[email protected]>
AuthorDate: Thu Jul 18 11:31:52 2024 +0800

    [KYUUBI #6534] Fix checkEngineConnectionAlive may throw NPE
    
    # :mag: Description
    ## Issue References ๐Ÿ”—
    
    This pull request fixes #6534
    
    ## Describe Your Solution ๐Ÿ”ง
    
    check null ahead.
    
    ## Types of changes :bookmark:
    
    - [x] Bugfix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
    
    ## Test Plan ๐Ÿงช
    
    Pass GHA
    
    ---
    
    # Checklist ๐Ÿ“
    
    - [x] This patch was not authored or co-authored using [Generative 
Tooling](https://www.apache.org/legal/generative-tooling.html)
    
    **Be nice. Be informative.**
    
    Closes #6540 from pan3793/client-npe.
    
    Closes #6534
    
    6976cd3f2 [Cheng Pan] [KYUUBI #6534] Fix checkEngineConnectionAlive may 
throw NPE
    
    Authored-by: Cheng Pan <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
---
 .../src/main/scala/org/apache/kyuubi/session/KyuubiSessionImpl.scala   | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionImpl.scala
 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionImpl.scala
index 166adc9f1..d0e8e042f 100644
--- 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionImpl.scala
+++ 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionImpl.scala
@@ -317,7 +317,8 @@ class KyuubiSessionImpl(
   }
 
   def checkEngineConnectionAlive(): Boolean = {
-    if (Option(client).exists(_.engineConnectionClosed)) return false
+    if (client == null) return true // client has not been initialized
+    if (client.engineConnectionClosed) return false
     !client.remoteEngineBroken
   }
 }

Reply via email to