Route addToRootPom=true pins to the reactor root in UpgradeTransitiveDependencyVersion - #8319
Open
steve-aom-elliott wants to merge 1 commit into
Open
Route addToRootPom=true pins to the reactor root in UpgradeTransitiveDependencyVersion#8319steve-aom-elliott wants to merge 1 commit into
steve-aom-elliott wants to merge 1 commit into
Conversation
…DependencyVersion Previously addToRootPom=true dropped every pin in a multi-module reactor when the transitive was held only by a child module. Two things combined to hide the write: UpgradeTransitiveDependencyVersion bailed at the reactor root because the root itself has no matching transitive of its own, and AddManagedDependency's write gate refused to write on the child because the child was not in the rootPoms set. Give UpgradeTransitiveDependencyVersion a real scanner: for every pom that holds a matching transitive, walk up parentPomIsProjectPom to find the reactor root's GAV and record the coordinate against it in AddManagedDependency.Scanned. In the visitor phase, when addToRootPom=true, fire only on reactor roots and pin every coordinate the scanner collected against that root. Non-root behavior stays identical for addToRootPom=null/false.
steve-aom-elliott
marked this pull request as ready for review
July 23, 2026 19:52
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
UpgradeTransitiveDependencyVersion(..., addToRootPom=true)silently dropped every pin in a multi-module reactor whenever the vulnerable transitive was held only by a child module. Two things combined to hide the write:UpgradeTransitiveDependencyVersion.visitDocumentreturned early on the reactor root because the root itself has no matching transitive of its own (matchingDependencies.isEmpty()).AddManagedDependency.visitDocument's write gate (!Boolean.TRUE.equals(addToRootPom) || acc.rootPoms.contains(document)) refused to write on the child pom because only reactor-root poms are inacc.rootPoms.Result: the recipe produced no changes at all, even though a child module clearly held the transitive.
Change
Give
UpgradeTransitiveDependencyVersiona real scanner: for every pom that holds a matching transitive, walk upparentPomIsProjectPom()to find the reactor root's GAV and record the coordinate against it in a newAddManagedDependency.Scanned#reactorRootTransitivesmap.In the visitor phase, branch on
addToRootPom:true— fire only on reactor roots (!parentPomIsProjectPom()) and pin every coordinate the scanner collected against that root's GAV.null/false— existing behavior unchanged (per-pom matching with parent-preference dedup).AddManagedDependency.visitDocument's guard already routes correctly when the root pom is visited (root is inacc.rootPoms), so no changes needed there.Behavior change
Only the
addToRootPom=truepath is affected. Thenull/falsepath — the common case, including everythingUpgradeTransitiveDependencyVersionTestcovered before — is unchanged.Callers that were relying on
addToRootPom=truesilently no-op-ing in reactors will now see the recipe produce edits.Known scope limitation
If a child has its own competing
<dependencyManagement>entry for the same coordinate, Maven's inheritance rule means the child's local entry shadows the parent's — the root-scoped pin won't take effect for that specific module until the child entry is removed. This PR does not touch child poms. Filed as follow-up.Test plan
addsManagedDependencyToReactorRootWhenAddToRootPomAndOnlyChildHoldsTheTransitiveinUpgradeTransitiveDependencyVersionTestcovers the reactor-root write.UpgradeTransitiveDependencyVersionTestandAddManagedDependencyTestsuites pass.rewrite-maven:testmodule passes.Draft — soliciting feedback on the accumulator shape and the child-cleanup boundary before finalizing.