From 42e1caf2bfe6385cc1dc55ec97c449330da74b71 Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Mon, 11 Jul 2016 07:35:10 +0530 Subject: [PATCH] SOLR-9291: ZkSolrResourceLoader should not retry fetching resources if the server has been shutdown --- solr/CHANGES.txt | 3 +++ .../apache/solr/cloud/ZkSolrResourceLoader.java | 16 +++++++++------- .../solr/handler/TestSolrConfigHandlerCloud.java | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 8b67d5a4170..45488fca19a 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -141,6 +141,9 @@ Bug Fixes * SOLR-9236: AutoAddReplicas will append an extra /tlog to the update log location on replica failover. (Eungsop Yoo, Mark Miller) +* SOLR-9291: ZkSolrResourceLoader should not retry fetching resources if the server has been shutdown. + (shalin) + Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkSolrResourceLoader.java b/solr/core/src/java/org/apache/solr/cloud/ZkSolrResourceLoader.java index 2b60e53ea70..209ca68c566 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkSolrResourceLoader.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkSolrResourceLoader.java @@ -96,13 +96,15 @@ public class ZkSolrResourceLoader extends SolrResourceLoader { } } catch (KeeperException.SessionExpiredException e) { exception = e; - // Retry in case of session expiry - try { - Thread.sleep(1000); - log.debug("Sleeping for 1s before retrying fetching resource=" + resource); - } catch (InterruptedException ie) { - Thread.currentThread().interrupt(); - throw new IOException("Could not load resource=" + resource, ie); + if (!zkController.getCoreContainer().isShutDown()) { + // Retry in case of session expiry + try { + Thread.sleep(1000); + log.debug("Sleeping for 1s before retrying fetching resource=" + resource); + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); + throw new IOException("Could not load resource=" + resource, ie); + } } } catch (InterruptedException e) { Thread.currentThread().interrupt(); diff --git a/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java b/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java index ab2f467fe8a..0dbbe401af5 100644 --- a/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java +++ b/solr/core/src/test/org/apache/solr/handler/TestSolrConfigHandlerCloud.java @@ -48,7 +48,7 @@ public class TestSolrConfigHandlerCloud extends AbstractFullDistribZkTestBase { private void setupHarnesses() { for (final SolrClient client : clients) { - RestTestHarness harness = new RestTestHarness(() -> ((HttpSolrClient)client).getBaseURL()); + RestTestHarness harness = new RestTestHarness(((HttpSolrClient) client)::getBaseURL); restTestHarnesses.add(harness); } }