Allow empty list for @RequestPart List<MultipartFile>#352
Closed
darrenfoong wants to merge 5 commits intospring-cloud:mainfrom
Closed
Allow empty list for @RequestPart List<MultipartFile>#352darrenfoong wants to merge 5 commits intospring-cloud:mainfrom
darrenfoong wants to merge 5 commits intospring-cloud:mainfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #352 +/- ##
===========================================
- Coverage 4.83% 4.80% -0.04%
Complexity 13 13
===========================================
Files 45 46 +1
Lines 1385 1394 +9
Branches 205 205
===========================================
Hits 67 67
- Misses 1316 1325 +9
Partials 2 2
|
Collaborator
|
Hi, @darrenfoong - thanks for the PR. Could you first check with the maintainers of feign-form if it's possible to add the |
Contributor
Author
|
I've just created a PR for feign-form: OpenFeign/feign-form#99. I hope the maintainers become active... |
Collaborator
|
Closing as external issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have a use case where I need to send a list of
MultipartFiles, but sometimes this list could be empty. Currently, to successfully send an empty list (i.e. the server receives an empty list as a method argument), I need to sendnullinstead, which requires me to do a priorisEmpty()check.(It is strange that sending
nullfrom the client results in an empty list received by the server, but this is documented here.)Sending an empty list now throws an exception:
This PR adds an
EmptyCollectionWritertoMultipartFormContentProcessorin theSpringFormEncoder. ThisWriteris a no-op.It would be ideal to add the
EmptyCollectionWriterin the feign-form project instead, but that project is relatively inactive.I also added a new test client endpoint that counts the number of files sent, to make sure that empty lists are not received as
null, in case Spring Framework changes behaviour in the future.