--- jsr166/src/test/tck/ConcurrentHashMapTest.java 2003/09/20 18:20:07 1.5 +++ jsr166/src/test/tck/ConcurrentHashMapTest.java 2003/11/28 12:38:08 1.6 @@ -435,5 +435,29 @@ public class ConcurrentHashMapTest exten unexpectedException(); } } + + + /** + * SetValue of an EntrySet entry sets value in the map. + */ + public void testSetValueWriteThrough() { + // Adapted from a bug report by Eric Zoerner + ConcurrentHashMap map = new ConcurrentHashMap(2, 5.0f, 1); + assertTrue(map.isEmpty()); + for (int i = 0; i < 20; i++) + map.put(new Integer(i), new Integer(i)); + assertFalse(map.isEmpty()); + Map.Entry entry1 = (Map.Entry)map.entrySet().iterator().next(); + + // assert that entry1 is not 16 + assertTrue("entry is 16, test not valid", + !entry1.getKey().equals(new Integer(16))); + + // remove 16 (a different key) from map + // which just happens to cause entry1 to be cloned in map + map.remove(new Integer(16)); + entry1.setValue("XYZ"); + assertTrue(map.containsValue("XYZ")); // fails + } }