Skip to content

High: mutual recursion between default getOutputPath()/getOutputName() causes StackOverflowError #92

Closed

Description

@elharo

Severity: High

Summary

The getOutputPath() and getOutputName() default methods in MavenReport delegate to each other. Because both are default, an implementation is allowed to override neither. Such an implementation compiles cleanly but recurses infinitely the first time the output path is queried and crashes with StackOverflowError.

Location

src/main/java/org/apache/maven/reporting/MavenReport.java:91-93 and :100-102

default String getOutputPath() {
    return getOutputName();
}

@Deprecated
default String getOutputName() {
    return getOutputPath();
}

Impact

The output path is queried during every report render. An implementation that overrides neither method (legal now that both are default) throws StackOverflowError on first access. Historically getOutputName() was abstract and mandatory, so implementations ported to the new API that omit both methods now crash at runtime instead of failing to compile.

Steps to reproduce

  1. Implement MavenReport without overriding either getOutputPath() or getOutputName().
  2. Call getOutputPath() (or getOutputName()).
  3. Observe StackOverflowError.

Suggested fix

Make at least one of the methods non-default/abstract, or replace the default delegation with a fail-fast fallback, e.g.:

@Deprecated
default String getOutputName() {
    throw new UnsupportedOperationException("Implement getOutputPath() instead");
}

Test gap

MavenReportTest only covers implementations that override the method; it never exercises an implementation that overrides neither, which is the case that overflows.

Activity

  1. self-assigned this
    on Oct 11, 2026
  2. added
    bug
    on Oct 11, 2026
  3. slachiewicz commented on Oct 11, 2026

    @slachiewicz
    Member

    The throwing default would break reports that follow the deprecation and implement only getOutputPath(): released maven-site-plugin 3.22.0 (AbstractSiteRenderingMojo lines 376 and 554) and doxia-sitetools 2.1.0 (DefaultSiteTool line 1494) still call report.getOutputName(). Making either method abstract is a source break in a minor release. The override check in #93 keeps both directions working; I'd tighten it to m.isDefault() && m.getDeclaringClass() == MavenReport.class so a sub-interface that redeclares getOutputName() is not rejected, and reuse it for #91.

  4. slawekjaranowski commented on Oct 11, 2026

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

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions