jakartaee / jakartaee/rest

Support java.util.Optional as parameter type in resource methods

Open
#503 15 comments 0 reactions 1 assignee Claimed by @glassfishrobot View on GitHub
Component: filters&handlers
Dominant language
Java
Stars
400
Forks
143
PR merge metrics
No merged PRs in 30d

Description

Jersey fills in missing optional resource method arguments with 'null'. Dealing with "possibly null" variables can be a bit of an annoyance, so more than often I do

Optional optArg1 = Optional.ofNullable(arg1);
Optional optArg2 = Optional.ofNullable(arg2);
...

at the top of my resource methods. This opens up for use of many convenience methods such as map, orElse, orElseThrow, ifPresent etc.

So, request for enhancement: Let Jersey handle java.util.Optional as parameter type in resource methods directly.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.