Skip to content

[Backport maven-3.10.x] Fix DependencyResolutionResult not dispatched when resolution fails (fix #8635) - #13688

Merged
gnodet merged 3 commits into
apache:maven-3.10.xfrom
gnodet:backport/13539-to-maven-3.10.x
Oct 23, 2026
Merged

gnodet merged 3 commits into
apache:maven-3.10.xfrom
gnodet:backport/13539-to-maven-3.10.x

Conversation

@gnodet

@gnodet gnodet commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Backport of #13539 to maven-3.10.x.

Cherry-pick of 7cf8647 required conflict resolution.

Changes:

  • Move eventSpyDispatcher.onEvent(result) into both the success and catch branches of getDependencies() so that event listeners receive the DependencyResolutionResult whether the resolution succeeds or fails
  • Add LifecycleDependencyResolverEventsTest verifying the result event fires once on success, once on failure, and once when an aggregator tolerates the failure

Conflict resolution:

  • Test file path adapted from impl/maven-core/ to maven-core/ (different module structure on maven-3.10.x)
  • Test adapted to use resolveProjectDependencies() instead of resolveProjectArtifacts() (different API on maven-3.10.x)
  • Constructor replaced with field injection via reflection (maven-3.10.x uses @Inject field injection, not constructor injection)
  • Import changed from org.apache.maven.impl.DefaultMessageBuilderFactory to org.apache.maven.message.internal.DefaultMessageBuilderFactory
  • Additional fields (artifactFactory, logger) mocked for the maven-3.10.x API

Fixes #8635

 apache#8635)

- LifecycleDependencyResolver dispatched the result only on the success path; on failure the exception was wrapped before the dispatch point, so listeners received the request but never a result
- Move the dispatch into both the success and catch branches immediately after the resolution call; remove the post-try dispatch; event order on success is unchanged, aggregator builds that tolerate failure still receive the result exactly once
- Add LifecycleDependencyResolverEventsTest: result fires once on success, once on failure, and once when an aggregator tolerates the failure
@gnodet gnodet added this to the 3.10.1 milestone Oct 22, 2026
@gnodet gnodet added bug Something isn't working backport labels Oct 22, 2026

@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.

CI is failing with two Spotless violations in LifecycleDependencyResolverEventsTest.java. The fix logic itself is correct — eventSpyDispatcher.onEvent(result) is now called in both paths. The test structure is solid. Just the formatting needs a spotless:apply.

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.

Following up on my earlier review — 1 of the 2 Spotless violations has been addressed, 1 remains.

  • Import ordering (org.codehaus.plexus.logging.Logger interleaved with org.apache.maven.*) — ✅ addressed. Imports are now alphabetically sorted (org.apache.maven.* → org.codehaus.* → org.eclipse.* → org.junit.* → org.mockito.*).
  • Missing newline at end of file — ⚠️ still open (see inline comment).

⚠️ Pre-fix validation: Dynamic check skipped (CI pending). Static trace: testResultIsFiredWhenTheResolutionFails calls resolve(false) which reaches resolveProjectDependencies() → getDependencies(). The test stubs dependenciesResolver.resolve() to throw failure, which is a DependencyResolutionException. The old code called onEvent(result) only after the try-catch (post-hoc), so a non-tolerating failure would exit via the re-thrown LifecycleExecutionException before reaching it — the test would have failed before the fix. The fix adds the call inside the catch block before rethrowing. The static trace confirms the test exercises the fixed path.

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

@gnodet
gnodet merged commit 3d91fd3 into apache:maven-3.10.x Oct 23, 2026
15 checks passed
@gnodet
gnodet deleted the backport/13539-to-maven-3.10.x branch October 26, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants