@Test
  public void refCountsAfterCloseTest() throws Exception {
    NettyMultipartRequest requestCloseBeforePrepare = createRequest(null, null);
    NettyMultipartRequest requestCloseAfterPrepare = createRequest(null, null);
    List<HttpContent> httpContents = new ArrayList<HttpContent>(5);
    for (int i = 0; i < 5; i++) {
      HttpContent httpContent = new DefaultHttpContent(Unpooled.wrappedBuffer(TestUtils.getRandomBytes(10)));
      requestCloseBeforePrepare.addContent(httpContent);
      requestCloseAfterPrepare.addContent(httpContent);
      assertEquals("Reference count is not as expected", 3, httpContent.refCnt());
      httpContents.add(httpContent);
    }
    closeRequestAndValidate(requestCloseBeforePrepare);
    requestCloseAfterPrepare.prepare();
    closeRequestAndValidate(requestCloseAfterPrepare);
    for (HttpContent httpContent : httpContents) {
      assertEquals("Reference count is not as expected", 1, httpContent.refCnt());
    }
  }
Tests that reference counts are correct when a {@link NettyMultipartRequest} is closed without being read.
@throws Exception
ambry-rest/src/test/java/com/github/ambry/rest/NettyMultipartRequestTest.java