8343426: ConcurrentSkipListMap.spliterator() can no longer split the stream

Co-authored-by: Doug Lea <dl@openjdk.org>
Reviewed-by: vklang
This commit is contained in:
Dr Heinz M. Kabutz 2024-11-14 09:17:02 +00:00 committed by Viktor Klang
parent a8152bdb9a
commit 2b57f402c4
2 changed files with 40 additions and 9 deletions

View file

@ -3221,14 +3221,14 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
}
// factory method for KeySpliterator
final KeySpliterator<K,V> keySpliterator() {
Index<K,V> h; Node<K,V> n; long est;
Index<K,V> h; Node<K,V> hn, n; long est;
VarHandle.acquireFence();
if ((h = head) == null) {
if ((h = head) == null || (hn = h.node) == null) {
n = null;
est = 0L;
}
else {
n = h.node;
n = hn.next;
est = getAdderCount();
}
return new KeySpliterator<K,V>(comparator, h, n, null, est);
@ -3307,14 +3307,14 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
// Almost the same as keySpliterator()
final ValueSpliterator<K,V> valueSpliterator() {
Index<K,V> h; Node<K,V> n; long est;
Index<K,V> h; Node<K,V> hn, n; long est;
VarHandle.acquireFence();
if ((h = head) == null) {
if ((h = head) == null || (hn = h.node) == null) {
n = null;
est = 0L;
}
else {
n = h.node;
n = hn.next;
est = getAdderCount();
}
return new ValueSpliterator<K,V>(comparator, h, n, null, est);
@ -3411,14 +3411,14 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
// Almost the same as keySpliterator()
final EntrySpliterator<K,V> entrySpliterator() {
Index<K,V> h; Node<K,V> n; long est;
Index<K,V> h; Node<K,V> hn, n; long est;
VarHandle.acquireFence();
if ((h = head) == null) {
if ((h = head) == null || (hn = h.node) == null) {
n = null;
est = 0L;
}
else {
n = h.node;
n = hn.next;
est = getAdderCount();
}
return new EntrySpliterator<K,V>(comparator, h, n, null, est);