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 re-retrieval of @ResponseStatus annotation for each request [SPR-15227] #19792

Closed
spring-projects-issues opened this issue Feb 6, 2017 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Feb 6, 2017

Violeta Georgieva opened SPR-15227 and commented

Hi,

Currently @ResponseStatus is calculated every time when a request is performed.

https://github.com/spring-projects/spring-framework/blob/master/spring-webflux/src/main/java/org/springframework/web/reactive/result/AbstractHandlerResultHandler.java#L166

It is better to calculate it when constructing the MethodParameter.

Regards,
Violeta


Affects: 4.3.7, 5.0 M4

Issue Links:

@spring-projects-issues
Copy link
Collaborator Author

Brian Clozel commented

This turns out to be a more general issue with AnnotatedElementUtils not caching annotation resolution (vs. AnnotatedUtils, which has a local cache for that). So we'll try to solve this issue at the AnnotatedElementUtils level.

If that doesn't work out, we can always solve that at the HandlerMethod level.

According to Violeta Georgieva, this performance issue shows even when the annotation is not present on the handler method, which means that the local cache should also cache null values (i.e. the annotation is not present).

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

I'm moving @ResponseStatus resolution to the cached HandlerMethod, with the InvocableHandlerMethod variants just picking it up from there. This allows for caching the actual HttpStatus object, not even having to call the (reflective) ResponseStatus.code() method for each request anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants