elharo opened a new pull request, #93:
URL: https://github.com/apache/maven-reporting-api/pull/93

   ## What
   
   `MavenReport.getOutputPath()` and the deprecated `getOutputName()` are both 
`default` methods that delegate to each other. An implementation that overrides 
neither recurses forever and fails with `StackOverflowError` as soon as the 
report output path is resolved.
   
   ## Why
   
   Because both methods are `default`, a `MavenReport` implementation is 
allowed to override neither (the interface still requires the other abstract 
methods), so the failure is reachable from ordinary code and crashes the report 
generation instead of reporting a clear error. See #92.
   
   ## How
   
   `getOutputPath()` now fails fast with an `UnsupportedOperationException` 
when neither method is overridden. It still delegates to `getOutputName()` when 
that method is overridden, so implementations overriding **either** method keep 
working:
   
   - override `getOutputPath()` only -> `getOutputName()` delegates to it
   - override `getOutputName()` only -> `getOutputPath()` delegates to it
   - override neither -> clear `UnsupportedOperationException`, no recursion
   
   The override check uses `getClass().getMethod("getOutputName").isDefault()`, 
which avoids changing either method's signature or default-ness.
   
   ## Tests
   
   Added four tests to `MavenReportTest` covering the full matrix (`StubReport` 
was factored out so the output path/name can be left unimplemented). The two 
"neither implemented" tests fail with `StackOverflowError` before the fix and 
pass afterwards; the two delegation tests guard the existing behavior.
   
   ```
   Tests run: 6, Failures: 0, Errors: 0, Skipped: 0
   ```
   
   `mvn verify` (checkstyle, RAT, tests) passes.
   
   Note: the analogous mutual recursion between the `default` `generate(...)` 
overloads is tracked separately in #91.
   
   Fixes #92
   
   ---
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](https://www.apache.org/licenses/LICENSE-2.0)
   check one of the following:
   
   - [x] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [ ] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   


-- 
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]

Reply via email to