ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ConcurrentHashMapTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ConcurrentHashMapTest.java (file contents):
Revision 1.58 by jsr166, Mon Jan 8 03:37:59 2018 UTC vs.
Revision 1.59 by dl, Fri Oct 5 19:01:35 2018 UTC

# Line 838 | Line 838 | public class ConcurrentHashMapTest exten
838          assertEquals(mapSize, map.size());
839      }
840  
841 +
842 +    
843 +    public void testReentrantComputeIfAbsent() {
844 +        ConcurrentHashMap<Integer, Integer> map = new ConcurrentHashMap<>(16);
845 +        try {
846 +            for (int i = 0; i < 100; i++) { // force a resize
847 +                map.computeIfAbsent(i, key -> findValue(map, key));
848 +            }
849 +            fail("recursive computeIfAbsent");
850 +        } catch (IllegalStateException ex) {
851 +        }
852 +    }
853 +
854 +    private Integer findValue(ConcurrentHashMap<Integer, Integer> map,
855 +                              Integer key) {
856 +        return (key % 5 == 0) ?  key :
857 +            map.computeIfAbsent(key + 1, k -> findValue(map, k));
858 +    }
859 +    
860   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines