Skip to content

[backport 4.0.x] Fix #12592: use string-based ID for forked execution cycle detection - #12898

Merged
gnodet merged 1 commit into
maven-4.0.xfrom
backport/12867
Aug 28, 2026
Merged

[backport 4.0.x] Fix #12592: use string-based ID for forked execution cycle detection#12898
gnodet merged 1 commit into
maven-4.0.xfrom
backport/12867

Conversation

@gnodet

@gnodet gnodet commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Backport of #12867 to maven-4.0.x.

Original PR: #12867

…12867)

The cycle detection in DefaultLifecycleExecutionPlanCalculator used
Set<MojoDescriptor> (object equality) to track already-planned forked
executions. Because DefaultPluginDescriptorCache clones the
PluginDescriptor (and all its MojoDescriptor objects) on every cache
retrieval, independently-loaded descriptors for the same plugin are
always different object instances. While MojoDescriptor does override
equals/hashCode, relying on mutable object equality inside a HashSet
is fragile — if any identity field changes after insertion, the set
lookup silently fails.

Switch to Set<String> using MojoDescriptor.getId()
(groupId:artifactId:version:goal) for cycle detection. String keys
are immutable and make the comparison semantics explicit, eliminating
any risk of identity mismatch across cloned descriptor instances.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet added this to the 4.0.0-rc-7 milestone Aug 28, 2026
@gnodet
gnodet merged commit c63d07d into maven-4.0.x Aug 28, 2026
23 checks passed
@gnodet
gnodet deleted the backport/12867 branch August 28, 2026 14:29

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean backport of #12867 to maven-4.0.x (byte-identical diffs). The change from Set<MojoDescriptor> to Set<String> using immutable MojoDescriptor.getId() keys (groupId:artifactId:version:goal) for forked execution cycle detection is correct — eliminates fragility of using mutable objects as hash set keys when DefaultPluginDescriptorCache clones descriptors on every cache retrieval.

All three cycle detection sites are consistently updated: fillMojoDescriptors (insertion), calculateForkedLifecycle (contains check), and calculateForkedGoal (contains check). The new test directly validates that independently-created descriptors with the same coordinates produce the same getId() value.

✅ LGTM — no issues found.

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of Guillaume Nodet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant