spring-projects / spring-shell

Spring based shell
http://projects.spring.io/spring-shell/
Apache License 2.0
723 stars 395 forks source link

ExitCodeAutoConfiguration doesn't map CommandParserExceptionsException #961

Closed jvalkeal closed 8 months ago

jvalkeal commented 8 months ago

Boot upgrade in #952.

There is a change between spring-boot 3.2.0 and 3.2.1 in its runner logic where exception is no longer wrapped in IllegalStateException.

In below code we used to check cause assuming actual exception is CommandExecution.CommandParserExceptionsException.

https://github.com/spring-projects/spring-shell/blob/cb8f44ff633fe3d23efc0d4c32ca3111ab8b5bd3/spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/ExitCodeAutoConfiguration.java#L62-L64

We can mitigate this by checking both exception itself and it's cause(in case user don't compile against the spring-boot version spring-shell is testing).

This also happens with spring-shell 3.1.x as change in spring-boot was backported into 3.1.7.

jvalkeal commented 8 months ago

A bit easier to see from a debugger.

boot 3.2.1: spring-shell-exit-boot-321

boot 3.2.0: spring-shell-exit-boot-320