Skip to content

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

Closed
wants to merge 3 commits into from

Conversation

bjornlindstrom
Copy link
Contributor

Change so the application can start even if the maven plugin xml configuration contains an empty argument element. #9713

@pivotal-issuemaster
Copy link

@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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 31, 2017
@pivotal-issuemaster
Copy link

@bjornlindstrom Thank you for signing the Contributor License Agreement!

Copy link
Member

@philwebb philwebb left a 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))
Copy link
Member

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);

Copy link
Contributor Author

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,

@philwebb philwebb added priority: normal type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 31, 2017
@philwebb philwebb added this to the 2.0.0.M5 milestone Jul 31, 2017
@snicoll snicoll self-assigned this Sep 19, 2017
snicoll pushed a commit that referenced this pull request Sep 19, 2017
@snicoll snicoll closed this in 8351042 Sep 19, 2017
snicoll added a commit that referenced this pull request Sep 19, 2017
* 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<>();

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants