Skip to content

Commit fd13c99

Browse files
committed
Fixed accidental use of String.isEmpty in SimpleCommandLineArgsParser
Issue: SPR-11321
1 parent 1f60738 commit fd13c99

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -52,9 +52,9 @@
5252
class SimpleCommandLineArgsParser {
5353

5454
/**
55-
* Parse the given {@code String} array based on the rules described {@linkplain
56-
* SimpleCommandLineArgsParser above}, returning a fully-populated
57-
* {@link CommandLineArgs} object.
55+
* Parse the given {@code String} array based on the rules described
56+
* {@linkplain SimpleCommandLineArgsParser above}, returning a
57+
* fully-populated {@link CommandLineArgs} object.
5858
* @param args command line arguments, typically from a {@code main()} method
5959
*/
6060
public CommandLineArgs parse(String... args) {
@@ -65,13 +65,13 @@ public CommandLineArgs parse(String... args) {
6565
String optionName;
6666
String optionValue = null;
6767
if (optionText.contains("=")) {
68-
optionName = optionText.substring(0, optionText.indexOf("="));
69-
optionValue = optionText.substring(optionText.indexOf("=")+1, optionText.length());
68+
optionName = optionText.substring(0, optionText.indexOf('='));
69+
optionValue = optionText.substring(optionText.indexOf('=') + 1, optionText.length());
7070
}
7171
else {
7272
optionName = optionText;
7373
}
74-
if (optionName.isEmpty() || (optionValue != null && optionValue.isEmpty())) {
74+
if (optionName.length() == 0 || (optionValue != null && optionValue.length() == 0)) {
7575
throw new IllegalArgumentException("Invalid argument syntax: " + arg);
7676
}
7777
commandLineArgs.addOptionArg(optionName, optionValue);

0 commit comments

Comments
 (0)