@Test
  public void testByteArrayInputStream() throws Exception {
    byte[] bytes = new byte[8];
    InputStream input = new ByteArrayInputStream(bytes);
    try {
      byte[] bytesRead = StreamUtil.getBytesFromStream(input);
      assertTrue(Arrays.equals(bytes, bytesRead));
    } finally {
      Closeables.close(input, true);
    }
  }
Verify that using a ByteArrayInputStream does not allocate a new byte array.
fbcore/src/test/java/com/facebook/common/util/StreamUtilTest.java