-
Notifications
You must be signed in to change notification settings - Fork 804
Fix GH-201: Multiple @RequestPart not Working #258
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
Conversation
@aaronjwhiteside Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@aaronjwhiteside Thank you for signing the Contributor License Agreement! |
Codecov Report
@@ Coverage Diff @@
## 2.2.x #258 +/- ##
============================================
+ Coverage 77.63% 78.21% +0.57%
- Complexity 386 390 +4
============================================
Files 51 52 +1
Lines 1525 1538 +13
Branches 221 222 +1
============================================
+ Hits 1184 1203 +19
+ Misses 246 239 -7
- Partials 95 96 +1
|
@aaronjwhiteside Thanks for the PR. Will review today. |
Fixes gh-201 |
Changing PR base branch to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @aaronjwhiteside In general, LGTM. Great that there are thorough tests. Have requested two minor changes - please have a look. Also, please merge the recent changes from branch 2.2.x
, resolve any conflicts and resubmit - will be able to merge it then.
...-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringEncoder.java
Show resolved
Hide resolved
@@ -120,8 +120,6 @@ public void testMultipartFile1() { | |||
MultipartFile multipartFile = new MockMultipartFile("test_multipart_file", | |||
"hi".getBytes()); | |||
encoder.encode(multipartFile, MultipartFile.class, request); | |||
|
|||
assertThat(request.requestCharset()).as("request charset is not null").isNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want the tests to have assertions varifying the results that we are expecting to get. If the assertion becomes invalid, due to changes in code, the test should be reworked with correct assertions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I removed this because charset has no impact on multipart handling, leaving this here would give the false impression that it's needed or influences something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. We would have to verify the commits and why this assertion was added there, to begin with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But since it's testing the exception let's leave it this way.
930e11c
to
c8dcd4d
Compare
Summary of changes follows: - Delegate ALL requestBody encoding where Content-Type is multipart/form-data to the SpringFormEncoder. - Introduce RequestPartParameterProcessor to deal with @RequestPart annotations, adds parameters to MethodMetadata.formParams(). - Wrap HttpMessageConversionException in EncodeException. - Add tests to verify expected behaviour. However there still exists a gap in functionality where any user defined pojo will be serialized as a Map<String,String>, as there is currently no way for SpringFormEncoder to know about the Content-Type of the individual parts beyond MultipartFile, boxed primitive types (which are treated as text/plain) and other built-in types inherited from FormEncoder.
dc7c1d2
to
9437031
Compare
Summary of changes follows:
Content-Type
ismultipart/form-data
to theSpringFormEncoder
.RequestPartParameterProcessor
to deal with@RequestPart
annotations, adds parameters toMethodMetadata.formParams()
.HttpMessageConversionException
inEncodeException
.However there still exists a gap in functionality where any user defined pojo will be serialized as a
Map<String,String>
, as there is currently no way forSpringFormEncoder
to know about theContent-Type
of the individual parts beyondMultipartFile
, boxed primitive types (which are treated astext/plain
) and other built-in types inherited fromFormEncoder
.