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 37f2c9888 [KYUUBI #5204] Thrift HTTP FE checks req conf nullable 
before evaluating proxy user
37f2c9888 is described below

commit 37f2c98883cf536b60e84b37a725da95f45dc668
Author: Cheng Pan <[email protected]>
AuthorDate: Mon Aug 28 10:21:20 2023 +0800

    [KYUUBI #5204] Thrift HTTP FE checks req conf nullable before evaluating 
proxy user
    
    ### _Why are the changes needed?_
    
    This PR fixes a NPE when client opens session with null configuration using 
Thrift HTTP protocol
    
    ```
    2023-08-28 02:03:56.512 ERROR 
org.apache.kyuubi.server.KyuubiTHttpFrontendService: Error opening session:
    java.lang.NullPointerException: null
            at 
org.apache.kyuubi.service.TFrontendService.getProxyUser(TFrontendService.scala:130)
 ~[kyuubi-common_2.12-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
            at 
org.apache.kyuubi.server.KyuubiTHttpFrontendService.getRealUserAndSessionUser(KyuubiTHttpFrontendService.scala:281)
 ~[kyuubi-server_2.12-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
            at 
org.apache.kyuubi.service.TFrontendService.getSessionHandle(TFrontendService.scala:168)
 ~[kyuubi-common_2.12-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
            at 
org.apache.kyuubi.service.TFrontendService.OpenSession(TFrontendService.scala:190)
 ~[kyuubi-common_2.12-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
            at 
org.apache.hive.service.rpc.thrift.TCLIService$Processor$OpenSession.getResult(TCLIService.java:1497)
 ~[hive-service-rpc-3.1.3.jar:3.1.3]
            at 
org.apache.hive.service.rpc.thrift.TCLIService$Processor$OpenSession.getResult(TCLIService.java:1482)
 ~[hive-service-rpc-3.1.3.jar:3.1.3]
            at 
org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39) 
~[libthrift-0.9.3.jar:0.9.3]
            at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39) 
~[libthrift-0.9.3.jar:0.9.3]
            at org.apache.thrift.server.TServlet.doPost(TServlet.java:83) 
~[libthrift-0.9.3.jar:0.9.3]
            at 
org.apache.kyuubi.server.http.ThriftHttpServlet.doPost(ThriftHttpServlet.scala:146)
 ~[kyuubi-server_2.12-1.8.0-SNAPSHOT.jar:1.8.0-SNAPSHOT]
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:517) 
~[jakarta.servlet-api-4.0.4.jar:4.0.4]
    ```
    
    ### _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.readthedocs.io/en/master/contributing/code/testing.html#running-tests)
 locally before make a pull request
    
    ### _Was this patch authored or co-authored using generative AI tooling?_
    
    No
    
    Closes #5204 from pan3793/http-null.
    
    Closes #5204
    
    1116b5efc [Cheng Pan] Thrift HTTP FE checks req conf nullable before 
evaluating proxy user
    
    Authored-by: Cheng Pan <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
---
 .../scala/org/apache/kyuubi/server/KyuubiTHttpFrontendService.scala | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTHttpFrontendService.scala
 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTHttpFrontendService.scala
index 63933aa77..79351118c 100644
--- 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTHttpFrontendService.scala
+++ 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiTHttpFrontendService.scala
@@ -278,7 +278,11 @@ final class KyuubiTHttpFrontendService(
     val realUser = 
getShortName(Option(SessionManager.getUserName).getOrElse(req.getUsername))
     // using the remote ip address instead of that in proxy http header for 
authentication
     val ipAddress: String = SessionManager.getIpAddress
-    val sessionUser: String = getProxyUser(req.getConfiguration, ipAddress, 
realUser)
+    val sessionUser: String = if (req.getConfiguration == null) {
+      realUser
+    } else {
+      getProxyUser(req.getConfiguration, ipAddress, realUser)
+    }
     debug(s"Client's real user: $realUser, session user: $sessionUser")
     realUser -> sessionUser
   }

Reply via email to