Move OOM try-catch

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2021-10-25 10:08:25 +02:00
parent afdc67fc26
commit 1851ea7eca

View File

@ -276,7 +276,13 @@ public class PlayerSocketConnection extends PlayerConnection {
public void flush() {
try {
synchronized (bufferLock) {
updateLocalBuffer();
try {
updateLocalBuffer();
} catch (OutOfMemoryError e) {
this.waitingBuffers.clear();
System.gc(); // Explicit gc forcing buffers to be collected
throw new ClosedChannelException();
}
}
synchronized (flushLock) {
try {
@ -291,10 +297,6 @@ public class PlayerSocketConnection extends PlayerConnection {
} catch (IOException e) { // Couldn't write to the socket
MinecraftServer.getExceptionManager().handleException(e);
throw new ClosedChannelException();
} catch (OutOfMemoryError e) { // Couldn't allocate a pooled buffer
this.waitingBuffers.clear();
System.gc(); // Explicit gc forcing buffers to be collected
throw new ClosedChannelException();
}
}
} catch (ClosedChannelException e) {