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

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


The following commit(s) were added to refs/heads/branch-1.7 by this push:
     new 86ca6591b [KYUUBI #4859] HttpException message should not be null
86ca6591b is described below

commit 86ca6591b8848ae3dd081176bb9f7578443378ba
Author: Cheng Pan <[email protected]>
AuthorDate: Fri May 19 11:44:40 2023 +0800

    [KYUUBI #4859] HttpException message should not be null
    
    ### _Why are the changes needed?_
    
    ```
      Cause: org.apache.http.HttpException: Cannot invoke 
"String.toCharArray()" because "message" is null
      at 
org.apache.kyuubi.jdbc.hive.auth.HttpRequestInterceptorBase.process(HttpRequestInterceptorBase.java:113)
      at 
org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:133)
      at 
org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
      at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
      at 
org.apache.http.impl.execchain.ServiceUnavailableRetryExec.execute(ServiceUnavailableRetryExec.java:85)
      at 
org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
      at 
org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
      at 
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118)
      at 
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
      at 
org.apache.thrift.transport.THttpClient.flushUsingHttpClient(THttpClient.java:251)
      ...
      Cause: java.lang.NullPointerException: Cannot invoke 
"String.toCharArray()" because "message" is null
      at org.apache.http.HttpException.clean(HttpException.java:48)
      at org.apache.http.HttpException.<init>(HttpException.java:105)
      at 
org.apache.kyuubi.jdbc.hive.auth.HttpKerberosRequestInterceptor.addHttpAuthHeader(HttpKerberosRequestInterceptor.java:68)
      at 
org.apache.kyuubi.jdbc.hive.auth.HttpRequestInterceptorBase.process(HttpRequestInterceptorBase.java:82)
      at 
org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:133)
      at 
org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
      at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
      at 
org.apache.http.impl.execchain.ServiceUnavailableRetryExec.execute(ServiceUnavailableRetryExec.java:85)
      at 
org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
      at 
org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
      ...
    ```
    
    ### _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/develop_tools/testing.html#running-tests)
 locally before make a pull request
    
    Closes #4859 from pan3793/http-exception.
    
    Closes #4859
    
    94c83a362 [Cheng Pan] HttpException message should not be null
    
    Authored-by: Cheng Pan <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
    (cherry picked from commit c5de33de7498bdc62029125329685dff7d9e10dc)
    Signed-off-by: Cheng Pan <[email protected]>
---
 .../apache/kyuubi/jdbc/hive/auth/HttpKerberosRequestInterceptor.java    | 2 +-
 .../org/apache/kyuubi/jdbc/hive/auth/HttpRequestInterceptorBase.java    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/auth/HttpKerberosRequestInterceptor.java
 
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/auth/HttpKerberosRequestInterceptor.java
index 278cef0b4..02d168c3f 100644
--- 
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/auth/HttpKerberosRequestInterceptor.java
+++ 
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/auth/HttpKerberosRequestInterceptor.java
@@ -65,7 +65,7 @@ public class HttpKerberosRequestInterceptor extends 
HttpRequestInterceptorBase {
       httpRequest.addHeader(
           HttpAuthUtils.AUTHORIZATION, HttpAuthUtils.NEGOTIATE + " " + 
kerberosAuthHeader);
     } catch (Exception e) {
-      throw new HttpException(e.getMessage(), e);
+      throw new HttpException(e.getMessage() == null ? "" : e.getMessage(), e);
     } finally {
       kerberosLock.unlock();
     }
diff --git 
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/auth/HttpRequestInterceptorBase.java
 
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/auth/HttpRequestInterceptorBase.java
index 9ce5a330b..42641c219 100644
--- 
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/auth/HttpRequestInterceptorBase.java
+++ 
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/auth/HttpRequestInterceptorBase.java
@@ -110,7 +110,7 @@ public abstract class HttpRequestInterceptorBase implements 
HttpRequestIntercept
         httpRequest.addHeader("Cookie", cookieHeaderKeyValues.toString());
       }
     } catch (Exception e) {
-      throw new HttpException(e.getMessage(), e);
+      throw new HttpException(e.getMessage() == null ? "" : e.getMessage(), e);
     }
   }
 

Reply via email to