This is an automated email from the ASF dual-hosted git repository. krisden pushed a commit to branch branch_9_0 in repository https://gitbox.apache.org/repos/asf/solr.git
commit 319a569c5246c240459283ab741a66a23ca94380 Author: Kevin Risden <[email protected]> AuthorDate: Wed May 18 08:50:39 2022 -0400 SOLR-16190: Http2SolrClient should make sure to shutdown the executor (#848) --- solr/CHANGES.txt | 2 ++ .../solr/client/solrj/impl/Http2SolrClient.java | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index f4417863ba9..d5284d83df1 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -16,6 +16,8 @@ Bug Fixes * SOLR-16399: ExportWriter fails with max values for fields (Kevin Risden) +* SOLR-16190: Http2SolrClient should make sure to shutdown the executor (Kevin Risden) + ================== 9.0.0 ================== New Features diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java index a12d03c41f7..a10d578a6a3 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java @@ -187,9 +187,9 @@ public class Http2SolrClient extends SolrClient { private HttpClient createHttpClient(Builder builder) { HttpClient httpClient; - BlockingArrayQueue<Runnable> queue = new BlockingArrayQueue<>(256, 256); executor = builder.executor; if (executor == null) { + BlockingArrayQueue<Runnable> queue = new BlockingArrayQueue<>(256, 256); this.executor = new ExecutorUtil.MDCAwareThreadPoolExecutor( 32, 256, 60, TimeUnit.SECONDS, queue, new SolrNamedThreadFactory("h2sc")); @@ -241,6 +241,7 @@ public class Http2SolrClient extends SolrClient { try { httpClient.start(); } catch (Exception e) { + close(); // make sure we clean up throw new RuntimeException(e); } @@ -250,16 +251,18 @@ public class Http2SolrClient extends SolrClient { 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.shutdownAndAwaitTermination(executor); } - } - if (shutdownExecutor) { - ExecutorUtil.shutdownAndAwaitTermination(executor); } assert ObjectReleaseTracker.release(this);
