Shutdown the server on OOM

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2021-09-21 10:44:36 +02:00
parent e43d001076
commit 5a4fc95ffd

View File

@ -1,5 +1,6 @@
package net.minestom.server.exception;
import net.minestom.server.MinecraftServer;
import org.jetbrains.annotations.Nullable;
/**
@ -15,7 +16,12 @@ public final class ExceptionManager {
* @param e the occurred exception
*/
public void handleException(Throwable e) {
// TODO handle OOM exceptions
if (e instanceof OutOfMemoryError) {
// OOM should be handled manually
e.printStackTrace();
MinecraftServer.stopCleanly();
return;
}
this.getExceptionHandler().handleException(e);
}