diff --git a/core/src/main/java/org/elasticsearch/bootstrap/ElasticsearchUncaughtExceptionHandler.java b/core/src/main/java/org/elasticsearch/bootstrap/ElasticsearchUncaughtExceptionHandler.java index 405e919fabd49..45d54ed4a6211 100644 --- a/core/src/main/java/org/elasticsearch/bootstrap/ElasticsearchUncaughtExceptionHandler.java +++ b/core/src/main/java/org/elasticsearch/bootstrap/ElasticsearchUncaughtExceptionHandler.java @@ -25,6 +25,8 @@ import org.elasticsearch.common.logging.Loggers; import java.io.IOError; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Objects; import java.util.function.Supplier; @@ -85,10 +87,16 @@ void onNonFatalUncaught(final String threadName, final Throwable t) { } // visible for testing - @SuppressForbidden(reason = "halt") void halt(int status) { - // we halt to prevent shutdown hooks from running - Runtime.getRuntime().halt(status); + AccessController.doPrivileged(new PrivilegedAction() { + @SuppressForbidden(reason = "halt") + @Override + public Void run() { + // we halt to prevent shutdown hooks from running + Runtime.getRuntime().halt(status); + return null; + } + }); } }