ByteBufHttpData implements HttpData, ResourceLeakHint { @Override public void close() { if ((flags & (FLAG_POOLED | FLAG_CLOSED)) == FLAG_POOLED) { flags |= FLAG_CLOSED; buf.release(); } } ByteBufHttpData(ByteBuf buf, boolean pooled); private  ByteBufHttpData(ByteBuf buf, int flags, @Nullable byte[] array); @Override byte[] array(); @Override int length(); @Override String toString(Charset charset); @Override String toString(); @Override String toHintString(); @Override InputStream toInputStream(); @Override boolean isEndOfStream(); @Override ByteBufHttpData withEndOfStream(boolean endOfStream); @Override boolean isPooled(); @Override ByteBuf byteBuf(ByteBufAccessMode mode); @Override ByteBuf byteBuf(int offset, int length, ByteBufAccessMode mode); @Override void touch(@Nullable Object hint); @Override void close(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test void doubleFree() { final ByteBuf buf = Unpooled.directBuffer(4).writeInt(0x01020304).retain(); final ByteBufHttpData data = new ByteBufHttpData(buf, true); for (int i = 0; i < 2; i++) { data.close(); assertThat(buf.refCnt()).isOne(); } buf.release(); }