HADOOP-18143. Introduce additional null safety checks

This commit is contained in:
9uapaw 2022-02-28 17:02:48 +01:00
parent efdfab807f
commit 1ecdcf0ef1
1 changed files with 6 additions and 2 deletions

View File

@ -658,8 +658,9 @@ public class ProtobufRpcEngine2 implements RpcEngine {
public void writeTo(ResponseBuffer out) throws IOException {
lock.lock();
try {
requestHeader.writeDelimitedTo(out);
if (payload != null) {
RequestHeaderProto request = getRequestHeader();
if (payload != null && request != null) {
request.writeDelimitedTo(out);
payload.writeDelimitedTo(out);
}
} finally {
@ -672,6 +673,9 @@ public class ProtobufRpcEngine2 implements RpcEngine {
public String toString() {
try {
RequestHeaderProto header = getRequestHeader();
if (header == null) {
throw new IllegalArgumentException("No request header is found");
}
return header.getDeclaringClassProtocolName() + "." +
header.getMethodName();
} catch (IOException e) {