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

java.util.Optional MultipartFile[] @RequestParam argument is null in multipart/form-data POST [SPR-15918] #20472

spring-issuemaster opened this issue Aug 31, 2017 · 2 comments


Copy link

@spring-issuemaster spring-issuemaster commented Aug 31, 2017

Brice Roncace opened SPR-15918 and commented

If an Optional @RequestParam is not present in the request parameters, that value should be Optional.EMPTY as opposed to null. However, an Optional<MultipartFile[]> or Optional<List<MultipartFile>> parameter on a controller method handling a POSTed multipart/form-data request is NOT converting that parameter to Optional.EMPTY as expected but leaving it null.

Affects: 4.3.10

Reference URL:

Issue Links:

  • #20235 Request params Optional<List and List are inconsistent
  • #20876 Empty List instead of null in List files
  • #20473 only one MultipartFile object populated when using an java.util.Optional MutipartFile array or list @RequestParam

Referenced from: commits 15c82af, 53a9697

Backported to: 4.3.12

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Sep 20, 2017

Juergen Hoeller commented

This turned out to be a general bug in the DefaultConversionService's CollectionToObjectConverter: It unconditionally turned an empty collection into null, not sending it through the ConversionService for potential Optional adaptation.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Dec 28, 2017

Maciej Zerkowski commented

Does it mean there is no way to get null instead of empty list for simple @RequestPart(required = false) List<MultipartFile> files rest controller method param?

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.