LinkedBlockingDeque.clear() should preserve weakly-consistent iterators by 
linking f.prev and f.next back to f, allowing the iterators to continue from 
the first or last respectively. This would be consistent with how the other 
node-based weakly consistent queues LinkedBlockingQueue LinkedTransferQueue, 
ConcurrentLinkedQueue/Deque work.

The LBD already supports self-linking, since that is done by the unlinkFirst() 
and unlinkLast() methods, and the iterators and spliterator all support this.

This can be fixed very easily by linking both f.prev and f.next back to f.

-------------

Commit messages:
 - Added self-link to nodes during clear(), to make weakly-consistent iteration 
consistent with other linked data structures.

Changes: https://git.openjdk.org/jdk/pull/24488/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=24488&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8354060
  Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/24488.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24488/head:pull/24488

PR: https://git.openjdk.org/jdk/pull/24488

Reply via email to