Fix repeated calls to DataBuffer.write(CharSequence, Charset)
Prior to this commit, repeated calls to `DataBuffer.write(CharSequence, Charset)` would not write the given chars to the expected position in the original buffer. This commit fixes that by writing to the `outBuffer.position()`, offset by the current `DataBuffer.writePosition()`. Fixes gh-22484
This commit is contained in:
committed by
Brian Clozel
parent
2137cc4422
commit
090aceb3ad
@@ -264,13 +264,13 @@ public interface DataBuffer {
|
||||
break;
|
||||
}
|
||||
if (cr.isOverflow()) {
|
||||
writePosition(outBuffer.position());
|
||||
writePosition(writePosition() + outBuffer.position());
|
||||
int maximumSize = (int) (inBuffer.remaining() * charsetEncoder.maxBytesPerChar());
|
||||
ensureCapacity(maximumSize);
|
||||
outBuffer = asByteBuffer(writePosition(), writableByteCount());
|
||||
}
|
||||
}
|
||||
writePosition(outBuffer.position());
|
||||
writePosition(writePosition() + outBuffer.position());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user