Skip to content

Clarify BloomFilter.put return value under concurrency - #8597

Open
NgoQuocViet2001 wants to merge 1 commit into
google:masterfrom
NgoQuocViet2001:docs-bloomfilter-concurrent-put-contract
Open

Clarify BloomFilter.put return value under concurrency#8597
NgoQuocViet2001 wants to merge 1 commit into
google:masterfrom
NgoQuocViet2001:docs-bloomfilter-concurrent-put-contract

Conversation

@NgoQuocViet2001

Copy link
Copy Markdown

Fixes #3055.

BloomFilter.put is lock-free, so concurrent calls for the same object can each set a different subset of bits and both return true. The existing Javadoc instead states that a true result definitely marks the first insertion.

This change scopes the first-insertion and mightContain return-value guarantees to nonconcurrent calls and documents the concurrent case. Runtime behavior is unchanged.

Tests:

  • Ran: .\mvnw.cmd -B -ntp clean install (865,730 tests; 0 failures or errors)

Concurrent puts of the same object can each change different bits and return true. Limit the first-insertion and opposite-return guarantees to nonconcurrent calls and document the concurrent case.
@google-cla

google-cla Bot commented Aug 8, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@NgoQuocViet2001
NgoQuocViet2001 force-pushed the docs-bloomfilter-concurrent-put-contract branch from f2226ae to e59b2ce Compare August 9, 2026 03:21
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.

BloomFilter multithread problem: put() NOT atomic

1 participant