Merge branch '5.1.x'
This commit is contained in:
@@ -264,13 +264,13 @@ public interface DataBuffer {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (cr.isOverflow()) {
|
if (cr.isOverflow()) {
|
||||||
writePosition(outBuffer.position());
|
writePosition(writePosition() + outBuffer.position());
|
||||||
int maximumSize = (int) (inBuffer.remaining() * charsetEncoder.maxBytesPerChar());
|
int maximumSize = (int) (inBuffer.remaining() * charsetEncoder.maxBytesPerChar());
|
||||||
ensureCapacity(maximumSize);
|
ensureCapacity(maximumSize);
|
||||||
outBuffer = asByteBuffer(writePosition(), writableByteCount());
|
outBuffer = asByteBuffer(writePosition(), writableByteCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writePosition(outBuffer.position());
|
writePosition(writePosition() + outBuffer.position());
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,6 +225,27 @@ public class DataBufferTests extends AbstractDataBufferAllocatingTestCase {
|
|||||||
release(buffer);
|
release(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void writeMultipleUtf8String() {
|
||||||
|
|
||||||
|
DataBuffer buffer = createDataBuffer(1);
|
||||||
|
buffer.write("abc", StandardCharsets.UTF_8);
|
||||||
|
assertEquals(3, buffer.readableByteCount());
|
||||||
|
|
||||||
|
buffer.write("def", StandardCharsets.UTF_8);
|
||||||
|
assertEquals(6, buffer.readableByteCount());
|
||||||
|
|
||||||
|
buffer.write("ghi", StandardCharsets.UTF_8);
|
||||||
|
assertEquals(9, buffer.readableByteCount());
|
||||||
|
|
||||||
|
byte[] result = new byte[9];
|
||||||
|
buffer.read(result);
|
||||||
|
|
||||||
|
assertArrayEquals("abcdefghi".getBytes(), result);
|
||||||
|
|
||||||
|
release(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void inputStream() throws IOException {
|
public void inputStream() throws IOException {
|
||||||
DataBuffer buffer = createDataBuffer(4);
|
DataBuffer buffer = createDataBuffer(4);
|
||||||
|
|||||||
Reference in New Issue
Block a user