Fix error in ResourceAccumulatorTest.
Change-Id: I3f1c9686e33892cb30f45825cb800806ff4d3f9d
diff --git a/dev/core/test/com/google/gwt/dev/resource/impl/ResourceAccumulatorTest.java b/dev/core/test/com/google/gwt/dev/resource/impl/ResourceAccumulatorTest.java
index c8d6de3..ca5e3a9 100644
--- a/dev/core/test/com/google/gwt/dev/resource/impl/ResourceAccumulatorTest.java
+++ b/dev/core/test/com/google/gwt/dev/resource/impl/ResourceAccumulatorTest.java
@@ -14,6 +14,7 @@
package com.google.gwt.dev.resource.impl;
import com.google.gwt.thirdparty.guava.common.collect.Lists;
+import com.google.gwt.thirdparty.guava.common.collect.Sets;
import com.google.gwt.thirdparty.guava.common.io.Files;
import junit.framework.TestCase;
@@ -24,6 +25,7 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.Set;
/**
* Tests for ResourceAccumulator.
@@ -271,14 +273,21 @@
return list;
}
- private PathPrefixSet pathPrefixes;
+ private Set<PathPrefixSet> pathPrefixes = Sets.newHashSet();
+
+ @Override
+ public void tearDown() {
+ pathPrefixes.clear();
+ }
private PathPrefixSet createInclusivePathPrefixSet() {
- // Set to a field to create a strong reference, otherwise will get GCed as ResourceAccumulator
- // refers to it weakly.
- pathPrefixes = new PathPrefixSet();
- pathPrefixes.add(new PathPrefix("", null));
- return pathPrefixes;
+ PathPrefixSet pathPrefixSet = new PathPrefixSet();
+ pathPrefixSet.add(new PathPrefix("", null));
+
+ // Keep the the reference until the end of the test to create a strong reference, otherwise
+ // will get GCed as ResourceAccumulator refers to it weakly.
+ pathPrefixes.add(pathPrefixSet);
+ return pathPrefixSet;
}
private void waitForFileEvents() throws InterruptedException {