--- jsr166/src/test/tck/ConcurrentHashMapTest.java 2016/07/17 03:40:07 1.48 +++ jsr166/src/test/tck/ConcurrentHashMapTest.java 2017/03/18 20:42:20 1.54 @@ -32,7 +32,7 @@ public class ConcurrentHashMapTest exten * Returns a new map from Integers 1-5 to Strings "A"-"E". */ private static ConcurrentHashMap map5() { - ConcurrentHashMap map = new ConcurrentHashMap(5); + ConcurrentHashMap map = new ConcurrentHashMap<>(5); assertTrue(map.isEmpty()); map.put(one, "A"); map.put(two, "B"); @@ -119,7 +119,7 @@ public class ConcurrentHashMapTest exten ConcurrentHashMap m = new ConcurrentHashMap(); for (int i = 0; i < size; i++) { - assertTrue(m.put(new CI(i), true) == null); + assertNull(m.put(new CI(i), true)); } for (int i = 0; i < size; i++) { assertTrue(m.containsKey(new CI(i))); @@ -140,7 +140,7 @@ public class ConcurrentHashMapTest exten BS bs = new BS(String.valueOf(i)); LexicographicList bis = new LexicographicList(bi); LexicographicList bss = new LexicographicList(bs); - assertTrue(m.putIfAbsent(bis, true) == null); + assertNull(m.putIfAbsent(bis, true)); assertTrue(m.containsKey(bis)); if (m.putIfAbsent(bss, true) == null) assertTrue(m.containsKey(bss)); @@ -331,6 +331,21 @@ public class ConcurrentHashMapTest exten } /** + * Test keySet().removeAll on empty map + */ + public void testKeySet_empty_removeAll() { + ConcurrentHashMap map = new ConcurrentHashMap<>(); + Set set = map.keySet(); + set.removeAll(Collections.emptyList()); + assertTrue(map.isEmpty()); + assertTrue(set.isEmpty()); + // following is test for JDK-8163353 + set.removeAll(Collections.emptySet()); + assertTrue(map.isEmpty()); + assertTrue(set.isEmpty()); + } + + /** * keySet.toArray returns contains all keys */ public void testKeySetToArray() { @@ -808,9 +823,9 @@ public class ConcurrentHashMapTest exten * ant -Djsr166.tckTestClass=ConcurrentHashMapTest -Djsr166.methodFilter=testRemoveAll_performance -Djsr166.expensiveTests=true tck */ public void testRemoveAll_performance() { - int mapSize = expensiveTests ? 1_000_000 : 100; - int iterations = expensiveTests ? 500 : 2; - ConcurrentHashMap map = new ConcurrentHashMap<>(); + final int mapSize = expensiveTests ? 1_000_000 : 100; + final int iterations = expensiveTests ? 500 : 2; + final ConcurrentHashMap map = new ConcurrentHashMap<>(); for (int i = 0; i < mapSize; i++) map.put(i, i); Set keySet = map.keySet(); @@ -819,4 +834,5 @@ public class ConcurrentHashMapTest exten assertFalse(keySet.removeAll(removeMe)); assertEquals(mapSize, map.size()); } + }