spring-projects / spring-projects/spring-boot
Dev tools causes misconfigured command-line application to exit with 0
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 81.5k
- Forks
- 42.7k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 65
Description
I have a really simple spring application that's misconfigured:
@SpringBootApplication()
public class SimpleApplication implements CommandLineRunner {
public static void main(String[] args) {
var ctx = SpringApplication.run(SimpleApplication.class, args);
System.exit(SpringApplication.exit(ctx));
}
public static class MyObject {}
//Oops - No bean provided!!!
@Autowired MyObject myObject;
@Override public void run(String... args) { }
}
I get the following error (in intellij):
...
Consider defining a bean of type 'test.app.SimpleApplication$MyObject' in your configuration.
Process finished with exit code 1
Which is what I'd expect.
If I add the spring-boot-devtools dependency in maven:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
Then I get the following:
...
Consider defining a bean of type 'test.app.SimpleApplication$MyObject' in your configuration.
Process finished with exit code 0
It seems that adding this package causes spring boot to have the wrong return codes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the SpringApplication.run and SpringApplication.exit flow in the provided CommandLineRunner example, comparing behavior with and without spring-boot-devtools. Reproduce the missing-bean failure in both configurations and trace how the exit code is determined; done means the misconfigured application returns the expected nonzero code in both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100