-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
Graham Cox opened SPR-16674 and commented
If I have handler methods annotated with @RequestMethod
, with varying degrees of the "params" property, Spring doesn't differentiate as I'd hoped.
Specifically, in this case:
@Controller
@RequestMapping(value = ["/oauth2/auth"], method = [RequestMethod.GET])
class AuthorizationController {
@RequestMapping(params = ["response_type=code"])
fun startAuthorizationCode() {
LOG.debug("Starting authorization with response_type=code")
}
@RequestMapping(params = ["response_type"])
fun startAuthorizationUnknownType(@RequestParam("response_type") responseType: String) {
LOG.warn("Unknown response_type value: {}", responseType)
}
@RequestMapping
fun startAuthorizationNoType() {
LOG.warn("Missing mandatory parameter: response_type")
}
}
If I call "GET /oauth2/auth" then I correctly trigger "startAuthorizationNoType" - as the only matching handler.
If I call "GET /oauth2/auth?response_type=different" then I correctly trigger "startAuthorizationUnknownType" - as the more specific match.
Unfortunately, the other case fails. A call to "GET /oauth2/auth?response_type=code" triggers:
java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path 'http://localhost:8080/oauth2/auth': {public void uk.co.grahamcox.worlds.openid.AuthorizationController.startAuthorizationCode(), public void uk.co.grahamcox.worlds.openid.AuthorizationController.startAuthorizationUnknownType(java.lang.String)}
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:370)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:317)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:62)
at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:351)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.getHandler(WebMvcMetricsFilter.java:132)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:119)
at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:111)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
I was hoping that this would instead trigger "startAuthorizationCode" as the most specific match of the three, but this proved not to be the case.
Affects: 5.0.4
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement