mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8214427: probable bug in logic of ConcurrentHashMap.addCount()
Reviewed-by: martin, dholmes
This commit is contained in:
parent
6c78aa9571
commit
8846159987
1 changed files with 7 additions and 9 deletions
|
@ -2334,17 +2334,15 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
|
|||
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);
|
||||
int rs = resizeStamp(n) << RESIZE_STAMP_SHIFT;
|
||||
if (sc < 0) {
|
||||
if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 ||
|
||||
sc == rs + MAX_RESIZERS || (nt = nextTable) == null ||
|
||||
transferIndex <= 0)
|
||||
if (sc == rs + MAX_RESIZERS || sc == rs + 1 ||
|
||||
(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))
|
||||
else if (U.compareAndSetInt(this, SIZECTL, sc, rs + 2))
|
||||
transfer(tab, null);
|
||||
s = sumCount();
|
||||
}
|
||||
|
@ -2358,11 +2356,11 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
|
|||
Node<K,V>[] nextTab; int sc;
|
||||
if (tab != null && (f instanceof ForwardingNode) &&
|
||||
(nextTab = ((ForwardingNode<K,V>)f).nextTable) != null) {
|
||||
int rs = resizeStamp(tab.length);
|
||||
int rs = resizeStamp(tab.length) << RESIZE_STAMP_SHIFT;
|
||||
while (nextTab == nextTable && table == tab &&
|
||||
(sc = sizeCtl) < 0) {
|
||||
if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 ||
|
||||
sc == rs + MAX_RESIZERS || transferIndex <= 0)
|
||||
if (sc == rs + MAX_RESIZERS || sc == rs + 1 ||
|
||||
transferIndex <= 0)
|
||||
break;
|
||||
if (U.compareAndSetInt(this, SIZECTL, sc, sc + 1)) {
|
||||
transfer(tab, nextTab);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue