From c463b937b8887b43017634124fa28e09c703bcb4 Mon Sep 17 00:00:00 2001 From: puppy4c Date: Sat, 18 Jan 2025 10:53:24 +0800 Subject: [PATCH] Update Javadoc for SimpleCommandLinePropertySource For ComandLineArgs, supplying the same option multiple times with different values is valid, and the values will be stored in a List. This commit also updates the Javadoc for SimpleCommandLineArgsParser. See gh-34282 Signed-off-by: puppy4c --- .../core/env/SimpleCommandLineArgsParser.java | 9 +++++---- .../core/env/SimpleCommandLinePropertySource.java | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java b/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java index 7f35d1b3c50..98b80011f5f 100644 --- a/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java +++ b/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java @@ -28,7 +28,8 @@ package org.springframework.core.env; *

That is, options must be prefixed with "{@code --}" and may or may not * specify a value. If a value is specified, the name and value must be separated * without spaces by an equals sign ("="). The value may optionally be - * an empty string. + * an empty string. if the option is present and has multiple values (e. g. "--foo=bar --foo=baz"), +* the values are parsed as a collection. * *

Valid examples of option arguments

*
@@ -37,14 +38,14 @@ package org.springframework.core.env;
  * --foo=""
  * --foo=bar
  * --foo="bar then baz"
- * --foo=bar,baz,biz
+ * --foo=bar,baz,biz + * --foo=bar --foo=baz --foo=biz * *

Invalid examples of option arguments

*
  * -foo
  * --foo bar
- * --foo = bar
- * --foo=bar --foo=baz --foo=biz
+ * --foo = bar * *

End of option arguments

*

This parser supports the POSIX "end of options" delimiter, meaning that any diff --git a/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLinePropertySource.java b/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLinePropertySource.java index 767d9b6211f..17121c29734 100644 --- a/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLinePropertySource.java +++ b/spring-core/src/main/java/org/springframework/core/env/SimpleCommandLinePropertySource.java @@ -40,7 +40,8 @@ import org.springframework.util.StringUtils; *

That is, options must be prefixed with "{@code --}" and may or may not * specify a value. If a value is specified, the name and value must be separated * without spaces by an equals sign ("="). The value may optionally be - * an empty string. + * an empty string. if the option is present and has multiple values (e. g. "--foo=bar --foo=baz"), + * the values are parsed as a collection. * *

Valid examples of option arguments

*
@@ -49,14 +50,14 @@ import org.springframework.util.StringUtils;
  * --foo=""
  * --foo=bar
  * --foo="bar then baz"
- * --foo=bar,baz,biz
+ * --foo=bar,baz,biz + * --foo=bar --foo=baz --foo=biz * *

Invalid examples of option arguments

*
  * -foo
  * --foo bar
- * --foo = bar
- * --foo=bar --foo=baz --foo=biz
+ * --foo = bar * *

End of option arguments

*

The underlying parser supports the POSIX "end of options" delimiter, meaning