Skip to content

Commit 10d1ad3

Browse files
committed
Use computeIfAbsent in CommandLineArgs.addOptionArg
Signed-off-by: junhyung8795 <junhyung8795@naver.com>
1 parent 5785923 commit 10d1ad3

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

spring-core/src/main/java/org/springframework/core/env/CommandLineArgs.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ class CommandLineArgs {
4646
* without an associated value &mdash; for example, "--foo" vs. "--foo=bar".
4747
*/
4848
public void addOptionArg(String optionName, @Nullable String optionValue) {
49-
if (!this.optionArgs.containsKey(optionName)) {
50-
this.optionArgs.put(optionName, new ArrayList<>());
51-
}
49+
List<String> values = this.optionArgs.computeIfAbsent(optionName, key -> new ArrayList<>());
5250
if (optionValue != null) {
53-
this.optionArgs.get(optionName).add(optionValue);
51+
values.add(optionValue);
5452
}
5553
}
5654

0 commit comments

Comments
 (0)