Quarkus:dev is unkillable if StartupEvent has infinite loop
See original GitHub issueTo reproduce, put this in a quarkus project:
@ApplicationScoped
public class FactorioDataGenerator {
public void generateDemoData(@Observes StartupEvent startupEvent) {
while (true) {
// If needed Do something to avoid this code getting optimized away.
}
}
}
and then run mvn quarkus:dev
in the terminal (I used the IntelliJ terminal). As your computer starts acting wierd, hit ctrl-c
, which will give you back your terminal prompt. Then look at your OS task navigator. Notice that a process is still running at full CPU usage and it refused to die: that ctrl-c didn’t kill it.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
System.exit(1) won’t exit if there is a non-daemon thread stuck in an infinite loop. Your only options are Thread.stop() which is deprecated for very good reason, and kill -9.
We could use a shutdown hook in Maven to wait X seconds then kill the process I guess. It’s only dev mode, so that might be ok.
Exactly, from a production point of view you just can’t really do this. You can have an infinite loop in other threads as well, you just can’t guard against this.
I am going to close this, basically you can only have one of the following guaranteed:
a) That all shutdown code that should run is being run (i.e. that you can do a clean shutdown) b) That shutdown completes in a given time period
I think it is more important to guarantee a) than to try and do b) to guard against developer mistakes.