Hi,

It appears that with *openjdk-11.0.3* the *Unpooled.buffer()* may
return a *ByteBuf
*with a backing array elements initialized to non zero values.

In Oracle JDK 8 however, the elements of the backing array are initialized
to zero.

Using *netty-4.1.41.Final*.

Appreciate if this can be explained.

Is there an API to get a ByteBuf with backing array elements initialized to
zero ?.

@Test(invocationCount = 10000)
public void testInitialization() {
    final int SIZE = 10000;
    ByteBuf byteBuf = Unpooled.buffer(SIZE);

    int arrayLength = byteBuf.array().length;
    for (int arrayIndex = 0; arrayIndex < arrayLength; arrayIndex++) {
        Assert.assertEquals(byteBuf.array()[arrayIndex], 0);
    }
}


[image: image.png]

-- 
You received this message because you are subscribed to the Google Groups 
"Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/netty/CAJt14FPetrEz%2BWHcOXjtjFR0HeTGK3s7i8Pk3kREMGRrim2MJg%40mail.gmail.com.

Reply via email to