Skip to content

Commit f04ae77

Browse files
committed
add handling for IOE.getMessage() being null; final sanity checks in setupResponse() guarantee that on a failure both error class and text are never null
1 parent fb1450e commit f04ae77

File tree

1 file changed

+5
-3
lines changed
  • hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc

1 file changed

+5
-3
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Server.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,7 +1994,8 @@ private void processOneRpc(byte[] buf)
19941994
final Call call = new Call(callId, retry, null, this);
19951995
setupResponse(authFailedResponse, call,
19961996
RpcStatusProto.FATAL, wrse.getRpcErrorCodeProto(), null,
1997-
ioe.getClass().getName(), ioe.getMessage());
1997+
ioe.getClass().getName(),
1998+
ioe.getMessage() != null ? ioe.getMessage() : ioe.toString());
19981999
call.sendResponse();
19992000
throw wrse;
20002001
}
@@ -2597,8 +2598,9 @@ private static void setupResponse(ByteArrayOutputStream responseBuf,
25972598
return;
25982599
}
25992600
} else { // Rpc Failure
2600-
headerBuilder.setExceptionClassName(errorClass);
2601-
headerBuilder.setErrorMsg(error);
2601+
headerBuilder.setExceptionClassName(errorClass != null
2602+
? errorClass : "RPC failure with no error provided");
2603+
headerBuilder.setErrorMsg(error != null ? error : "");
26022604
headerBuilder.setErrorDetail(erCode);
26032605
RpcResponseHeaderProto header = headerBuilder.build();
26042606
int headerLen = header.getSerializedSize();

0 commit comments

Comments
 (0)