@Test
  public void testBoundedByteBufferReceiveOnLargeRequest() throws Exception {
    int bufferSize = 2000;
    ByteBuffer buffer = ByteBuffer.allocate(bufferSize);
    buffer.putLong(bufferSize);
    byte[] buf = new byte[bufferSize - Long.BYTES];
    new Random().nextBytes(buf);
    buffer.put(buf);
    buffer.flip();
    BoundedNettyByteBufReceive set = new BoundedNettyByteBufReceive(100);
    // The max request size is 100, but the buffer size is 2000, will result in IOException
    try {
      set.readFrom(Channels.newChannel(new ByteBufferInputStream(buffer)));
      Assert.fail("Should fail with IOException");
    } catch (IOException e) {
    }
    buffer.clear();
  }
Test when the request size is bigger than the maximum size
@throws Exception
ambry-network/src/test/java/com/github/ambry/network/BoundedNettyByteBufReceiveTest.java