Repository navigation
Conversation
Both are default methods that delegate to each other. An implementation overriding neither recursed forever and failed with StackOverflowError when the report output path was resolved. getOutputPath() now fails fast with UnsupportedOperationException when neither method is overridden, while still delegating to getOutputName() for implementations that override it. Implementations overriding either method keep working unchanged. Fixes #92
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
MavenReport.getOutputPath()and the deprecatedgetOutputName()are bothdefaultmethods that delegate to each other. An implementation that overrides neither recurses forever and fails withStackOverflowErroras soon as the report output path is resolved.Why
Because both methods are
default, aMavenReportimplementation 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 anUnsupportedOperationExceptionwhen neither method is overridden. It still delegates togetOutputName()when that method is overridden, so implementations overriding either method keep working:getOutputPath()only ->getOutputName()delegates to itgetOutputName()only ->getOutputPath()delegates to itUnsupportedOperationException, no recursionThe override check uses
getClass().getMethod("getOutputName").isDefault(), which avoids changing either method's signature or default-ness.Tests
Added four tests to
MavenReportTestcovering the full matrix (StubReportwas factored out so the output path/name can be left unimplemented). The two "neither implemented" tests fail withStackOverflowErrorbefore the fix and pass afterwards; the two delegation tests guard the existing behavior.mvn verify(checkstyle, RAT, tests) passes.Note: the analogous mutual recursion between the
defaultgenerate(...)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
check one of the following: