Skip to content

CacheAspectSupport 's generateKey method should not concatenate Strings [SPR-12527] #17132

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
spring-projects-issues opened this issue Dec 9, 2014 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Kyrill Alyoshin opened SPR-12527 and commented

CacheAspectSupport class has the following line of code at the beginning of its generateKey method:

Assert.notNull(key, "Null key returned for cache operation (maybe you are using named params " +
				"on classes without debug info?) " + context.operation);

YourKit shows that this single method call takes about 15% of total time when invoking a "cached" method through Spring caching pipeline. It is not surprising because context.operation object has a non-trivial implementation of the toString method.

We really think that this Assert.notNull call should be refactored into if(key == null)... for performance reasons.


Affects: 4.1.3

Referenced from: commits 67f1842

Backported to: 4.0.9

1 votes, 3 watchers

@spring-projects-issues
Copy link
Collaborator Author

Stéphane Nicoll commented

Good catch, most of the logging usage of CacheOperation are guarded by logger.isTraceEnabled - This may also be a nice improvements for Spring 4.0.x (that piece of code of yours is coming from 4.0.x I think)

@spring-projects-issues
Copy link
Collaborator Author

Stéphane Nicoll commented

Fixed.

Juergen Hoeller, I think that's a good candidate for a backport. What do you think?

@spring-projects-issues spring-projects-issues added status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.1.4 milestone Jan 11, 2019
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) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants