mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 00:17:58 +01:00
Fix buffer not being emptied
This commit is contained in:
parent
1b708bc851
commit
5b8b9cab57
@ -124,12 +124,15 @@ public final class BinaryBuffer {
|
||||
}
|
||||
|
||||
public void writeChannel(WritableByteChannel channel) throws IOException {
|
||||
final int count = channel.write(asByteBuffer(readerOffset, writerOffset));
|
||||
if (count == -1) {
|
||||
// EOS
|
||||
throw new IOException("Disconnected");
|
||||
var writeBuffer = asByteBuffer(readerOffset, writerOffset);
|
||||
while (writeBuffer.position() != writeBuffer.limit()) {
|
||||
final int count = channel.write(writeBuffer);
|
||||
if (count == -1) {
|
||||
// EOS
|
||||
throw new IOException("Disconnected");
|
||||
}
|
||||
this.readerOffset += count;
|
||||
}
|
||||
this.readerOffset += count;
|
||||
}
|
||||
|
||||
public void readChannel(ReadableByteChannel channel) throws IOException {
|
||||
|
Loading…
Reference in New Issue
Block a user