--- jsr166/src/test/tck/ConcurrentHashMapTest.java 2016/07/17 03:40:07 1.48 +++ jsr166/src/test/tck/ConcurrentHashMapTest.java 2017/01/04 06:09:58 1.52 @@ -16,6 +16,8 @@ import java.util.Map; import java.util.Random; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import junit.framework.Test; import junit.framework.TestSuite; @@ -32,7 +34,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"); @@ -331,6 +333,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 +825,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 +836,5 @@ public class ConcurrentHashMapTest exten assertFalse(keySet.removeAll(removeMe)); assertEquals(mapSize, map.size()); } + }