diff --git a/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index 2b47908c352..1e53faa9efc 100644 --- a/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -163,16 +163,6 @@ final class Bootstrap { try { spawner.spawnNativePluginControllers(environment); - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - try { - spawner.close(); - } catch (IOException e) { - throw new ElasticsearchException("Failed to destroy spawned controllers", e); - } - } - }); } catch (IOException e) { throw new BootstrapException(e); } @@ -191,7 +181,7 @@ final class Bootstrap { @Override public void run() { try { - IOUtils.close(node); + IOUtils.close(node, spawner); LoggerContext context = (LoggerContext) LogManager.getContext(false); Configurator.shutdown(context); } catch (IOException ex) { @@ -269,7 +259,7 @@ final class Bootstrap { static void stop() throws IOException { try { - IOUtils.close(INSTANCE.node); + IOUtils.close(INSTANCE.node, INSTANCE.spawner); } finally { INSTANCE.keepAliveLatch.countDown(); }