fix(form): correctly handle Map and POJO types - #3586
Open
EduardoRadieske wants to merge 6 commits into
Open
EduardoRadieske wants to merge 6 commits into
EduardoRadieske wants to merge 6 commits into
Conversation
- improve POJO detection for parameterized types - prevent Map and collection types from being treated as POJOs - add PojoUtil unit tests - update WildCardMapTest
EduardoRadieske
force-pushed
the
fix/map-string-urlencoded
branch
from
September 27, 2026 02:27
f8c5848 to
89648ae
Compare
velo
requested changes
Oct 2, 2026
velo
left a comment
Member
There was a problem hiding this comment.
Thanks for the fix. A couple of things before this can go in:
Blocking
PojoUtil.isUserPojo(Class)callstype.getPackage().getName(), butgetPackage()returnsnullfor arrays and primitives. A form-encoded method with abyte[]orintbody now throws an NPE inFormEncoder.encode. WithcreatePredicatedFormEncoder()the predicate throws instead of returningfalse, so the request never reaches the delegate encoder. Please returnfalsefor primitives, arrays, and classes with no package, and add a test for each.WildCardMapTest.testMapStringStringalready passes on master, becauseFormEncoder.encodeand theformRequestspredicate checkinstanceof Mapbefore callingisUserPojo. So it doesn't cover the fix. The real improvement is non-Map JDK types (e.g. aList<String>body or a raw interface type) no longer being treated as POJOs. Please add an end-to-end test throughFormEncoderfor that case.
Nits
FormEncoder.isMap(Object)only wrapsinstanceof Map; inline it.- Please revert the unrelated changes: the javadoc
<pre>reformat, and theappendToFileremoval, which leaves the@TempDir logDirfield unused. - The test package is
feign.form.utils, but the main package isfeign.form.util. PojoUtilTest.TypeReferencewritesjava.lang.reflect.ParameterizedTypein full even though it's already imported.
Author
|
Thanks for the review. Addressed the requested changes and updated the tests. I kept appendToFile removed because it causes TempDir cleanup failures on Windows: log.txt remains open when JUnit tries to delete the temporary directory. Since logDir is no longer used, I also removed the unused TempDir field. |
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.
Description
Fix form encoding for
Mapand POJO types by improving type detection.Changes
Map, collection, primitive, and array types from being treated as POJOs.Map, collection, primitive, array, POJO, and parameterized type handling.Testing
Added and updated unit and end-to-end tests covering the affected form encoding paths.
Related issue: #2827