Skip to content

[#6804] Honor BOM relocation during dependency management import - #13081

Open
goutamadwant wants to merge 4 commits into
apache:masterfrom
goutamadwant:fix/mng-5527-bom-relocation
Open

goutamadwant wants to merge 4 commits into
apache:masterfrom
goutamadwant:fix/mng-5527-bom-relocation

Conversation

@goutamadwant

@goutamadwant goutamadwant commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6804.

Follow distributionManagement relocation chains for imported BOMs in the Maven 4 model builder, including partial relocations. Preserve dependency-management precedence, import exclusions, and the resolver-selected version.

Warn when a user directly imports a relocated BOM. Log later relocation hops and relocations encountered inside another imported BOM at DEBUG, since those warnings are not actionable. Order contended import-cache lock waits to prevent concurrent BOM-import cycles while retaining in-flight reuse for ordinary shared imports.

The deprecated compat model builder retains its previous BOM-import behavior. Its only change reports a model-building error, rather than an NPE, when a workspace resolver misses and no fallback ModelResolver is available.

Validation:

Follow partial and chained BOM relocations in both model builders while preserving import precedence, exclusions, resolver-selected versions, and ordinary imported-model validation behavior.

Detect relocation and mixed import cycles, retain coordination for ordinary cold imports, and avoid cyclic waits introduced by relocation traversal. Add focused compatibility and concurrency tests and a Core IT for the reported missing managed-version failure.

Signed-off-by: goutamadwant <[email protected]>
+ dependency.getManagementKey() + " is missing.")
.setLocation(dependency.getLocation("")));
continue;
DependencyManagement importMgmt = loadDependencyManagement(dependency, model, request, problems, importIds);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no abbrevations please

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.

renamed the variables to use full names.

}

continue;
@SuppressWarnings("checkstyle:methodlength")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe you should break this method up

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.

Done.

importRequest.setUserProperties(request.getUserProperties());
importRequest.setLocationTracking(request.isLocationTracking());
}
final ModelBuildingResult importResult;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

move into the try block, don't split declaration and initialization

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.

Sure. Moved the declaration and initialization of importResult inside the try block, together with the result handling. Let me know if this is good now

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I reviewed the three comments from @elharo. Here's my assessment:


Comment 1 — "no abbreviations please" (line 1185, importMgmt)

importMgmt is not new to this PR — it already exists on master (along with depMgmt) in the same method. The PR merely moved this code into an extracted loadDependencyManagement method. While renaming abbreviations is a fine cleanup, it shouldn't be a blocker for this PR since it's pre-existing code. If there's a desire to rename these, it could be done as a separate cleanup across the file.

Comment 2 — "maybe you should break this method up" (line 1199, @SuppressWarnings("checkstyle:methodlength"))

The @SuppressWarnings("checkstyle:methodlength") was on master's importDependencyManagement before this PR. This PR already did break the method up: it extracted loadDependencyManagement out of importDependencyManagement, which went from ~160 lines down to ~15. The new method inherited the suppress annotation because the relocation-chain logic added more code. Further decomposition is possible (e.g., extracting the relocation handling) but this is already a significant improvement over master.

Comment 3 — "move into the try block, don't split declaration and initialization" (line 1303)

The final ModelBuildingResult importResult; pattern is carried verbatim from master (previously at the same indentation inside the loop). It's a pre-existing pattern, not introduced by this PR. That said, it's a trivial fix — the variable can be moved inside the try block:

try {
    final ModelBuildingResult importResult = build(importRequest, importIds);
    problems.addAll(importResult.getProblems());
    importModel = importResult.getEffectiveModel();
} catch (ModelBuildingException e) {
    problems.addAll(e.getProblems());
    return null;
}

This is a reasonable cleanup the contributor could apply.


Summary: All three comments point at pre-existing patterns that this PR carried over unchanged. Comment 3 is the only one with a concrete, actionable fix that's trivial to apply. The other two are either already addressed by the PR (method extraction) or out of scope (renaming existing abbreviations).

@renechoi

renechoi commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Maven 4 already has a relocation SPI: MavenArtifactRelocationSource (distributionManagement, userProperties), walked with cycle detection in DefaultArtifactDescriptorReader.loadPom. This adds a second walker for distributionManagement only, and imports resolve via DefaultModelResolver, which never consults those sources, so maven.relocations.entries cannot reach an imported BOM. Intended?

Also a relocation-only loop reports "dependencies of type=pom and with scope=import form a cycle" though one import is declared; loadPom words it "Artifact relocations form a cycle".

@gnodet-bot

Copy link
Copy Markdown
Contributor

Good observations @renechoi. Two distinct points here:

1. Relationship with MavenArtifactRelocationSource / DefaultArtifactDescriptorReader.loadPom

These operate at different layers:

  • DefaultArtifactDescriptorReader.loadPom (resolver layer) — handles relocations during dependency resolution, when the resolver reads an artifact descriptor. It walks relocations via MavenArtifactRelocationSource (which includes DistributionManagementArtifactRelocationSource and UserPropertiesArtifactRelocationSource). This path is used when resolving regular dependencies.

  • DefaultModelBuilder.importDependencyManagement (model builder layer) — handles BOM imports (<scope>import</scope>) during model building. This path resolves the imported POM directly via ModelResolver, builds its effective model, and extracts <dependencyManagement>. It never goes through DefaultArtifactDescriptorReader, so the relocation SPI is never consulted.

Before this PR, if a BOM declared <distributionManagement><relocation>, the model builder would silently ignore it and import nothing (or the wrong thing). This PR adds relocation-following specifically to the model builder's import path.

Regarding maven.relocations.entries (user-properties-based relocations): correct, those cannot currently reach an imported BOM through this path. That's by design for this fix — the scope is limited to distributionManagement relocations, which is the mechanism actually used in published POMs. Extending user-properties relocations to BOM imports would be a separate enhancement.

2. Error message wording for relocation-only cycles

Valid point. When a cycle involves only relocation hops (no actual scope=import dependencies form the cycle), the message "The dependencies of type=pom and with scope=import form a cycle" is misleading. The PR does distinguish between relocation cycles and import cycles internally (see cycleIncludesRelocation in the Maven 4 model builder), but the error message template is reused. This could be improved with a more specific message like "The import POM relocation chain forms a cycle" when the cycle includes a relocation hop.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Use a cycle diagnostic that covers imports and relocations in both model builders. Assert the complete message for ordinary, relocation-only, and mixed cycles.

Extract imported-model resolution from compatibility dependency-management loading, expand the local variable names, and initialize the model-building result inside its try block.

Signed-off-by: goutamadwant <[email protected]>
@goutamadwant

Copy link
Copy Markdown
Contributor Author

Maven 4 already has a relocation SPI: MavenArtifactRelocationSource (distributionManagement, userProperties), walked with cycle detection in DefaultArtifactDescriptorReader.loadPom. This adds a second walker for distributionManagement only, and imports resolve via DefaultModelResolver, which never consults those sources, so maven.relocations.entries cannot reach an imported BOM. Intended?

Also a relocation-only loop reports "dependencies of type=pom and with scope=import form a cycle" though one import is declared; loadPom words it "Artifact relocations form a cycle".

Yes, this fix is limited to distributionManagement relocations in imported BOMs. Imports use ModelResolver rather than the artifact-descriptor relocation SPI; extending maven.relocations.entries to BOM imports would be a separate change.

Changed the diagnostic to “The import POMs form a cycle”, covering ordinary imports, relocations, and mixed cycles. Both model builders now assert the message and cycle path.

@gnodet, could you approve the new CI run?

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Second commit (a7b8f49) addresses all outstanding review feedback:

  1. Variable renames — depMgmt → dependencyManagement, importMgmt → importedManagement, importMgmts → importedManagements. Pre-existing abbreviations cleaned up per @elharo's request.

  2. Method extraction — resolveImportModel() extracted from loadDependencyManagement(), removing the @SuppressWarnings("checkstyle:methodlength"). The extraction is a pure refactoring: workspace-first resolution with early return, then fallback to ModelResolver, same semantics as before with cleaner flow.

  3. Declaration inside try — importResult is now declared and initialized inside the try block as requested.

  4. Cycle diagnostic — Message changed to "The import POMs form a cycle: ..." in both model builders (compat and impl), covering relocations, imports, and mixed cycles. Concise and accurate regardless of whether the cycle involves relocation hops.

  5. New tests — detectsImportCycle() in the compat builder test and detectsDirectImportCycle() in the impl builder test, both asserting the updated cycle message.

CI status: all completed checks are green. The one failure (integration-tests (macos-latest, 17)) is an infrastructure issue — the "Set up JDK 17" step failed, not related to this PR. Remaining checks still in progress.

Changes look solid. @gnodet — this is ready for your review when CI completes.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet

gnodet commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

CI has been approved and is running. Status so far:

  • All 9 full-build jobs: ✅ passed (all platforms, JDK 17/21/25)
  • integration-tests (ubuntu 21, 25): ✅ passed
  • integration-tests (macos 17): ❌ infra failure ("Set up JDK 17" step failed — not related to this PR)
  • Remaining integration-tests: still in progress

The second commit addresses all review feedback cleanly:

  1. Variable renames (depMgmt → dependencyManagement, etc.)
  2. resolveImportModel() extracted, removing the @SuppressWarnings
  3. importResult declaration moved inside the try block
  4. Cycle diagnostic updated to "The import POMs form a cycle"
  5. New cycle-detection tests in both builders

Looks good. I'll re-check once the remaining integration tests complete.

This comment was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review: [MNG-5527] Honor BOM relocation during dependency management import

Verdict: 💬 COMMENT — All prior review feedback (elharo + gnodet) addressed. One gap in the compat builder worth fixing before merge.

Prior findings — all addressed

  • ✅ depMgmt → dependencyManagement, importMgmts → importedManagements — renamed.
  • ✅ Method broken up — importDependencyManagement now delegates to loadDependencyManagement and resolveImportModel.
  • ✅ Variable declarations moved inside try blocks.

Finding: potential NPE in compat resolveImportModel when workspace returns null and modelResolver is absent

In compat/maven-model-builder, the guard at the top of resolveImportModel only catches the case where both resolvers are null:

if (workspaceResolver == null && modelResolver == null) { throw new NullPointerException(...); }

If workspaceResolver is non-null but returns null (model not in workspace — a legitimate outcome), execution falls through to:

importSource = modelResolver.resolveModel(groupId, artifactId, version);

modelResolver could be null here — for example, IDE embedders that supply a WorkspaceModelResolver but no legacy ModelResolver. This produces an NPE with no actionable diagnostic.

Fix: add a null guard before the fallthrough:

if (modelResolver == null) {
    problems.add(new ModelProblemCollectorRequest(Severity.ERROR, Version.BASE)
            .setMessage("Cannot resolve import POM "
                    + ModelProblemUtils.toId(groupId, artifactId, version)
                    + ": not found in workspace and no ModelResolver provided")
            .setLocation(dependency.getLocation("")));
    return null;
}

Impl builder: concurrency analysis

The ImportModelCacheEntry + ReentrantLock + volatile ImportedModel pattern is correct:

  • Normal import paths block (via lock.lock()) until the in-flight build completes, then re-read cached.model — avoids duplicate work.
  • Relocation paths skip waiting via tryLock to prevent deadlock when a relocation chain leads back to a currently-building import — produces at most duplicate work, not a correctness problem.
  • volatile on cached.model guarantees cross-thread visibility without needing a full synchronized block.
  • BomRelocationConcurrencyTest covers concurrent cycles, concurrent aliases, and the shared-build path (concurrentOrdinaryImportsBuildSharedBomOnce).

No concurrency bugs in the impl builder.

Test coverage

BomRelocationTest (compat) covers simple relocation, partial chains, cycles (relocation→import, import→relocation, import→import), workspace path, invalid coordinates, and deduplication (resolutions.get("test:new:1") == 1).

BomRelocationTest + BomRelocationConcurrencyTest (impl) mirror the compat coverage and add multi-thread correctness.


This review was generated by an AI agent, Hermès on behalf of @gnodet.

Report a model-building error when an imported BOM is absent from the
workspace and no fallback ModelResolver is configured. Include the
attempted coordinates and original import location in the diagnostic.

Cover original and relocated workspace misses, configured fallback
resolution, and workspace error precedence without changing successful
imports or the existing invalid-request contract.
@goutamadwant

Copy link
Copy Markdown
Contributor Author

@gnodet-bot @gnodet Fixed. A workspace miss without a fallback ModelResolver now reports a normal model-building error with the missing BOM coordinates and import location. thanks!

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review: [MNG-5527] Honor BOM relocation during dependency management import

Verdict: ✅ APPROVE

Prior finding — addressed

✅ The modelResolver == null guard in compat resolveImportModel is now in place. When a workspace resolver is configured but returns null (model absent from workspace) and no fallback ModelResolver is provided, an ERROR-severity problem with coordinates and source location is reported instead of throwing an NPE.

The severity choice is correct: FATAL is reserved for workspace resolver exceptions (the catch (UnresolvableModelException e) path above). A misconfigured embedder that provides only a workspace resolver without a fallback is a build-configuration error, not a fatal runtime failure — ERROR is appropriate and consistent with the UnresolvableModelException path.

New tests

Five new test methods in BomRelocationTest (compat) cover the full matrix:

  • reportsWorkspaceMissWithoutModelResolver — plain miss, empty workspace, no fallback
  • reportsWorkspaceRelocationTargetMissWithoutModelResolver — relocation chain where the target is missing
  • fallsBackToModelResolverAfterWorkspaceMiss — workspace returns null, fallback resolver succeeds
  • fallsBackToModelResolverForWorkspaceRelocationTarget — relocation chain where only the target needs fallback
  • preservesWorkspaceResolutionFailure — workspace exception (FATAL) takes precedence over fallback

assertMissingWorkspaceModel asserts ERROR severity, message contains the missing coordinates, modelId == "test:consumer:1", and both lineNumber > 0 / columnNumber > 0 (location tracking enabled). Thorough.

No new issues.


This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The relocation warning is not consistently actionable.

Maven's rule is that warnings must be actionable by the user. A relocation is actionable only when the user themselves declared the <dependency> with <scope>import</scope> in their own POM — they can update the coordinates. When the relocation is transitive (a BOM they imported itself re-imports a relocated BOM), there is nothing the user can do, so emitting a WARNING is misleading noise.

The existing resolver layer (DistributionManagementArtifactRelocationSource) already follows this convention: it logs at DEBUG only and never surfaces a BuilderProblem for artifact relocations, even though those can also be transitive.

The ImportContext already carries the machinery to distinguish these two cases — relocationSources is non-empty exactly when we are inside a transitive relocation hop. The fix is to downgrade to LOGGER.debug() for transitive hops and keep WARNING (or LOGGER.warn()) only for direct imports.

Suggestions are provided inline for both model builders.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Comment on lines +1275 to +1282
String message = "The import POM " + imported + " has been relocated to " + relocated.getGroupId() + ':'
+ relocated.getArtifactId() + ':' + relocated.getVersion();
if (relocation.getMessage() != null) {
message += ": " + relocation.getMessage();
}
problems.add(new ModelProblemCollectorRequest(Severity.WARNING, Version.BASE)
.setMessage(message)
.setLocation(dependency.getLocation("")));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The warning is emitted unconditionally — including for transitive relocation hops where the user has nothing to update. Only emit WARNING when it is actually actionable (direct import). Transitive hops should be DEBUG.

ImportContext doesn't exist in the compat builder, but you can check whether importIds is at its initial depth — or simply replicate the relocationSources-based check. The simplest approach: add a Logger field and split on whether this is a direct or transitive call.

Suggested change
String message = "The import POM " + imported + " has been relocated to " + relocated.getGroupId() + ':'
+ relocated.getArtifactId() + ':' + relocated.getVersion();
if (relocation.getMessage() != null) {
message += ": " + relocation.getMessage();
}
problems.add(new ModelProblemCollectorRequest(Severity.WARNING, Version.BASE)
.setMessage(message)
.setLocation(dependency.getLocation("")));
String message = "The import POM " + imported + " has been relocated to " + relocated.getGroupId() + ':'
+ relocated.getArtifactId() + ':' + relocated.getVersion();
if (relocation.getMessage() != null) {
message += ": " + relocation.getMessage();
}
// Only warn when the user directly declared this import and can act on it.
// Transitive relocation hops (a BOM re-importing a relocated BOM) are not
// actionable by the user — log at DEBUG to match artifact relocation behaviour.
if (importIds.isEmpty()) {
problems.add(new ModelProblemCollectorRequest(Severity.WARNING, Version.BASE)
.setMessage(message)
.setLocation(dependency.getLocation("")));
} else {
LOGGER.debug(message);
}

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.

Addressed by removing relocation handling from the deprecated compat builder, as requested in the scope review. There is no compat relocation warning path now.

Comment on lines +2568 to +2574
String message = "The import POM " + imported + " has been relocated to "
+ relocatedDependency.getGroupId() + ':' + relocatedDependency.getArtifactId() + ':'
+ relocatedDependency.getVersion();
if (relocation.getMessage() != null) {
message += ": " + relocation.getMessage();
}
add(Severity.WARNING, Version.BASE, message, dependency.getLocation(""));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same issue as in the compat builder: the WARNING is emitted unconditionally, including for transitive relocation hops. ImportContext.relocationSources is already the right signal — it is non-empty exactly when we are inside a transitive hop. Use it.

Suggested change
String message = "The import POM " + imported + " has been relocated to "
+ relocatedDependency.getGroupId() + ':' + relocatedDependency.getArtifactId() + ':'
+ relocatedDependency.getVersion();
if (relocation.getMessage() != null) {
message += ": " + relocation.getMessage();
}
add(Severity.WARNING, Version.BASE, message, dependency.getLocation(""));
String message = "The import POM " + imported + " has been relocated to "
+ relocatedDependency.getGroupId() + ':' + relocatedDependency.getArtifactId() + ':'
+ relocatedDependency.getVersion();
if (relocation.getMessage() != null) {
message += ": " + relocation.getMessage();
}
// Only warn when actionable: the user declared this import directly and can update
// the coordinates. Transitive hops (relocationSources non-empty) are not actionable
// — log at DEBUG to match DistributionManagementArtifactRelocationSource behaviour.
if (context.relocationSources().isEmpty()) {
add(Severity.WARNING, Version.BASE, message, dependency.getLocation(""));
} else {
LOGGER.debug(message);
}

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.

Addressed. A direct import relocation remains a WARNING at the declaration location. Later hops and relocations encountered while building another BOM are DEBUG. The partial-chain regression asserts that only the direct hop warns.

}

