Bug fix: ByteArrayBuilder incorrectly handles empty strings
This commit is contained in:
parent
75e8dc6f9b
commit
235900eb57
|
@ -74,8 +74,8 @@ public final class ByteArrayBuilder {
|
|||
|
||||
final int capacity = (int) (in.remaining() * encoder.averageBytesPerChar());
|
||||
ByteBuffer out = ensureFreeCapacity(buffer, capacity);
|
||||
for (;;) {
|
||||
CoderResult result = in.hasRemaining() ? encoder.encode(in, out, true) : CoderResult.UNDERFLOW;
|
||||
while (in.hasRemaining()) {
|
||||
CoderResult result = encoder.encode(in, out, true);
|
||||
if (result.isError()) {
|
||||
result.throwException();
|
||||
}
|
||||
|
|
|
@ -96,6 +96,7 @@ public class TestByteArrayBuilder {
|
|||
buffer.append("bcd");
|
||||
buffer.append("e");
|
||||
buffer.append("f");
|
||||
buffer.append("");
|
||||
buffer.append((String) null);
|
||||
buffer.append((char[]) null);
|
||||
|
||||
|
|
Loading…
Reference in New Issue