Skip to content

Second call to MVC handler method with Optional parameter fails with argument type mismatch [SPR-13755] #18328

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 2, 2015 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Dec 2, 2015

Andy Wilkinson opened SPR-13755 and commented

This was originally reported as a Spring Boot issue, but I believe the problem lies in Spring MVC. I've pushed a sample that reproduces the issue to the spring-boot-issues repo: https://github.com/spring-projects/spring-boot-issues/tree/master/gh-4660.

For the first request, the argument type is correctly resolved as java.util.Optional. The second time it's resolved as a MultipartFile. A possible side-effect of the first resolution setting the HandlerMethodParameter's parameter type so the second resolution is using different inputs?


Affects: 4.1.8, 4.2.3

Reference URL: spring-projects/spring-boot#4660

Issue Links:

Backported to: 4.1.9

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Indeed, its the interaction with GenericTypeResolver.resolveParameterType which breaks it: There is a missing check for the top nesting level there, accidentally exposing a nested parameter type as cached top-level parameter type.

The underlying bug also affects 4.1.x, so I'm backporting that change to 4.1.9 as well.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Andy Wilkinson, does a recent 4.2.4.BUILD-SNAPSHOT work here? Could you please (re-)run that Boot repro app just to double-check?

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Andy Wilkinson commented

Looks good. The repro passes against Boot 1.3.1.BUILD-SNAPSHOT which is using Spring Framework 4.2.4.BUILD-SNAPSHOT.

@spring-projects-issues spring-projects-issues added type: bug A general bug status: backported An issue that has been backported to maintenance branches in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.2.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: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants