You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by kr...@apache.org on 2022/05/06 16:54:57 UTC
[solr] branch branch_9x updated: SOLR-16185: CloudSolrClientCacheTest leaks threads (#839)
This is an automated email from the ASF dual-hosted git repository.
krisden pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 92de6b371d2 SOLR-16185: CloudSolrClientCacheTest leaks threads (#839)
92de6b371d2 is described below
commit 92de6b371d2e1e3b593b33854b6cd1c3c6b8406b
Author: Kevin Risden <ri...@users.noreply.github.com>
AuthorDate: Fri May 6 12:51:25 2022 -0400
SOLR-16185: CloudSolrClientCacheTest leaks threads (#839)
---
.../solr/client/solrj/impl/CloudSolrClient.java | 5 +++--
.../client/solrj/impl/CloudSolrClientCacheTest.java | 21 ++++++++++++++-------
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
index a1f0222709b..7794818e89c 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
@@ -99,7 +99,7 @@ public abstract class CloudSolrClient extends SolrClient {
// no of times collection state to be reloaded if stale state error is received
private static final int MAX_STALE_RETRIES =
Integer.parseInt(System.getProperty("cloudSolrClientMaxStaleRetries", "5"));
- private Random rand = new Random();
+ private final Random rand = new Random();
private final boolean updatesToLeaders;
private final boolean directUpdatesToLeadersOnly;
@@ -304,7 +304,8 @@ public abstract class CloudSolrClient extends SolrClient {
@Override
public void close() throws IOException {
if (this.threadPool != null && !this.threadPool.isShutdown()) {
- this.threadPool.shutdown();
+ ExecutorUtil.shutdownAndAwaitTermination(this.threadPool);
+ this.threadPool = null;
}
}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
index 4c9bebf369f..35c404d33a3 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
@@ -78,10 +78,11 @@ public class CloudSolrClientCacheTest extends SolrTestCaseJ4 {
LBHttpSolrClient mockLbclient = getMockLbHttpSolrClient(responses);
AtomicInteger lbhttpRequestCount = new AtomicInteger();
- try (CloudSolrClient cloudClient =
- new CloudSolrClientBuilder(getStateProvider(livenodes, refs))
- .withLBHttpSolrClient(mockLbclient)
- .build()) {
+ try (ClusterStateProvider clusterStateProvider = getStateProvider(livenodes, refs);
+ CloudSolrClient cloudClient =
+ new CloudSolrClientBuilder(clusterStateProvider)
+ .withLBHttpSolrClient(mockLbclient)
+ .build()) {
livenodes.addAll(ImmutableSet.of("192.168.1.108:7574_solr", "192.168.1.108:8983_solr"));
ClusterState cs =
ClusterState.createFromJson(1, coll1State.getBytes(UTF_8), Collections.emptySet());
@@ -91,9 +92,15 @@ public class CloudSolrClientCacheTest extends SolrTestCaseJ4 {
"request",
o -> {
int i = lbhttpRequestCount.incrementAndGet();
- if (i == 1) return new ConnectException("TEST");
- if (i == 2) return new SocketException("TEST");
- if (i == 3) return new NoHttpResponseException("TEST");
+ if (i == 1) {
+ return new ConnectException("TEST");
+ }
+ if (i == 2) {
+ return new SocketException("TEST");
+ }
+ if (i == 3) {
+ return new NoHttpResponseException("TEST");
+ }
return okResponse;
});
UpdateRequest update = new UpdateRequest().add("id", "123", "desc", "Something 0");