Skip to content
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

Improve performance of MapPropertySource.containsProperty [SPR-12224] #16839

Closed
spring-projects-issues opened this issue Sep 18, 2014 · 1 comment
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Phil Webb opened SPR-12224 and commented

The MapPropertySource.containsProperty() method is not currently implemented directly, instead the EnumerablePropertySource implementation is used. This means for each containsProperty() call map keys are converted to an array then iterated.

We can improve performance by looking in the map directly.


Affects: 4.1 GA

Referenced from: commits 587a816, e71fbb9, 752574d, 65cc57d

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

This change unfortunately has a side effect for SystemEnvironmentPropertySource (which extends MapPropertySource): When used with an active JVM SecurityManager, it may fail when checking the availability of property naming variants. Our EnvironmentSecurityManagerIntegrationTests does fail on Windows for that reason.

Modifying SystemEnvironmentPropertySource to not call super.containsProperty anymore but rather to perform the default check against getPropertyNames() as we used to do before makes the problem go away. This should be a fine compromise, with the regular MapPropertySource still being able to perform an optimized containsProperty lookup.

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants