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

Closed
spring-projects-issues opened this issue Aug 31, 2017 · 2 comments
Assignees
Labels
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 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: https://stackoverflow.com/q/45949393/225217

Issue Links:

Referenced from: commits 15c82af, 53a9697

Backported to: 4.3.12

@spring-projects-issues
Copy link
Collaborator Author

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.

@spring-projects-issues
Copy link
Collaborator Author

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
Labels
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