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

Side effect from ProducesRequestCondition cache with multiple RequestMappingHandlerMapping beans #23091

Closed
odrotbohm opened this issue Jun 5, 2019 · 0 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@odrotbohm
Copy link
Member

The fix for #22644 introduces an optimization by storing the calculated accept headers in a request attribute for later lookups. If a HandlerMapping implementation decorates the request hoping that Accept headers would be looked up through that decorator, this fails as the cached values get used.

I suggest to reset the cache per HandlerMapping so that it's able to tweak thhe request early in the processing cycle but still benefit from the cache.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 5, 2019
@sbrannen sbrannen added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement labels Jun 6, 2019
@rstoyanchev rstoyanchev self-assigned this Jun 6, 2019
@rstoyanchev rstoyanchev added this to the 5.2 M3 milestone Jun 6, 2019
@rstoyanchev rstoyanchev removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 6, 2019
@rstoyanchev rstoyanchev changed the title Optimizations in ProducesRequestCondition affect HandlerMappings Side effect from ProducesRequestCondition cache with multiple RequestMappingHandlerMapping beans Jun 11, 2019
bclozel added a commit to spring-projects/spring-boot that referenced this issue Feb 17, 2020
As of spring-projects/spring-framework#22644, Spring Framework caches
the "produces" condition when matching for endpoints in the
`HandlerMapping` infrastructure. This has been improved in
spring-projects/spring-framework#23091 to prevent side-effects in other
implementations.

Prior to this commit, the Spring Boot actuator infrastructure for
`EndpointHandlerMapping` would not clear the cached attribute,
presenting the same issue as Spring Framework's infrastructure. This
means that a custom arrangement with custom `HandlerMapping` or
`ContentTypeResolver` would not work properly and reuse the cached
produced conditions for other, unintented, parts of the handler mapping
process.

This commit clears the cached data and ensures that other handler
mapping implementations are free of that side-effect.

Fixes gh-20150
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

4 participants