continue;
private DependencyManagement loadDependencyManagement(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The compat DefaultModelBuilder is @Deprecated(since = "4.0.0"). The goal of the compat module is to keep existing Maven 3 embedders working without surprises — not to gain new behaviour. Maven 3 never followed BOM relocations during import, so embedders using this path have no expectation of it.

The changes here go well beyond the minimum needed to fix the NPE / null-resolver gap: they add full relocation-following (loadDependencyManagement, resolveImportModel, validateRelocationCoordinate), new cycle-detection logic, and a relocation warning — all new behaviour in a deprecated class.

Please revert the compat builder to the minimal change needed (e.g. just the null-resolver guard from the last commit if needed for correctness), and keep the BOM relocation feature in the impl builder only. The compat builder should not follow relocations at all.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

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.

Addressed. The compat builder retains its previous BOM-import behavior. Only the workspace-miss guard for a missing fallback ModelResolver remains, with focused tests for workspace hits, misses, fallback, resolver failure, and unchanged relocation behavior.

@elharo
elharo dismissed gnodet-bot’s stale review September 22, 2026 11:08

Bot reviews like thsisone seem useful, but I'm not OK with them requiring changes.

@gnodet

gnodet commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

@elharo

Bot reviews like this one seem useful, but I'm not OK with them requiring changes.

In that very case, the bot did approve the PR. After me reviewing the PR, I instructed the bot to actually request changes for the non actionable warnings. Dismissing the review, given it seems we both agree sounds a bit too much imho. I don't mind people replying and argument to the review and actually disregarding it, that's fine, but dismissing the correct review because it has been raised by a bot is wrong imho.

AFAIK, a "request change" review does not technically forbid anyone from merging the PR.

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@goutamadwant Please address the non actionable WARNING problem.

Warn only for direct BOM imports in the Maven 4 model builder; log
transitive relocation hops at DEBUG. Restore the deprecated compat
builder's import behavior while retaining the workspace-miss resolver
diagnostic.

Order contended BOM cache-lock waits to avoid concurrent ordinary import
cycles, and cover warnings, workspace fallback, and overlapping cycles
with focused regressions.
@goutamadwant

Copy link
Copy Markdown
Contributor Author

@gnodet Addressed the non-actionable warnings. The Maven 4 builder now warns only for a direct BOM import; later relocation hops and relocations inside imported BOMs are DEBUG. I also removed relocation handling from the deprecated compat builder, retaining only the workspace-miss resolver guard. The warning and concurrent-cycle regressions pass, as do mvn verify and the MNG-5527 Core IT. Please take another look.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review: [MNG-5527] Honor BOM relocation during dependency management import

Verdict: ✅ APPROVE

Prior findings (Sep 22 review) — all addressed

✅ impl builder: WARNING now throttled to direct imports only. The condition context.parent == null && context.relocationSources.isEmpty() correctly distinguishes a user-declared top-level import (actionable → Severity.WARNING) from a transitive hop (not actionable → logger.debug()). Traced through the warnsForDirectImportAfterTransitiveImportWasCached test: outer→old:1 (transitive, parent != null) emits debug only; consumer→old:1 (direct, parent == null, relSources empty) emits exactly one WARNING from the cache hit path. Correct.

✅ compat builder: relocation-following removed entirely. importDependencyManagement in compat is now back to Maven 3 behavior — workspace lookup, then ModelResolver fallback, no relocation chain walking. BomRelocationTest deleted from compat. WorkspaceImportResolverTest added to cover the modelResolver == null guard (ERROR instead of NPE), the workspace-hit path, the workspace-fail path, and the compat "ignore-relocation" behavior. All four cases are correct.

New logic in this commit: highestLockedImport deadlock prevention

Verified the lock-ordering invariant. Ascending lexicographic ordering on artifact coordinates (e.g. "test:a:1" < "test:b:1") means:

  • Thread holding lock for A and wanting B: highest("a") < "b" → blocks (waits for B's lock).
  • Thread holding lock for B and wanting A: highest("b") < "a" → false → loads A locally without blocking.

This is a consistent total ordering that prevents circular waits. The three-lock scenario is also safe: if Thread1 holds A+C (highest=C) and wants B where A < B < C, C < B is false → Thread1 loads B locally; no cycle possible. withProblems correctly preserves highestLockedImport across the nested model build boundary.

relocationTarget being reset to false in withProblems is intentional and correct — nested BOM builds should not be in relocation-target error-propagation mode; that flag applies only during the doLoadDependencyManagement resolution step where an unresolvable relocation target needs to fail the whole chain.

Minor observation (no action needed)

There is no standalone test asserting zero warnings when a relocated BOM is imported only transitively. The warnsForDirectImportAfterTransitiveImportWasCached test implies it (total count = 1, not 2), but a dedicated doesNotWarnForTransitiveOnlyRelocation test would make the contract explicit. Optional — the existing coverage is sufficient for merge.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet gnodet added bug Something isn't working mvn4 labels Oct 14, 2026
@gnodet gnodet changed the title [MNG-5527] Honor BOM relocation during dependency management import [#6804] Honor BOM relocation during dependency management import Nov 9, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ License declaration missing

The pull request description must contain at least one of the following lines with a checked box ([x]):

- [ ] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
- [ ] I hereby declare that I have filed an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).

This comment will be hidden automatically once the description is fixed.

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

Labels

bug Something isn't working mvn4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MNG-5527] Dependency management import should support relocations.

5 participants