You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
java.util.Optional MultipartFile[] @RequestParam argument is null in multipart/form-data POST [SPR-15918] #20472
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.
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.
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?
Activity
spring-projects-issues commentedon Sep 20, 2017
Juergen Hoeller commented
This turned out to be a general bug in the
DefaultConversionService'sCollectionToObjectConverter: It unconditionally turned an empty collection intonull, not sending it through theConversionServicefor potentialOptionaladaptation.spring-projects-issues commentedon Dec 28, 2017
Maciej Zerkowski commented
Does it mean there is no way to get
nullinstead of empty list for simple@RequestPart(required = false) List<MultipartFile> filesrest controller method param?