From ac87751b3d41e14ecac61cd9bcbb1eddaef8d6d9 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Fri, 29 Jan 2016 16:26:37 +0100 Subject: [PATCH] Use IOUtils#close() where needed --- .../java/org/elasticsearch/bootstrap/Bootstrap.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index 188fd4ae113..5aa760dc9f6 100644 --- a/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -20,6 +20,7 @@ package org.elasticsearch.bootstrap; import org.apache.lucene.util.Constants; +import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.StringHelper; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; @@ -159,12 +160,10 @@ final class Bootstrap { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { - if (node != null) { - try { - node.close(); - } catch (IOException ex) { - throw new ElasticsearchException("failed to stop node", ex); - } + try { + IOUtils.close(node); + } catch (IOException ex) { + throw new ElasticsearchException("failed to stop node", ex); } } }); @@ -233,7 +232,7 @@ final class Bootstrap { static void stop() throws IOException { try { - INSTANCE.node.close(); + IOUtils.close(INSTANCE.node); } finally { INSTANCE.keepAliveLatch.countDown(); }