You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/07/12 01:02:09 UTC
[lucene-solr] branch reference_impl updated: #81 Close root zk
client async.
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/reference_impl by this push:
new 906673e #81 Close root zk client async.
906673e is described below
commit 906673e69af9e0d4c639f15fbac24ba6e55a086e
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Sat Jul 11 20:01:55 2020 -0500
#81 Close root zk client async.
---
.../java/org/apache/solr/servlet/SolrDispatchFilter.java | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
index 058ce10..ca86a19 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
@@ -63,10 +63,12 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHeaders;
import org.apache.lucene.util.Version;
import org.apache.solr.api.V2HttpCall;
+import org.apache.solr.common.ParWork;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.util.ExecutorUtil;
+import org.apache.solr.common.util.IOUtils;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.NodeConfig;
import org.apache.solr.core.SolrCore;
@@ -295,19 +297,20 @@ public class SolrDispatchFilter extends BaseSolrFilter {
String zkHost = System.getProperty("zkHost");
if (!StringUtils.isEmpty(zkHost)) {
int startUpZkTimeOut = Integer.getInteger("waitForZk", 10);
- try (SolrZkClient zkClient = new SolrZkClient(zkHost, (int) TimeUnit.SECONDS.toMillis(startUpZkTimeOut))) {
+ SolrZkClient zkClient = new SolrZkClient(zkHost, (int) TimeUnit.SECONDS.toMillis(startUpZkTimeOut));
+ try {
log.info("Trying solr.xml in ZooKeeper...");
- try {
+
byte[] data = zkClient.getData("/solr.xml", null, null, true);
return SolrXmlConfig.fromInputStream(solrHome, new ByteArrayInputStream(data), nodeProperties, true);
} catch (KeeperException.NoNodeException e) {
// okay
- }
-
- } catch (Exception e) {
+ } catch (Exception e) {
SolrZkClient.checkInterrupted(e);
throw new SolrException(ErrorCode.SERVER_ERROR, "Error occurred while loading solr.xml from zookeeper", e);
+ } finally {
+ ParWork.getExecutor().submit(() -> IOUtils.closeQuietly(zkClient));
}
log.info("Loading solr.xml from SolrHome (not found in ZooKeeper)");
}