> I don't think this is necessary. A 0 is also a valid data, so I see no
> difference between a buffer not being zero'ed and a buffer containing only
> 0.

I would agree with you if we are not talking about C instead of java.
Most of the initialised data in java is set to specified
(well-defined) default values. For example instance variables are set
to 0 or null, arrays are initialized to the default value of the
declaring type. If an uninitialised local variable is used the
compiler gives throws an error. Even the DirectBuffer class of
java.nio explicitly clears its data to 0 in the constructor. For this
reasons I would assume that most java developers are used to having
implicitly initialized data.

IMO there is no advantage in receiving an uninitialised buffer. It
doesn't make sense to reuse a buffer with existing data. This implies
that the client must always  always reinitialise the buffer which
seems pointless as the buffer could be a new instance or the used
allocator is not the PooledByteBufferAllocator. Due to this I feel it
would make more sense to assign the responsibility of clearing the
buffer to the PooledByteBufferAllocator. This would guarantee the
state of the buffer for the client independent of the allocator.

Reply via email to