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

Avoid eager error message formatting in pre-condition checks [SPR-13007] #17599

Closed
spring-issuemaster opened this issue May 10, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented May 10, 2015

Philippe Marschall opened SPR-13007 and commented

During profiling of our application we found a place where Spring unconditionally created an error message using String#format even if no error is raised later. This costs performance as both a java.util.Formatter and error string are created but not used later on. This seems to be the exception from the rule: in most cases the error string is only created in case of an error (e.g., as in AbstractPropertyResolver). In ReadOnlySystemAttributesMap we even found a potential NullPointerException.


No further details from SPR-13007

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 10, 2015

Philippe Marschall commented

pull request
#797

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented May 10, 2015

Sam Brannen commented

This has been addressed in GitHub commit 92c1751:

Avoid eager formatting in pre-condition checks

In general, the Spring Framework aims to construct error message strings only if an actual error has occurred. This seems to be the common pattern in the codebase and saves both CPU and memory. However, there are some places where eager error message formatting occurs unnecessarily.

This commit addresses this issue in the following classes: AdviceModeImportSelector, AnnotationAttributes, and ReadOnlySystemAttributesMap.

The change in ReadOnlySystemAttributesMap also avoids a potential NullPointerException.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.