Apache Lucene open-source search software
SOLR-7601: We should only check that tests have properly closed resources if the tests passed. Speeds up test fails and cleans up Jenkin's failure reports.
Mark Robert Millerd38212a4581b
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.javaindex 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.javaindex 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();