Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(doc) Simplify CompilationFailureException #19

Merged
merged 3 commits into from
Aug 2, 2019

Conversation

rhowe
Copy link
Contributor

@rhowe rhowe commented May 21, 2019

This class can be a little bit more concise.

The nullity check in longMessage() is made redundant by the lack of an equivalent check in shortMessage. CompilationFailureException is thrown in two places in AbstractCompilerMojo and both of those are guaranteed to pass a non-null object.

Whilst we're in here, remove a redundant local variable in shortMessage() and merge the StringBuilder calls onto a single line.

@rhowe rhowe force-pushed the simpler-failureexception branch from 06dc84a to cee6ad8 Compare May 26, 2019 20:23
@rhowe
Copy link
Contributor Author

rhowe commented Jun 3, 2019

Should this change have a Jira ticket?

@@ -43,13 +43,11 @@ public static String longMessage( List<CompilerMessage> messages )
{
StringBuilder sb = new StringBuilder();

if ( messages != null )
for ( CompilerMessage compilerError : messages )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use this opportunity to improve javadoc as well and to make clear that messages cannot be null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me - how's it looking now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these methods be private static or just inlined into the constructor? They have no other callers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it's not possible to inline them because of the super() call

rhowe added 2 commits June 4, 2019 08:56
If the messages list is null, this class will throw a NullPointerException in
its shortMessage() method, so having a check for a null message list in
longMessage() seems unnecessary. Remove it.
@rhowe rhowe force-pushed the simpler-failureexception branch from cee6ad8 to 8a5e02d Compare June 4, 2019 07:59
@rhowe rhowe force-pushed the simpler-failureexception branch from 8a5e02d to 83b0343 Compare June 4, 2019 08:03
@rhowe
Copy link
Contributor Author

rhowe commented Jun 4, 2019

I'm afraid the tests aren't working for me locally - master fails in the same way as this branch using javac 11.0.4 from Debian unstable's openjdk package

@rhowe
Copy link
Contributor Author

rhowe commented Jun 11, 2019

Tests passed for me on an OS X device

@rhowe
Copy link
Contributor Author

rhowe commented Aug 2, 2019

@rfscholte any love for this little cleanup?

@rfscholte rfscholte merged commit 942fe42 into apache:master Aug 2, 2019
@rfscholte
Copy link
Contributor

Jenkins was happy too, so PR is merged. Thanks for the patch!

@rhowe rhowe deleted the simpler-failureexception branch August 6, 2019 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants