From 2bb3fdfa8b42490af1b2ca2b8a489c423d5c8752 Mon Sep 17 00:00:00 2001 From: Peter-Josef Meisch Date: Sun, 15 Dec 2019 15:53:52 +0100 Subject: [PATCH] DATAES-314 - NodeClientFactoryBean doesn't shutdown ES on destroy life-cycle. Original PR: #360 --- .../elasticsearch/client/NodeClientFactoryBean.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/springframework/data/elasticsearch/client/NodeClientFactoryBean.java b/src/main/java/org/springframework/data/elasticsearch/client/NodeClientFactoryBean.java index ef6e463d6..465d60e8e 100644 --- a/src/main/java/org/springframework/data/elasticsearch/client/NodeClientFactoryBean.java +++ b/src/main/java/org/springframework/data/elasticsearch/client/NodeClientFactoryBean.java @@ -57,7 +57,7 @@ public class NodeClientFactoryBean implements FactoryBean, InitializingB public static class TestNode extends Node { - private static final String DEFAULT_NODE_NAME = "spring-data-elasticsearch-test-node"; + private static final String DEFAULT_NODE_NAME = "spring-data-elasticsearch-nodeclientfactorybean-test"; public TestNode(Settings preparedSettings, Collection> classpathPlugins) { @@ -151,13 +151,12 @@ public class NodeClientFactoryBean implements FactoryBean, InitializingB public void destroy() throws Exception { try { // NodeClient.close() is a noop, no need to call it here + nodeClient = null; logger.info("Closing elasticSearch node"); - // closing the Node causes tests to fail in the pipeline build and on some - // "mvn test" runs, there seem still to be tests relying on a running instance that - // is not properly set up. -// if (node != null) { -// node.close(); -// } + if (node != null) { + node.close(); + node = null; + } } catch (final Exception e) { logger.error("Error closing ElasticSearch client: ", e); }