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

ObjectToOptionalConverter should use Optional.ofNullable(…) instead of Optional.of(…) [SPR-12589] #17190

Closed
spring-issuemaster opened this issue Dec 31, 2014 · 0 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Dec 31, 2014

Oliver Drotbohm opened SPR-12589 and commented

In case the ConversionService used in the ObjectToOptionalConverter is a FormattingConversionService, a ParserConverter will be used for the String to object conversion. For empty String instances this will immediately return null from convert(…) which then causes an exception as the ObjectToOptionalConverter passes it to Optional.of(…).

Here's a sample scenario:

String someMethod(@RequestParam Optional<Point> location) { … }

Now imagine we have a Formatter registered to turn a request parameter String into a Point. If now a request ?location= (no value) is triggered, the scenario described above kicks in.


Affects: 4.1.4

Referenced from: commits ed665a1, ec84fa6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.