Fix `Spliterator` characteristics in `ConcurrentReferenceHashMap` by kilink · Pull Request #35817 · spring-projects/spring-framework

@kilink

The Spliterators returned by values, entrySet, and keySet incorrectly reported
the SIZED characteristic, instead of CONCURRENT. This could lead to bugs when
the map is concurrently modified during a stream operation.

For keySet and values, the incorrect characteristics are inherited from
AbstractMap, so to rectify that the respective methods are overridden and
custom collections are provided that report the correct Spliterator
characteristics.

Signed-off-by: Patrick Strawderman <pstrawderman@netflix.com>

kilink

@sbrannen sbrannen added the in: core

Issues in core modules (aop, beans, core, context, expression)

label

Nov 15, 2025

@sbrannen sbrannen changed the title Fix Spliterator characteristics in ConcurrentReferenceHashMap Fix Spliterator characteristics in ConcurrentReferenceHashMap

Nov 17, 2025

sbrannen added a commit that referenced this pull request

Nov 17, 2025

sbrannen pushed a commit that referenced this pull request

Nov 17, 2025
The Spliterators returned by values, entrySet, and keySet incorrectly
reported the SIZED characteristic, instead of CONCURRENT. This could
lead to bugs when the map is concurrently modified during a stream
operation.

For keySet and values, the incorrect characteristics are inherited from
AbstractMap, so to rectify that the respective methods are overridden,
and custom collections are provided that report the correct Spliterator
characteristics.

Closes gh-35817

Signed-off-by: Patrick Strawderman <pstrawderman@netflix.com>

(cherry picked from commit ed75906)

sbrannen added a commit that referenced this pull request

Nov 17, 2025

@kilink kilink deleted the concurrent-reference-hash-map-fix-spliterators branch

November 20, 2025 16:21