HADOOP-17914. Print RPC response length in the exception message (#3436)
This commit is contained in:
parent
f5c76c8e31
commit
71a601241c
@ -1907,10 +1907,12 @@ public ByteBuffer readResponse() throws IOException {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (length <= 0) {
|
if (length <= 0) {
|
||||||
throw new RpcException("RPC response has invalid length");
|
throw new RpcException(String.format("RPC response has " +
|
||||||
|
"invalid length of %d", length));
|
||||||
}
|
}
|
||||||
if (maxResponseLength > 0 && length > maxResponseLength) {
|
if (maxResponseLength > 0 && length > maxResponseLength) {
|
||||||
throw new RpcException("RPC response exceeds maximum data length");
|
throw new RpcException(String.format("RPC response has a " +
|
||||||
|
"length of %d exceeds maximum data length", length));
|
||||||
}
|
}
|
||||||
ByteBuffer bb = ByteBuffer.allocate(length);
|
ByteBuffer bb = ByteBuffer.allocate(length);
|
||||||
in.readFully(bb.array());
|
in.readFully(bb.array());
|
||||||
|
@ -1638,8 +1638,8 @@ public void testRpcResponseLimit() throws Throwable {
|
|||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Assert.assertNotNull(ioe);
|
Assert.assertNotNull(ioe);
|
||||||
Assert.assertEquals(RpcException.class, ioe.getClass());
|
Assert.assertEquals(RpcException.class, ioe.getClass());
|
||||||
Assert.assertEquals("RPC response exceeds maximum data length",
|
Assert.assertTrue(ioe.getMessage().contains(
|
||||||
ioe.getMessage());
|
"exceeds maximum data length"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Assert.fail("didn't get limit exceeded");
|
Assert.fail("didn't get limit exceeded");
|
||||||
|
Loading…
Reference in New Issue
Block a user