Skip to content

Conversation

@czpilar
Copy link
Contributor

@czpilar czpilar commented Jan 30, 2026

Resolves #1304

Signed-off-by: David Pilar <david@czpilar.net>
@fmbenhassine fmbenhassine merged commit af799ed into spring-projects:main Jan 30, 2026
2 checks passed
@czpilar czpilar deleted the patches/1304-boolean-options-without-values branch January 30, 2026 21:31
@fmbenhassine
Copy link
Contributor

fmbenhassine commented Jan 31, 2026

Hi @czpilar ,

I was doing my last checks before releasing 4.0.1 and I noticed a regression which seems to be related to this PR. When I ask for help for a command with -h or --help, it fails with the following error (from the spring-shell-sample-spring-boot sample with debug mode enabled):

shell:>hello -h
Error while parsing command: Option '-h' requires a value
java.lang.IllegalArgumentException: Option '-h' requires a value
	at org.springframework.shell.core.command.DefaultCommandParser.parse(DefaultCommandParser.java:107)
	at org.springframework.shell.core.InteractiveShellRunner.run(InteractiveShellRunner.java:96)
	at org.springframework.shell.core.autoconfigure.ShellRunnerAutoConfiguration.lambda$springShellApplicationRunner$0(ShellRunnerAutoConfiguration.java:39)
	at org.springframework.boot.SpringApplication.lambda$callRunner$0(SpringApplication.java:788)
	at org.springframework.util.function.ThrowingConsumer$1.acceptWithException(ThrowingConsumer.java:82)
	at org.springframework.util.function.ThrowingConsumer.accept(ThrowingConsumer.java:60)
	at org.springframework.util.function.ThrowingConsumer$1.accept(ThrowingConsumer.java:86)
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:800)
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:788)
	at org.springframework.boot.SpringApplication.lambda$callRunners$0(SpringApplication.java:776)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:776)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:328)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1365)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
	at org.springframework.shell.samples.helloworld.boot.SpringShellApplication.main(SpringShellApplication.java:12)
shell:>

I see no need to create a new issue for that unless you think this error is not related to this PR. I will check on my side as well before releasing.

@czpilar
Copy link
Contributor Author

czpilar commented Jan 31, 2026

@fmbenhassine will look at this...

@czpilar
Copy link
Contributor Author

czpilar commented Jan 31, 2026

The regression was introduced in this commit:
84abfda3

@czpilar
Copy link
Contributor Author

czpilar commented Jan 31, 2026

@fmbenhassine here is a quick fix in PR #1307 + added test

@fmbenhassine
Copy link
Contributor

The regression was introduced in this commit: 84abfda3

Indeed, the code block at which the error happens which was lastly changed in this PR made me think it was related to this PR. Sorry for the noise.. Now I will go hide under my rock 🙈

here is a quick fix in PR #1307

Thank you for the quick fix! That was it. I seem to have inadvertently removed it in that commit. I will put it back. I am still bothered with the lack of test coverage for these cases (I will plan some improvements after 4.0.1).

@czpilar
Copy link
Contributor Author

czpilar commented Jan 31, 2026

Sorry for the noise.. Now I will go hide under my rock 🙈

That is OK. No problem—these types of things happen. I was able to quickly identify the problem.

So I've added there also test to prevent deletion of the code in future ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve default parser to accept boolean options without values

2 participants