Returned byte buffers through ByteBufferIterator from DefaultDataBuffer are misconfigured #30966
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: duplicate
A duplicate of another issue
type: bug
A general bug
Affects: 6.0.11
The DefaultDataBuffer class has follow implementations of the methods readableByteBuffers and writableByteBuffers of DataBuffer interface:
The
limit
onreadOnly
inreadableByteBuffers
should be set tothis.writePosition
, because if the condition(this.writePosition - this.readPosition) <= this.readPosition
is satisfied, thelimit
of the returned byte buffer will be equal to itsposition
, so the byte buffer will be returned, which no single byte could be read from. In this case theposition
can be set to a lower index thanthis.readPosition
, which can lead that some buffer data will be read again, afterlimit
increased.The limit on
duplicate
inwritableByteBuffers
should be set tothis.capacity
, because if the condition(this.capacity - this.writePosition) <= this.writePosition
is satisfied, thelimit
of the returned byte buffer will be equal to itsposition
, so the byte buffer will be returned, which no single byte could be written into. In this case theposition
can be set to a lower index thanthis.writePosition
, which can lead, that some buffer data will be overwritten, afterlimit
increased.So how it should be:
The text was updated successfully, but these errors were encountered: