-
Notifications
You must be signed in to change notification settings - Fork 37.7k
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
Support command line arguments with an empty value #24464
Comments
What happens if you leave out the
Does |
FWIW, comparing the out-of-the-box implementations of The test for @Test
void withOptionalArg_andArgIsEmpty() {
OptionParser parser = new OptionParser();
parser.accepts("foo").withOptionalArg();
OptionSet options = parser.parse("--foo=");
PropertySource<?> ps = new JOptCommandLinePropertySource(options);
assertThat(ps.containsProperty("foo")).isTrue();
assertThat(ps.getProperty("foo")).isEqualTo("");
} Whereas, the test for @Test
void withOptionalArg_andArgIsEmpty() {
EnumerablePropertySource<?> ps = new SimpleCommandLinePropertySource("--foo=");
assertThat(ps.containsProperty("foo")).isTrue();
assertThat(ps.getProperty("foo")).isEqualTo("");
} Thus, we could consider removing the non-empty check in |
Yes, But the way to pass an argument value should not depend upon whether it is empty or not. Actually, I created this issue because Spring Cloud Stream hits it when trying to pass empty properties while creating a binder application: |
Glad to hear that works at least as a workaround. Thanks for the feedback.
I agree, and we will address that for For previous versions of Spring Framework, please use the aforementioned workaround. |
With Spring Boot, you can override application properties using command line arguments like so:
This, however, fails when you try to pass an empty value:
Since an empty string is a legal value for an application property, there seems to be no good reason to reject command line arguments with an empty value.
A real-world example is Kafka's
ssl.endpoint.identification.algorithm
which has to be set to an empty string to disable host name verification.The text was updated successfully, but these errors were encountered: