Polish "Fix handling of empty/null arguments"
Closes gh-9916
This commit is contained in:
parent
0867ac5777
commit
8351042469
|
|
@ -18,11 +18,10 @@ package org.springframework.boot.maven;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.codehaus.plexus.util.cli.CommandLineUtils;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Parse and expose arguments specified in a single string.
|
||||
*
|
||||
|
|
@ -41,7 +40,7 @@ class RunArguments {
|
|||
|
||||
RunArguments(String[] args) {
|
||||
if (args != null) {
|
||||
Arrays.stream(args).filter(StringUtils::hasLength).forEach(this.args::add);
|
||||
Arrays.stream(args).filter(Objects::nonNull).forEach(this.args::add);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -43,9 +43,16 @@ public class RunArgumentsTests {
|
|||
|
||||
@Test
|
||||
public void parseArrayContainingNullValue() {
|
||||
String[] args = new RunArguments(new String[]{null}).asArray();
|
||||
String[] args = new RunArguments(new String[]{"foo", null, "bar"}).asArray();
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args.length).isEqualTo(0);
|
||||
assertThat(args).containsOnly("foo", "bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseArrayContainingEmptyValue() {
|
||||
String[] args = new RunArguments(new String[]{"foo", "", "bar"}).asArray();
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args).containsOnly("foo", "", "bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in New Issue