Skip to content

putIfAbsent - #825

Open
pjfanning wants to merge 1 commit into
3.xfrom
putIfAbsent
Open

putIfAbsent#825
pjfanning wants to merge 1 commit into
3.xfrom
putIfAbsent

Conversation

@pjfanning

@pjfanning pjfanning commented Aug 13, 2026

Copy link
Copy Markdown
Member

What this fixes: Under concurrent access, two threads could both miss the cache, both compute the value (expensive for _descriptorCache which runs BeanIntrospector), and then both call put — the second overwriting the first. With putIfAbsent, only the first computed value is stored; the second thread's result is discarded safely. The redundant computation still happens but the cache is never corrupted by a race.

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.

1 participant