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

achennaka pushed a commit to branch branch-1.17.x
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/branch-1.17.x by this push:
     new 2869fef2d [java] fix NPE in Connection::exceptionCaught()
2869fef2d is described below

commit 2869fef2dfc747724e8529de48748bd74ecf2193
Author: Alexey Serbin <ale...@apache.org>
AuthorDate: Thu Jan 4 10:06:17 2024 -0800

    [java] fix NPE in Connection::exceptionCaught()
    
    Before this patch, an NPE might be thrown by the Java Kudu client
    when trying to establish a connection to a Kudu server.  I have a test
    scenario to reproduce the issue, but it requires a lot of latency and
    failure injection on the server side, which I'm not going to add just to
    reproduce this issue.  However, the issue is real and might be hit
    in field when Kudu servers run on very busy nodes, sharing the node's
    CPU and memory resources with many other active processes, and Kudu's
    acceptor thread might be often de-scheduled, so a long queue of pending
    connections grows at the server's RPC socket.
    
    It's quite clear the code before this patch had the corresponding
    deficiency, so I think this patch is good to go without adding a test
    that reproducing the issue.  If I can eventually justify adding
    all the latency and failure injection at the server side, I'll add the
    corresponding test as well in a follow-up patch.
    
    Change-Id: Ibd6eed2ecdcadab7eaff301f3a3f3d5dcacfd83d
    Reviewed-on: http://gerrit.cloudera.org:8080/20858
    Tested-by: Kudu Jenkins
    Reviewed-by: Abhishek Chennaka <achenn...@cloudera.com>
    (cherry picked from commit fde29c3aa1bdf1d46b093207e56e955f7b05f151)
    Reviewed-on: http://gerrit.cloudera.org:8080/20865
    Tested-by: Alexey Serbin <ale...@apache.org>
---
 .../kudu-client/src/main/java/org/apache/kudu/client/Connection.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git 
a/java/kudu-client/src/main/java/org/apache/kudu/client/Connection.java 
b/java/kudu-client/src/main/java/org/apache/kudu/client/Connection.java
index cd8ad8c3e..c495b0d5d 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/Connection.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/Connection.java
@@ -445,8 +445,9 @@ class Connection extends 
SimpleChannelInboundHandler<Object> {
       // If the connection was explicitly disconnected via a call to 
disconnect(), we should
       // have either gotten a ClosedChannelException or an SSLException.
       assert !explicitlyDisconnected;
-      String message = String.format("%s unexpected exception from downstream 
on %s",
-                                     getLogPrefix(), ctx.channel());
+      String channelInfo = ctx == null ? "" : String.format(" on %s", 
ctx.channel());
+      String message = String.format(
+          "%s unexpected exception from downstream%s", getLogPrefix(), 
channelInfo);
       error = new RecoverableException(Status.NetworkError(message), e);
       LOG.error(message, e);
     }

Reply via email to