Add more try-catch to prevent the worker from returning

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2021-10-06 18:47:40 +02:00
parent d89e5cf2ee
commit 2f1e4101d1
2 changed files with 12 additions and 9 deletions

View File

@ -125,14 +125,10 @@ public class PlayerSocketConnection extends PlayerConnection {
// Decompress to content buffer
content = workerContext.contentBuffer.clear();
decompressedSize = dataLength;
try {
Inflater inflater = workerContext.inflater;
inflater.setInput(readBuffer.asByteBuffer(readBuffer.readerOffset(), payloadLength));
inflater.inflate(content.asByteBuffer(0, dataLength));
inflater.reset();
} catch (DataFormatException e) {
MinecraftServer.getExceptionManager().handleException(e);
}
Inflater inflater = workerContext.inflater;
inflater.setInput(readBuffer.asByteBuffer(readBuffer.readerOffset(), payloadLength));
inflater.inflate(content.asByteBuffer(0, dataLength));
inflater.reset();
}
}
// Process packet
@ -156,6 +152,10 @@ public class PlayerSocketConnection extends PlayerConnection {
readBuffer.reset(beginMark);
this.cacheBuffer = BinaryBuffer.copy(readBuffer);
break;
} catch (DataFormatException e) {
MinecraftServer.getExceptionManager().handleException(e);
disconnect();
return;
}
}
}

View File

@ -53,9 +53,12 @@ public final class Worker extends Thread {
} catch (IOException e) {
// TODO print exception? (should ignore disconnection)
connection.disconnect();
} catch (IllegalArgumentException e) {
MinecraftServer.getExceptionManager().handleException(e);
connection.disconnect();
}
});
} catch (IOException e) {
} catch (Exception e) {
MinecraftServer.getExceptionManager().handleException(e);
}
}