Do not flush if channel is closed

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2021-11-08 09:11:02 +01:00
parent 87819ba806
commit ae08ac2987

View File

@ -235,7 +235,7 @@ public class PlayerSocketConnection extends PlayerConnection {
if (encrypted) { // Encryption support
ByteBuffer output = PacketUtils.localBuffer();
try {
this.encryptCipher.update(buffer.slice(index,length), output);
this.encryptCipher.update(buffer.slice(index, length), output);
buffer = output.flip();
index = 0;
} catch (ShortBufferException e) {
@ -280,6 +280,8 @@ public class PlayerSocketConnection extends PlayerConnection {
@Override
public void flush() {
try {
if (!channel.isConnected())
throw new ClosedChannelException();
synchronized (bufferLock) {
try {
updateLocalBuffer();