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/10 02:14:46 UTC

[GitHub] [solr] risdenk commented on a diff in pull request #848: SOLR-16190: Http2SolrClient should make sure to shutdown the executor

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


##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -250,16 +250,18 @@ private HttpClient createHttpClient(Builder builder) {
   public void close() {
     // we wait for async requests, so far devs don't want to give sugar for this
     asyncTracker.waitForComplete();
-    if (closeClient) {
-      try {
+    try {
+      if (closeClient) {
         httpClient.setStopTimeout(1000);
         httpClient.stop();
-      } catch (Exception e) {
-        throw new RuntimeException("Exception on closing client", e);
+        httpClient.destroy();

Review Comment:
   I have no idea if `destroy()` is needed, but I was surprised it existed. When I stepped through with the debugger, `destroy` cleaned up more resources which seems to be a good idea on `close()`...



##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -250,16 +250,18 @@ private HttpClient createHttpClient(Builder builder) {
   public void close() {
     // we wait for async requests, so far devs don't want to give sugar for this
     asyncTracker.waitForComplete();
-    if (closeClient) {
-      try {
+    try {
+      if (closeClient) {
         httpClient.setStopTimeout(1000);
         httpClient.stop();
-      } catch (Exception e) {
-        throw new RuntimeException("Exception on closing client", e);
+        httpClient.destroy();
+      }
+    } catch (Exception e) {
+      throw new RuntimeException("Exception on closing client", e);
+    } finally {
+      if (shutdownExecutor) {
+        ExecutorUtil.shutdownNowAndAwaitTermination(executor);
       }

Review Comment:
   Make sure we shutdown the executor even if the close client fails. We want to interrupt the threads since the client is already closed so no need to keep any threads executing.



-- 
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