- 
    Bug 
- 
    Resolution: Fixed
- 
     P4 P4
- 
    11, 12
- 
        b24
- 
        generic
- 
        generic
| Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build | 
|---|---|---|---|---|---|---|
| JDK-8293086 | 11.0.18-oracle | Ravi Reddy | P4 | Resolved | Fixed | b01 | 
| JDK-8287737 | 11.0.17 | Andrew Hughes | P4 | Resolved | Fixed | b01 | 
| JDK-8292696 | openjdk8u352 | Paul Hohensee | P4 | Resolved | Fixed | b04 | 
| JDK-8358264 | shenandoah8u352 | Paul Hohensee | P4 | Resolved | Fixed | b04 | 
| JDK-8293087 | 8u361 | Ravi Reddy | P4 | Resolved | Fixed | b01 | 
if (check >= 0) {
Node<K,V>[] tab, nt; int n, sc;
while (s >= (long)(sc = sizeCtl) && (tab = table) != null &&
(n = tab.length) < MAXIMUM_CAPACITY) {
int rs = resizeStamp(n);
if (sc < 0) {
if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 ||
sc == rs + MAX_RESIZERS || (nt = nextTable) == null ||
transferIndex <= 0)
break;
if (U.compareAndSetInt(this, SIZECTL, sc, sc + 1))
transfer(tab, nt);
}
else if (U.compareAndSetInt(this, SIZECTL, sc,
(rs << RESIZE_STAMP_SHIFT) + 2))
transfer(tab, null);
s = sumCount();
}
}
In the above code, condition of (sc == rs + 1 || sc == rs + MAX_RESIZERS ) would never be true , since the value of rs is positive and the value of sc is negative .
The correct condition should be (sc >>> RESIZE_STAMP_SHIFT) == rs + 1 || (sc >>> RESIZE_STAMP_SHIFT) == rs + MAX_RESIZERS, which can be used to dedect if resizing process finished or resizing threads reaches maxmium limitation
if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 ||
sc == rs + MAX_RESIZERS || (nt = nextTable) == null ||
transferIndex <= 0)
FREQUENCY : always
Edited to correct apparent typo: it stated "... the value of rs is negative" but it is sc that is negative.
- backported by
- 
                    JDK-8287737 probable bug in logic of ConcurrentHashMap.addCount() -           
- Resolved
 
-         
- 
                    JDK-8292696 probable bug in logic of ConcurrentHashMap.addCount() -           
- Resolved
 
-         
- 
                    JDK-8293086 probable bug in logic of ConcurrentHashMap.addCount() -           
- Resolved
 
-         
- 
                    JDK-8293087 probable bug in logic of ConcurrentHashMap.addCount() -           
- Resolved
 
-         
- 
                    JDK-8358264 probable bug in logic of ConcurrentHashMap.addCount() -           
- Resolved
 
-         
- relates to
- 
                    JDK-8215326 Test java/util/concurrent/ConcurrentHashMap/ToArray.java hangs after j.u.c updates -           
- Closed
 
-         
- 
                    JDK-8242464 Bug in the logic of ConcurrentHashMap.addCount() when used in Threads -           
- Closed
 
-         
- links to
- 
                     Commit
        openjdk/jdk8u-dev/4cc462ab Commit
        openjdk/jdk8u-dev/4cc462ab
- 
                     Commit
        openjdk/jdk11u-dev/a2e64948 Commit
        openjdk/jdk11u-dev/a2e64948
- 
                     Review
        openjdk/jdk8u-dev/18 Review
        openjdk/jdk8u-dev/18
- 
                     Review
        openjdk/jdk11u-dev/1114 Review
        openjdk/jdk11u-dev/1114
- 
                     Review(master)
        openjdk/jdk8u-dev/18 Review(master)
        openjdk/jdk8u-dev/18