Repository navigation
[Backport maven-3.10.x] Fix DependencyResolutionResult not dispatched when resolution fails (fix #8635) - #13688
Conversation
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-bot
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Following up on my earlier review — 1 of the 2 Spotless violations has been addressed, 1 remains.
- Import ordering (
org.codehaus.plexus.logging.Loggerinterleaved withorg.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).
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.
Backport of #13539 to
maven-3.10.x.Cherry-pick of 7cf8647 required conflict resolution.
Changes:
eventSpyDispatcher.onEvent(result)into both the success and catch branches ofgetDependencies()so that event listeners receive theDependencyResolutionResultwhether the resolution succeeds or failsLifecycleDependencyResolverEventsTestverifying the result event fires once on success, once on failure, and once when an aggregator tolerates the failureConflict resolution:
impl/maven-core/tomaven-core/(different module structure onmaven-3.10.x)resolveProjectDependencies()instead ofresolveProjectArtifacts()(different API onmaven-3.10.x)maven-3.10.xuses@Injectfield injection, not constructor injection)org.apache.maven.impl.DefaultMessageBuilderFactorytoorg.apache.maven.message.internal.DefaultMessageBuilderFactoryartifactFactory,logger) mocked for themaven-3.10.xAPIFixes #8635