avoid test failure due to field assignment rearrangements?

This commit is contained in:
Alexey Kudravtsev
2017-06-16 17:47:18 +03:00
parent 012d87ec0a
commit 0093ee8e46
@@ -389,19 +389,19 @@ public class ConcurrentMapsTest {
while (!map.isEmpty());
}
private volatile Object strong;
@Test
public void testConcurrentWeakValueSize() {
Map<String, Object> map = ContainerUtil.createConcurrentWeakValueMap();
Object o = new Object();
map.put("a", o);
strong = new Object();
map.put("a", strong);
map.put("b", new Object());
GCUtil.tryGcSoftlyReachableObjects();
assertEquals(1, map.size());
o = null;
strong = null;
GCUtil.tryGcSoftlyReachableObjects();
assertTrue(map.isEmpty());
assertTrue(map.toString(), map.isEmpty());
}
}