Support for java.util.OptionalInt/Long/Double as @RequestParam #33301
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: declined
A suggestion or change that we don't feel we should currently apply
Uh oh!
There was an error while loading. Please reload this page.
Affects: 4.1+
Spring supports java8 generic
Optional<?>
as a request parameter (see #16448 0dc6082).But there are value-based primitive counterparts:
java.util.OptionalInt
java.util.OptionalLong
java.util.OptionalDouble
which are not supported. For example, simple controller methods like this
require cumbersome fiddling with converters and method argument resolvers.
Is it worth implementing these types as well to get more consistent behavior? Such classes are quite useful especially in conjunction with primitive streams or custom primitive collections (we use fastutils). Their apis usually offer bare primitive types instead of boxed wrappers. Sure, it is possible to get it working without extra config just with generic
Optional<BoxedType>
and some manual casts here and there, it just feels unnecessary.The text was updated successfully, but these errors were encountered: