Skip to content

Conversation

@nickita-khylkouski
Copy link

Summary

  • Add ConcurrentMapSpliteratorTester to verify spliterator characteristics on ConcurrentMap views
  • Tests verify that entrySet(), keySet(), and values() spliterators have the CONCURRENT characteristic
  • Tests verify that no spliterator has both CONCURRENT and SIZED characteristics (mutually incompatible per Java spec)

Motivation

Per issue #7855 and maintainer guidance from @chaoren:

  • ConcurrentMap implementations should return spliterators with the CONCURRENT characteristic
  • The Java specification states that a top-level Spliterator should not report both CONCURRENT and SIZED

Currently, some Guava ConcurrentMap implementations (e.g., LocalCache, MapMakerInternalMap) return spliterators that:

  • Do NOT have CONCURRENT (should have it)
  • DO have SIZED (should not have it for concurrent collections)

This PR adds tests to document the expected behavior. A follow-up PR can fix the implementations.

Testing

  • Tests follow the existing ConcurrentMap*Tester pattern in testlib
  • Includes reflection helper methods for test suppression if needed
  • Verified JDK's ConcurrentHashMap correctly returns CONCURRENT=true, SIZED=false

Related Issues

Fixes #7855

…istics

Add tests to verify that ConcurrentMap implementations return spliterators
with the CONCURRENT characteristic on their entrySet(), keySet(), and
values() views. Also verifies that no spliterator reports both CONCURRENT
and SIZED characteristics (which are mutually incompatible per the Java
specification).

Fixes google#7855
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

testlib: add tests for ConcurrentMap to make sure its derived Sets are concurrent

1 participant