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 03187a25e1f..dbc1c3afb8a 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 @@ -375,7 +375,8 @@ public abstract class LuceneTestCase extends Assert { private final static Set STATIC_LEAK_IGNORED_TYPES = Collections.unmodifiableSet(new HashSet(Arrays.asList( "org.slf4j.Logger", - "org.apache.solr.SolrLogFormatter"))); + "org.apache.solr.SolrLogFormatter", + EnumSet.class.getName()))); /** * This controls how suite-level rules are nested. It is important that _all_ rules declared @@ -390,9 +391,14 @@ public abstract class LuceneTestCase extends Assert { .around(new TestRuleAssertionsRequired()) .around(new StaticFieldsInvariantRule(STATIC_LEAK_THRESHOLD, true) { protected boolean accept(java.lang.reflect.Field field) { + // Don't count known classes that consume memory once. if (STATIC_LEAK_IGNORED_TYPES.contains(field.getType().getName())) { return false; } + // Don't count references from ourselves, we're top-level. + if (field.getDeclaringClass() == LuceneTestCase.class) { + return false; + } return super.accept(field); } })