diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 2ec8c9d72e2..9a063da07bf 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -37,6 +37,9 @@ Release 0.23-PB - Unreleased HADOOP-7833. Fix findbugs warnings in protobuf generated code. (John Lee via suresh) + HADOOP-7897. ProtobufRpcEngine client side exception mechanism is not + consistent with WritableRpcEngine. (suresh) + Release 0.23.1 - Unreleased INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufHelper.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufHelper.java index 7f029618fa4..e30f28a698a 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufHelper.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufHelper.java @@ -33,14 +33,17 @@ private ProtobufHelper() { } /** - * Return the RemoteException wrapped in ServiceException as cause. - * @param se ServiceException that wraps RemoteException - * @return RemoteException wrapped in ServiceException or - * a new IOException that wraps unexpected ServiceException. + * Return the IOException thrown by the remote server wrapped in + * ServiceException as cause. + * @param se ServiceException that wraps IO exception thrown by the server + * @return Exception wrapped in ServiceException or + * a new IOException that wraps the unexpected ServiceException. */ public static IOException getRemoteException(ServiceException se) { Throwable e = se.getCause(); - return ((e instanceof RemoteException) ? (IOException) e : - new IOException(se)); + if (e == null) { + return new IOException(se); + } + return e instanceof IOException ? (IOException) e : new IOException(se); } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufRpcEngine.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufRpcEngine.java index 3db73859e58..637d3d9835e 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufRpcEngine.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtobufRpcEngine.java @@ -144,9 +144,10 @@ private HadoopRpcRequestProto constructRpcRequest(Method method, * * ServiceException has the following causes: *