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 2021/02/21 14:37:22 UTC

[lucene-solr] branch reference_impl_dev updated: @1361 Detect too many SolrCore closes after dec, tooling on tests and threads and leaks.

This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/reference_impl_dev by this push:
     new c1dcda7  @1361 Detect too many SolrCore closes after dec, tooling on tests and threads and leaks.
c1dcda7 is described below

commit c1dcda7c5bb35b473fcbba4e36b80646a323cc97
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Sun Feb 21 08:36:59 2021 -0600

    @1361 Detect too many SolrCore closes after dec, tooling on tests and threads and leaks.
    
    Took 11 minutes
---
 solr/core/src/java/org/apache/solr/core/SolrCore.java            | 9 ++++++---
 solr/core/src/test/org/apache/solr/core/TestConfigSets.java      | 1 +
 .../apache/solr/handler/admin/ShowFileRequestHandlerTest.java    | 4 ++--
 solr/test-framework/src/java/org/apache/solr/SolrTestCase.java   | 5 +++++
 4 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index 7169245..127834b 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -1746,13 +1746,16 @@ public final class SolrCore implements SolrInfoBean, Closeable {
   @Override
   public void close() {
     int cref = refCount.get();
-    if (cref == -1 || cref == 0) {
-      throw new IllegalStateException("Already closed " + cref);
-    }
+
 
 
     int count = refCount.decrementAndGet();
 
+    if (count < -1) {
+      refCount.set(-1);
+      throw new IllegalStateException("Already closed " + count);
+    }
+
 //    if (log.isDebugEnabled()) {
 //      RuntimeException e = new RuntimeException();
 //      StackTraceElement[] stack = e.getStackTrace();
diff --git a/solr/core/src/test/org/apache/solr/core/TestConfigSets.java b/solr/core/src/test/org/apache/solr/core/TestConfigSets.java
index 07e6d0c..70af6a0 100644
--- a/solr/core/src/test/org/apache/solr/core/TestConfigSets.java
+++ b/solr/core/src/test/org/apache/solr/core/TestConfigSets.java
@@ -130,6 +130,7 @@ public class TestConfigSets extends SolrTestCaseJ4 {
 
       // We initially don't have a /dump handler defined
       SolrCore core = container.create("core1", ImmutableMap.of("configSet", "configset-2"));
+
       assertThat("No /dump handler should be defined in the initial configuration", core.getRequestHandler("/dump"), is(nullValue()));
 
       // Now copy in a config with a /dump handler and reload
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java
index 59641e3..827e170 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/ShowFileRequestHandlerTest.java
@@ -43,13 +43,13 @@ public class ShowFileRequestHandlerTest extends SolrJettyTestBase {
 
   @Before
   public void setUp() throws Exception {
-    createAndStartJetty(legacyExampleCollection1SolrHome());
     super.setUp();
+    createAndStartJetty(legacyExampleCollection1SolrHome());
   }
 
   @After
   public void tearDown() throws Exception {
-      super.tearDown();
+    super.tearDown();
   }
 
   public void test404ViaHttp() throws Exception {
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
index 5006719..8a90267 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCase.java
@@ -704,6 +704,11 @@ public class SolrTestCase extends Assert {
     }
     if (thread.getName().contains(ParWork.ROOT_EXEC_NAME + "-")) {
       log.warn("interrupt on {}", thread.getName());
+      try {
+        thread.join(100);
+      } catch (InterruptedException e) {
+
+      }
       thread.interrupt();
       return true;
     }