Skip to content

Commit 71a6012

Browse files
authored
HADOOP-17914. Print RPC response length in the exception message (#3436)
1 parent f5c76c8 commit 71a6012

File tree

2 files changed

+6
-4
lines changed
  • hadoop-common-project/hadoop-common/src

2 files changed

+6
-4
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,10 +1907,12 @@ public ByteBuffer readResponse() throws IOException {
19071907
}
19081908
}
19091909
if (length <= 0) {
1910-
throw new RpcException("RPC response has invalid length");
1910+
throw new RpcException(String.format("RPC response has " +
1911+
"invalid length of %d", length));
19111912
}
19121913
if (maxResponseLength > 0 && length > maxResponseLength) {
1913-
throw new RpcException("RPC response exceeds maximum data length");
1914+
throw new RpcException(String.format("RPC response has a " +
1915+
"length of %d exceeds maximum data length", length));
19141916
}
19151917
ByteBuffer bb = ByteBuffer.allocate(length);
19161918
in.readFully(bb.array());

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestIPC.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,8 +1638,8 @@ public void testRpcResponseLimit() throws Throwable {
16381638
} catch (IOException ioe) {
16391639
Assert.assertNotNull(ioe);
16401640
Assert.assertEquals(RpcException.class, ioe.getClass());
1641-
Assert.assertEquals("RPC response exceeds maximum data length",
1642-
ioe.getMessage());
1641+
Assert.assertTrue(ioe.getMessage().contains(
1642+
"exceeds maximum data length"));
16431643
return;
16441644
}
16451645
Assert.fail("didn't get limit exceeded");

0 commit comments

Comments
 (0)