-
Notifications
You must be signed in to change notification settings - Fork 38.4k
Align @RequestPart support in WebFlux with Spring MVC #22973
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Could you provide a sample application we could take a look at? It's hard to figure out where the problem is without a way to reproduce the issue. |
@bclozel here you go It works on SB 2.0.9, but if you change SB version to 2.1.x here Then test will fail. |
@bclozel can I help somehow more with the issue? |
Hi @lazystone , sorry about the late feedback. @PostMapping(value = "/{callId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public Mono<Void> store(@RequestPart("people") final List<Person> people) { is expecting multiple parts like so: var bodyBuilder = new MultipartBodyBuilder();
bodyBuilder.part("people", new Person("Jane"), MediaType.APPLICATION_JSON);
bodyBuilder.part("people", new Person("John"), MediaType.APPLICATION_JSON); In your sample, the If you wish to bind a single part as a collection, then I think you should use the following: @PostMapping(value = "/{callId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public Mono<Void> store(
@PathVariable final String callId,
@RequestPart("metadata") final Map<String, String> metadata,
@RequestPart("fieldOne") final String[] fieldOne,
@RequestPart("fieldTwo") final Double[] fieldTwo) { I think we can use this issue to improve the documentation and underline that |
Oookaay, yeah - definitely worth to document this :) Better with some examples. |
This looks more like a regression to me. The sample doesn't even have multiple parts with the same name, and yet the resolver is trying to pass a List of all parts with that name. As a result there is no option to convert to a List, and while array does provide an option, it is a problem in its own right that arrays and lists aren't treated consistently. Taking a step back and comparing to Spring MVC where In WebFlux, the support for I think we should correct this and align with Spring MVC even if the behavior has been there since the beginning of 5.1. It would be a breaking change if trying to convert multipart parts with the same name to a |
I think we need to address this but I've scheduled it for 5.3 since it will require breaking behavior, mainly with regards to decoding to
|
Affects: 5.1.6
After upgrading Spring Boot from 2.0.2 to 2.1.4 we started to see an issue with multipart form data uploading:
That worked on spring boot 2.0.2, but on 2.1.4 it fails with decoding exception:
So it actually tries to deserialize list of doubles as just a Double.
As a workaround we've changed method signature to use Double[] instead of List. After that it works as expected.
The text was updated successfully, but these errors were encountered: