LUCENE-4383: fixes to static memory leak accounting.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1384222 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dawid Weiss 2012-09-13 07:32:28 +00:00
parent 19119c0476
commit 6b6e3d888c
1 changed files with 7 additions and 1 deletions

View File

@ -375,7 +375,8 @@ public abstract class LuceneTestCase extends Assert {
private final static Set<String> STATIC_LEAK_IGNORED_TYPES =
Collections.unmodifiableSet(new HashSet<String>(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);
}
})