Skip to content

Polish LinkedCaseInsensitiveMap #22926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

izeye
Copy link
Contributor

@izeye izeye commented May 8, 2019

This PR polishes LinkedCaseInsensitiveMap.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 8, 2019
@jhoeller jhoeller self-assigned this May 8, 2019
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels May 8, 2019
@jhoeller jhoeller added this to the 5.2 M2 milestone May 8, 2019
@jhoeller
Copy link
Contributor

jhoeller commented May 8, 2019

Following up on #22821, this would indeed benefit from some further polishing. However, those lazy key/value/entry are really meant to be published in a thread-safe fashion, preserving the notion of multi-threaded exposure for read-only purposes... so those fields should be declared volatile, in which case the current initialization pattern makes sense for thread-safe publication purposes.

I'll do a custom commit for the volatile declarations, also picking up your EntryIterator refactoring in it. Thanks for the PR, in any case!

@jhoeller jhoeller closed this in fb29088 May 8, 2019
@izeye
Copy link
Contributor Author

izeye commented May 8, 2019

@jhoeller Thanks for the quick feedback!

in which case the current initialization pattern makes sense for thread-safe publication purposes.

If "the current initialization pattern" means having a local variable, I'd like to understand if removing the local variable as proposed causes any problem. Could you please explain on this?

@izeye izeye deleted the polish-20190508 branch May 8, 2019 17:14
@jhoeller
Copy link
Contributor

jhoeller commented May 8, 2019

It's just a defensive coding pattern where the local copy of a volatile field can be reliably checked against (in case of multiple checks, it's a single consistent value which is not going to reflect concurrent changes from other threads), and where we're optimizing access to the volatile field to begin with (one read attempt only). We're using a similar pattern in other places.

@izeye
Copy link
Contributor Author

izeye commented May 8, 2019

@jhoeller Thanks for clarification 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: task A general task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants