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 // Decompress to content buffer
content = workerContext.contentBuffer.clear(); content = workerContext.contentBuffer.clear();
decompressedSize = dataLength; decompressedSize = dataLength;
try { Inflater inflater = workerContext.inflater;
Inflater inflater = workerContext.inflater; inflater.setInput(readBuffer.asByteBuffer(readBuffer.readerOffset(), payloadLength));
inflater.setInput(readBuffer.asByteBuffer(readBuffer.readerOffset(), payloadLength)); inflater.inflate(content.asByteBuffer(0, dataLength));
inflater.inflate(content.asByteBuffer(0, dataLength)); inflater.reset();
inflater.reset();
} catch (DataFormatException e) {
MinecraftServer.getExceptionManager().handleException(e);
}
} }
} }
// Process packet // Process packet
@ -156,6 +152,10 @@ public class PlayerSocketConnection extends PlayerConnection {
readBuffer.reset(beginMark); readBuffer.reset(beginMark);
this.cacheBuffer = BinaryBuffer.copy(readBuffer); this.cacheBuffer = BinaryBuffer.copy(readBuffer);
break; 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) { } catch (IOException e) {
// TODO print exception? (should ignore disconnection) // TODO print exception? (should ignore disconnection)
connection.disconnect(); connection.disconnect();
} catch (IllegalArgumentException e) {
MinecraftServer.getExceptionManager().handleException(e);
connection.disconnect();
} }
}); });
} catch (IOException e) { } catch (Exception e) {
MinecraftServer.getExceptionManager().handleException(e); MinecraftServer.getExceptionManager().handleException(e);
} }
} }