ByteArrayHttpData implements HttpData { @Override public int hashCode() { final int end = Math.min(32, length()); int hash = 0; for (int i = 0; i < end; i++) { hash = hash * 31 + array[i]; } return hash; } ByteArrayHttpData(byte[] array); private  ByteArrayHttpData(byte[] array, boolean endOfStream); @Override byte[] array(); @Override int length(); @Override String toString(Charset charset); @Override String toString(); @Override InputStream toInputStream(); @Override boolean isEndOfStream(); @Override ByteArrayHttpData withEndOfStream(boolean endOfStream); @Override boolean isPooled(); @Override ByteBuf byteBuf(ByteBufAccessMode mode); @Override ByteBuf byteBuf(int offset, int length, ByteBufAccessMode mode); @Override void close(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test void hash() { final ByteArrayHttpData data = new ByteArrayHttpData(new byte[] { 2, 3, 4, 5 }); assertThat(data.hashCode()).isEqualTo(((2 * 31 + 3) * 31 + 4) * 31 + 5); final byte[] bigArray = new byte[33]; bigArray[32] = 1; final ByteArrayHttpData bigData = new ByteArrayHttpData(bigArray); assertThat(bigData.hashCode()).isZero(); }