[java client] Fix an NPE in KuduException

Saw this in a Jenkins run and also running ITClient on my machine.

Change-Id: Iceddc6931e8d3a8cb807657fc5c0804f7052e48f
Reviewed-on: http://gerrit.cloudera.org:8080/4488
Reviewed-by: Adar Dembo <a...@cloudera.com>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/8fc75a5c
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/8fc75a5c
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/8fc75a5c

Branch: refs/heads/master
Commit: 8fc75a5c654e100871316e61878b141df4707d0e
Parents: 519b222
Author: Jean-Daniel Cryans <jdcry...@apache.org>
Authored: Tue Sep 20 18:02:36 2016 -0700
Committer: Jean-Daniel Cryans <jdcry...@apache.org>
Committed: Thu Sep 22 00:33:20 2016 +0000

----------------------------------------------------------------------
 .../src/main/java/org/apache/kudu/client/KuduException.java | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/8fc75a5c/java/kudu-client/src/main/java/org/apache/kudu/client/KuduException.java
----------------------------------------------------------------------
diff --git 
a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduException.java 
b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduException.java
index 16b1072..f3afe92 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduException.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduException.java
@@ -80,20 +80,23 @@ public abstract class KuduException extends IOException {
    * @return a KuduException that's easier to handle
    */
   static KuduException transformException(Exception e) {
+    // The message may be null.
+    String message =  e.getMessage() == null ? "" : e.getMessage();
     if (e instanceof KuduException) {
       return (KuduException) e;
     } else if (e instanceof DeferredGroupException) {
       // TODO anything we can do to improve on that kind of exception?
     } else if (e instanceof TimeoutException) {
-      Status statusTimeout = Status.TimedOut(e.getMessage());
+      Status statusTimeout = Status.TimedOut(message);
       return new NonRecoverableException(statusTimeout, e);
     } else if (e instanceof InterruptedException) {
       // Need to reset the interrupt flag since we caught it but aren't 
handling it.
       Thread.currentThread().interrupt();
-      Status statusAborted = Status.Aborted(e.getMessage());
+
+      Status statusAborted = Status.Aborted(message);
       return new NonRecoverableException(statusAborted, e);
     }
-    Status status = Status.IOError(e.getMessage());
+    Status status = Status.IOError(message);
     return new NonRecoverableException(status, e);
   }
 }

Reply via email to