#4094 Prefer uses methods when nested target options are only ignores - #4109
Open
arimu1 wants to merge 2 commits into
Open
#4094 Prefer uses methods when nested target options are only ignores#4109arimu1 wants to merge 2 commits into
arimu1 wants to merge 2 commits into
Conversation
…y ignores Under BeanMapping(ignoreByDefault = true), a whole-property mapping combined with a nested path ignore was forcing an empty forged method and silently skipping Mapper#uses methods. Prefer existing mapping methods when nested options are ignore-only, and allow name-based mapping for those forged methods.
…-assign Only retain Mapper#uses mapping-method assignments for ignore-only nested options; forge for direct/type-conversion so same-type nested ignores apply. Add same-type regression test.
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
With
@BeanMapping(ignoreByDefault = true), combining a whole-property mapping and a nested path ignore:caused MapStruct to always forge a nested
personToPersonDtomethod instead of using a suitable method fromMapper#uses. Because the forged method inheritedignoreByDefaultand only carried the nested ignore, it mapped nothing — silent data loss. Removing the redundant nested ignore restored correct delegation.Fix
PropertyMapping: when nested forge options are ignore-only, try existing mapping method selection first (same path as a plain property mapping), and only forge if none is found.BeanMappingMethod: for forged methods that only carry ignore references, do not let parentignoreByDefaultsuppress name-based mapping (so same-named properties still map when nousesmethod exists). Positive nested mappings underignoreByDefault(e.g. ToolBox / Ignore mappings by default #1392) are unchanged.MappingReferences#containsOnlyIgnoreMappingshelper.Fixes #4094
Changes
PropertyMapping,BeanMappingMethod,MappingReferencesorg.mapstruct.ap.test.bugs._4094(uses mapper + without uses)NEXT_RELEASE_CHANGELOG.mdTest plan
Issue4094Test(6 runs: eclipse + javac) — greenIgnorePropertyTest(ignore / expand / inherit),Issue2278Test— green