question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Quarkus:dev is unkillable if StartupEvent has infinite loop

See original GitHub issue

To 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:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
stuartwdouglascommented, Oct 27, 2020

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.

0reactions
stuartwdouglascommented, Nov 2, 2020

Btw, just killing the process right away (without a grace period) on CTRL+C doesn’t seem like a good idea since that would prevent shutdown hooks from running (e.g. see #12577).

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found