diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java index f2280e462aa..51306dbb350 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java +++ b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java @@ -489,7 +489,7 @@ public abstract class LuceneTestCase extends Assert { /** * Suite failure marker (any error in the test or suite scope). */ - private static TestRuleMarkFailure suiteFailureMarker; + protected static TestRuleMarkFailure suiteFailureMarker; /** * Temporary files cleanup rule. diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java index aa1e5121228..5d3ec611b06 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java @@ -226,13 +226,18 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase { try { deleteCore(); resetExceptionIgnores(); - endTrackingSearchers(); - String orr = ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty(); - if (!RandomizedContext.current().getTargetClass().isAnnotationPresent(SuppressObjectReleaseTracker.class)) { - assertNull(orr, orr); - } else { - if (orr != null) { - log.warn("Some resources were not closed, shutdown, or released. This has been ignored due to the SuppressObjectReleaseTracker annotation."); + + if (suiteFailureMarker.wasSuccessful()) { + // if the tests passed, make sure everything was closed / released + endTrackingSearchers(); + String orr = ObjectReleaseTracker.clearObjectTrackerAndCheckEmpty(); + if (!RandomizedContext.current().getTargetClass().isAnnotationPresent(SuppressObjectReleaseTracker.class)) { + assertNull(orr, orr); + } else { + if (orr != null) { + log.warn( + "Some resources were not closed, shutdown, or released. This has been ignored due to the SuppressObjectReleaseTracker annotation."); + } } } resetFactory();