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.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1682454 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2015-05-29 13:18:09 +00:00
parent 9cc7865346
commit d38212a458
2 changed files with 13 additions and 8 deletions

View File

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

View File

@ -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();