elharo opened a new issue, #91:
URL: https://github.com/apache/maven-reporting-api/issues/91
## Severity: High
### Summary
The two `generate(...)` 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 at
runtime and crashes with `StackOverflowError`.
### Location
`src/main/java/org/apache/maven/reporting/MavenReport.java:60-62` and
`:76-78`
```java
@Deprecated
default void generate(Sink sink, Locale locale) throws MavenReportException {
generate(sink, null, locale); // -> multi-page overload
}
default void generate(Sink sink, SinkFactory sinkFactory, Locale locale)
throws MavenReportException {
generate(sink, locale); // -> single-page overload
}
```
### Impact
Any `MavenReport` implementation that overrides neither overload causes a
`StackOverflowError` when the report is generated. This is a denial-of-service
/ crash for the Maven report runner. The previous contract made `generate`
abstract, so this is a runtime regression introduced by making both methods
`default`. The Javadoc states an implementation "must override at least one of
them", but nothing enforces this at compile time or fails fast at runtime.
### Steps to reproduce
1. Implement `MavenReport` without overriding either `generate(...)` method.
2. Call `generate(sink, null, locale)` (or `generate(sink, locale)`).
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.:
```java
default void generate(Sink sink, SinkFactory sinkFactory, Locale locale)
throws MavenReportException {
throw new MavenReportException("This report does not implement
generate(...)");
}
```
### Test gap
`MavenReportTest` only covers implementations that override exactly one
overload; it never exercises an implementation that overrides neither, which is
the case that overflows.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]