-
Notifications
You must be signed in to change notification settings - Fork 41.3k
Fix to allow empty argument in maven plugin. Fixes gh-9713 #9916
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
Conversation
@bjornlindstrom Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@bjornlindstrom Thank you for signing the Contributor License Agreement! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bjornlindstrom Thanks very much for the contribution. I've suggested one small change that might make the code a little more concise.
|
||
RunArguments(String arguments) { | ||
this(parseArgs(arguments)); | ||
} | ||
|
||
RunArguments(String[] args) { | ||
this.args = new LinkedList<>(Arrays.asList(args)); | ||
if (args != null) { | ||
this.args.addAll(Arrays.stream(args).filter(s -> s != null && !"".equals(s)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably replace the filter with hasLength
from org.springframework.util.StringUtils
. A forEach
might also be a bit more concise than the collector:
Arrays.stream(args).filter(StringUtils::hasLength).forEach(this.args::add);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, that is a better solution,
* pr/9916: Polish "Fix handling of empty/null arguments" Fix handling of empty/null arguments
@@ -31,14 +32,17 @@ | |||
|
|||
private static final String[] NO_ARGS = {}; | |||
|
|||
private final LinkedList<String> args; | |||
private final LinkedList<String> args = new LinkedList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better to initialize instance variables inside constructors instead of at the declaration level
Change so the application can start even if the maven plugin xml configuration contains an empty argument element. #9713