Fix buffer not being emptied

This commit is contained in:
TheMode 2021-08-09 02:05:51 +02:00
parent 1b708bc851
commit 5b8b9cab57

View File

@ -124,12 +124,15 @@ public final class BinaryBuffer {
} }
public void writeChannel(WritableByteChannel channel) throws IOException { public void writeChannel(WritableByteChannel channel) throws IOException {
final int count = channel.write(asByteBuffer(readerOffset, writerOffset)); var writeBuffer = asByteBuffer(readerOffset, writerOffset);
if (count == -1) { while (writeBuffer.position() != writeBuffer.limit()) {
// EOS final int count = channel.write(writeBuffer);
throw new IOException("Disconnected"); if (count == -1) {
// EOS
throw new IOException("Disconnected");
}
this.readerOffset += count;
} }
this.readerOffset += count;
} }
public void readChannel(ReadableByteChannel channel) throws IOException { public void readChannel(ReadableByteChannel channel) throws IOException {