#4029 Fall back from ADDER_PREFERRED to setter when adder path not applicable - #4108
Open
arimu1 wants to merge 1 commit into
Open
#4029 Fall back from ADDER_PREFERRED to setter when adder path not applicable#4108arimu1 wants to merge 1 commit into
arimu1 wants to merge 1 commit into
Conversation
…th not applicable When CollectionMappingStrategy.ADDER_PREFERRED selects an adder but the source cannot supply elements for adder matching (e.g. Map with a direct Map→List mapping method), fall back to SETTER_PREFERRED behavior instead of failing while trying to map into the adder parameter type.
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.
Summary
CollectionMappingStrategy.ADDER_PREFERREDis a preference, not a hard requirement. When the adder path is not applicable — for example mapping aMapsource property onto a collection that has both an adder and a setter, with a direct whole-collection mapping method (List map(Map)) — MapStruct previously failed while trying to map into the adder parameter type (e.g.Map → String).This change falls back to setter-preferred behavior when:
Map, which is not treated as element-iterable for matching), and a setter exists for the property; orList/iterable/array sources that can use the adder continue to prefer the adder.
Fixes #4029
Changes
PropertyMapping: fall back to the property setter when ADDER is selected but not applicable; do not forge doomedMap → adder-elementmappingsorg.mapstruct.ap.test.bugs._4029covering Map→List (setter fallback) and List→List (adder still preferred)Test plan
Issue4029MapperTest(4 runs: eclipse + javac) — greenAdderTest,Issue3165MapperTest,bugs._1170.AdderTest— green