-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Dev tools causes misconfigured command-line application to exit with 0 #28541
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
Comments
Here's my full maven config: <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>springboot-test</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>13</maven.compiler.source>
<maven.compiler.target>13</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.5.5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- This dependency causes the issue -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
</dependencies>
</project> |
Ideally, in this case it should investigate the target of the exception and match it |
#26894 is in a similar area. |
@cdmatta @wilkinsona |
@msmerc @cdmatta @wilkinsona I think this situation is not a bug, isn't it ? |
If this is the intended behavior then I think spring-boot-devtools needs to inform the user that it's changed the exit code! Otherwise this is very non-obvious. Took me ages to track down the culprit. |
It looks like a bug to me. |
@wilkinsona @msmerc 1、The first is to set SilentExitExceptionHandler in Line 139 in 3478e19
2、Suspend the main thread at Line 296 in 3478e19
3、Handle the error obtained in Lines 262 to 273 in 3478e19
4、When we track Line 180 in 3478e19
5、At this time, the SilentExitExceptionHandler of the main thread handles SilentExitException and silently terminates the JVM Lines 37 to 49 in 16f54d2
I think devtool does not classify and actively handle the exceptions generated by the child threads, but chooses to return the exception information through the log listener, and chooses to silently end the program. |
@wilkinsona If this logic is unreasonable and I want to solve it, please give some guidance. |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
@wilkinsona I'm not quite sure I understand. Obviously there's no intention for the app to be misconfigured! Our app has multiple modules. Basically one webapp and a bunch of supporting CommandLineRunner utilities. These modules all had common dependencies (including DevTools) - arguably this is incorrect since the devtools only make sense for the webapp, but it's hardly something non-spring-experts would be aware of. We have a test that validates the spring configuration by running one of the spring command line utils on the code during a continuous integration stage. Although the app was misconfigured, the test was passing because the exit was 0, so our test wasn't picking up configuration issues. The other problem is that it's very non-obvious that the devtools are the issue. There's nothing in the output telling you that devtools is changing the exit code. |
Thanks, @msmerc. Knowing if the usage is accidental or if there was a usecase that we have overlooked is valuable in helping us to prioritise a fix. If there was a usecase that we have overlooked, recommending that you avoid using dev tools in a command-line app would not have been very helpful. |
I have a really simple spring application that's misconfigured:
I get the following error (in intellij):
Which is what I'd expect.
If I add the
spring-boot-devtools
dependency in maven:Then I get the following:
It seems that adding this package causes spring boot to have the wrong return codes.
The text was updated successfully, but these errors were encountered: