RFR: 8351230: Collections.synchronizedList returns a list that is not thread-safe [v3]

Stuart Marks smarks at openjdk.org
Sat May 17 01:25:14 UTC 2025


> Collections.synchronizedList() returns a List implementation that doesn't do proper locking. This PR does the following on the synchronized wrapper:
> 
> - overrides and adds locking to SequencedCollection methods;
> - performs instance management of reversed synchronized views;
> - adds test for race conditions and functional tests of synchronized wrappers.

Stuart Marks has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains eight additional commits since the last revision:

 - Merge branch 'master' into JDK-8351230-synchronized-list
 - Adjust @summary line in test.
 - Reversed view of SynchronizedRandomAccessList should also be RandomAccess.
   Add tests to ensure RandomAccess is preserved when reversing.
 - moar comments
 - Various tweaks.
 - fix for synch list
 - fix copyright line
 - tests for synch list

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/24990/files
  - new: https://git.openjdk.org/jdk/pull/24990/files/1750bb20..0ad5d080

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=24990&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=24990&range=01-02

  Stats: 58374 lines in 1704 files changed: 29902 ins; 19676 del; 8796 mod
  Patch: https://git.openjdk.org/jdk/pull/24990.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24990/head:pull/24990

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


More information about the core-libs-dev mailing list