Skip to content

fast mode: failOnError=true cannot fail the build from session-end listener #352

Closed

Description

@gnodet

Problem

When -Dmaven.clean.fast=true is set, BackgroundCleaner runs deletion inside a Maven session-end listener (AbstractEventSpy.onEvent). Maven catches exceptions thrown from listeners and downgrades them to a warning:

[WARNING] Failed to notify spy EventSpyImpl

This means failOnError=true silently has no effect in fast mode: deletion failures are logged as warnings but the build still succeeds. This is documented in the current Javadoc but is a real user-visible gap.

Root cause

A session-end listener is the wrong execution context to fail a build. Maven's listener dispatch swallows exceptions — there is no mechanism to propagate them as a MojoExecutionException from that point.

Proposed approaches

Two options were discussed in PR #347:

  1. Check accumulated errors at next module execution: have CleanMojo.execute() check BackgroundCleaner's accumulated fatal errors at the start of the next module's run and throw MojoExecutionException if any exist. This keeps the asynchrony but introduces a one-module delay before the failure surfaces.

  2. Give up asynchrony when failOnError=true: when failOnError=true, have CleanMojo.execute() wait for that module's deletion to complete synchronously before returning, turning fast mode into a synchronous operation for that configuration. Simpler semantics, but defeats the performance benefit for that config.

Both have real trade-offs. Neither belonged in PR #347.

Related

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions