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

Regression: Handler method detection reporting ambiguous methods for explicit HEAD mapping [SPR-14182] #18753

spring-issuemaster opened this issue Apr 16, 2016 · 3 comments


Copy link

@spring-issuemaster spring-issuemaster commented Apr 16, 2016

Oliver Drotbohm opened SPR-14182 and commented

Let's start with the reproducing sample first.

$ git clone
$ cd spring-data-examples/rest/starbucks
$ mvn spring-boot:run

$ curl -v -X HEAD http://localhost:8080/api/stores
> HEAD /api/stores HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
< HTTP/1.1 500 Internal Server Error
< Server: Apache-Coyote/1.1
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Sat, 16 Apr 2016 12:37:59 GMT
< Connection: close

The server produces the following exception:

java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path 'http://localhost:8080/api/stores': {public org.springframework.http.ResponseEntity, throws org.springframework.web.HttpRequestMethodNotSupportedException, public org.springframework.hateoas.Resources,,, throws,org.springframework.web.HttpRequestMethodNotSupportedException}
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod( ~[spring-webmvc-4.3.0.RC1.jar:4.3.0.RC1]
	at ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na]
	at ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na]

I was caught by surprise to see that as the two methods mentioned — RepositoryEntityController.headCollectionResource(…) and RepositoryEntityController. getCollectionResource(…) are considered ambiguous as they actually declare request mappings for different HTTP methods. getCollectionResource clearly maps to GET, not HEAD.

On Spring 4.2 this works as expected as you can see by downgrading the example to Spring Boot 1.4.0.M1 (by tweaking the version number of the Boot parent in the root project's POM).

Affects: 4.3 RC1


Issue Links:

  • #17721 Spring should have default support for OPTIONS, HEAD and Allow
  • #22125 Regression: IllegalStateException: Ambiguous handler methods is thrown for explicit HEAD mapping

Referenced from: commits 1cb9f2c, 7cdcc10

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Apr 16, 2016

Oliver Drotbohm commented

Added a screenshot showing the detected mappings in the Eclipse debugger. Note that the HTTP method mapping is reported to be HEAD where it actually is declared as GET in code.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Apr 17, 2016

Juergen Hoeller commented

Rossen Stoyanchev, this looks like a side effect of our default HEAD handling against GET methods. While we treat it right invocation-wise if a dedicated HEAD mapping exists, we seem to get confused in the mapping registration phase when the mappings just differ in GET vs HEAD.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Apr 17, 2016

Rossen Stoyanchev commented

This should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.