private byte[] getByteArrayFromByteBuffer(ByteBuffer buffer) throws Exception {
    assertFalse(buffer.isDirect());
    if (buffer.hasArray()) {
      return buffer.array();
    }
    Field arrayField = ByteBuffer.class.getDeclaredField("hb");
    arrayField.setAccessible(true);
    return (byte[]) arrayField.get(buffer);
  }
Return the internal byte array of the given {@link ByteBuffer}. It only works when the {@link ByteBuffer} is not
a direct {@link ByteBuffer}.
@param buffer The {@link ByteBuffer}.
@return The internal byte array.
@throws Exception Any unexpected error.
ambry-utils/src/test/java/com/github/ambry/utils/UtilsTest.java