From c0fd09c42ced09a25914195e38d1c7d581a105dd Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Fri, 13 Oct 2017 13:31:01 +0100 Subject: [PATCH] HADOOP-9844. NPE when trying to create an error message response of SASL RPC This closes #55 Change-Id: I10a20380565fa89762f4aa564b2f1c83b9aeecdc Signed-off-by: Akira Ajisaka (cherry picked from commit 07530314c2130ecd1525682c59bf51f15b82c024) --- .../src/main/java/org/apache/hadoop/ipc/IpcException.java | 5 ++--- .../src/main/java/org/apache/hadoop/ipc/Server.java | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/IpcException.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/IpcException.java index e55eda93778..61c42b80887 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/IpcException.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/IpcException.java @@ -26,9 +26,8 @@ import java.io.IOException; */ public class IpcException extends IOException { private static final long serialVersionUID = 1L; - - final String errMsg; + public IpcException(final String err) { - errMsg = err; + super(err); } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java index 154877bf327..79fbf827922 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java @@ -1948,7 +1948,7 @@ public abstract class Server { private void doSaslReply(Exception ioe) throws IOException { setupResponse(authFailedCall, RpcStatusProto.FATAL, RpcErrorCodeProto.FATAL_UNAUTHORIZED, - null, ioe.getClass().getName(), ioe.getLocalizedMessage()); + null, ioe.getClass().getName(), ioe.toString()); sendResponse(authFailedCall); } @@ -2307,7 +2307,8 @@ public abstract class Server { final RpcCall call = new RpcCall(this, callId, retry); setupResponse(call, rse.getRpcStatusProto(), rse.getRpcErrorCodeProto(), null, - t.getClass().getName(), t.getMessage()); + t.getClass().getName(), + t.getMessage() != null ? t.getMessage() : t.toString()); sendResponse(call); } }