#3997 Fix InheritInverseConfiguration ignore for nested sources with parameter prefix#4091
Open
kamilkrzywanski wants to merge 1 commit into
Conversation
…ces with parameter prefix When a forward mapping uses a source path that includes the source parameter name (e.g. source.client.id), inverse inheritance previously kept that prefix in the inverse target name. Ignore and redefinition matching then failed because the first path segment was the parameter name rather than the property. Strip the source parameter name prefix when building the inverse target name, mirroring SourceReference / TargetReference resolution.
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
Fixes #3997
When a forward mapping uses a source path that includes the source parameter name (e.g.
source.client.id),@InheritInverseConfigurationpreviously kept that prefix in the inverse target name (source.client.id). As a result,@Mapping(target = "client", ignore = true)on the inverse method did not match the nested inherited mapping, and MapStruct still created intermediate objects for ignored properties.Root cause
copyForInverseInheritanceswapped source/target naively, sosource = "source.client.id"became inversetarget = "source.client.id".TargetReference, so nested mapping still worked.source), not the property (client).Fix
When building the inverse target name, strip the source parameter name prefix (e.g.
source.client.id→client.id), mirroringSourceReference/TargetReferenceresolution. If the first segment is also a property of the source type, the full path is kept (property path takes precedence).Tests
ignore = true→ nested properties stay nullChecklist
NEXT_RELEASE_CHANGELOG.md