Skip to content

#1968 Do not pass condition qualifiers to forged iterable mapping methods - #4158

Open
Maver4ck wants to merge 1 commit into
mapstruct:mainfrom
Maver4ck:1968
Open

Maver4ck wants to merge 1 commit into
mapstruct:mainfrom
Maver4ck:1968

Conversation

@Maver4ck

@Maver4ck Maver4ck commented Nov 24, 2026 •

Copy link
Copy Markdown

Fixes #1968

Condition qualifiers (conditionQualifiedBy / conditionQualifiedByName) only select the presence check of the property, which is generated in the calling method. They were also passed to the forged iterable / stream mapping method, where they are part of ContainerMappingMethod#equals. As a result, otherwise identical forged methods were not reused and a duplicate (e.g. stringArrayToStringList1) was generated.

The forged method now only receives the selection parameters it applies (SelectionParameters#withoutConditionQualifiers).

The exact scenario from the issue is already fixed on main by #3591. This PR adds a regression test for it and fixes the remaining variant with a condition qualifier. Generated code before/after: #1968 (comment)

Tests: Issue1968Test fails without the change and passes with it; it also asserts that the condition is still applied to the property itself. The full processor test suite passes locally.

…pping methods

They are only used to select the presence check of the property, but made
otherwise identical forged methods unequal, which generated duplicates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MapStruct creates duplicate helper methods for Array to List conversion

1 participant