You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/05/05 18:52:00 UTC

[GitHub] [solr] risdenk commented on a diff in pull request #839: SOLR-16185: CloudSolrClientCacheTest leaks threads

risdenk commented on code in PR #839:
URL: https://github.com/apache/solr/pull/839#discussion_r866215719


##########
solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java:
##########
@@ -78,28 +78,30 @@ public DocCollection get() {
 
     LBHttpSolrClient mockLbclient = getMockLbHttpSolrClient(responses);
     AtomicInteger lbhttpRequestCount = new AtomicInteger();
-    try (CloudSolrClient cloudClient =
-        new CloudSolrClientBuilder(getStateProvider(livenodes, refs))
-            .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());
-      refs.put(collName, new Ref(collName));
-      colls.put(collName, cs.getCollectionOrNull(collName));
-      responses.put(
-          "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");
-            return okResponse;
-          });
-      UpdateRequest update = new UpdateRequest().add("id", "123", "desc", "Something 0");
-
-      cloudClient.request(update, collName);
-      assertEquals(2, refs.get(collName).getCount());
+    try (ClusterStateProvider clusterStateProvider = getStateProvider(livenodes, refs)) {

Review Comment:
   Since this is actually just a mock this isn't 100% necessary, but if it was real would need to close it.



##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java:
##########
@@ -304,7 +304,8 @@ public ClusterState getClusterState() {
   @Override
   public void close() throws IOException {
     if (this.threadPool != null && !this.threadPool.isShutdown()) {
-      this.threadPool.shutdown();
+      ExecutorUtil.shutdownAndAwaitTermination(this.threadPool);
+      this.threadPool = null;

Review Comment:
   As far as I can tell the test ended quickly and the thread pool still hadn't terminated the threads yet. This will ensure this waits until the threadpool is actually shutdown.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org