Use IOUtils#close() where needed

This commit is contained in:
Simon Willnauer 2016-01-29 16:26:37 +01:00
parent 87737d3e02
commit ac87751b3d
1 changed files with 6 additions and 7 deletions

View File

@ -20,6 +20,7 @@
package org.elasticsearch.bootstrap; package org.elasticsearch.bootstrap;
import org.apache.lucene.util.Constants; import org.apache.lucene.util.Constants;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.StringHelper; import org.apache.lucene.util.StringHelper;
import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version; import org.elasticsearch.Version;
@ -159,14 +160,12 @@ final class Bootstrap {
Runtime.getRuntime().addShutdownHook(new Thread() { Runtime.getRuntime().addShutdownHook(new Thread() {
@Override @Override
public void run() { public void run() {
if (node != null) {
try { try {
node.close(); IOUtils.close(node);
} catch (IOException ex) { } catch (IOException ex) {
throw new ElasticsearchException("failed to stop node", ex); throw new ElasticsearchException("failed to stop node", ex);
} }
} }
}
}); });
} }
@ -233,7 +232,7 @@ final class Bootstrap {
static void stop() throws IOException { static void stop() throws IOException {
try { try {
INSTANCE.node.close(); IOUtils.close(INSTANCE.node);
} finally { } finally {
INSTANCE.keepAliveLatch.countDown(); INSTANCE.keepAliveLatch.countDown();
} }