Breakpoint at "throw new SilentExitException()" in Eclipse + Spring Boot
Solution 1
This is unfortunately a know issue with the new spring-boot-devtools
module (see https://github.com/spring-projects/spring-boot/issues/3100). We use this trick to kill the main thread so that we can replace it with a re-loadable version. So far I've not found a way to prevent the debug breakpoint from triggering.
For now, you can toggle the "suspend execution on uncaught exceptions" checkbox in Java -> Debug preferences to prevent it from happening.
Solution 2
Add the property as a VM argument:
-Dspring.devtools.restart.enabled=false
That way you don't have to change your code, as it is the case when using:
System.setProperty("spring.devtools.restart.enabled", "false");
Solution 3
As Eclipse on Debug mode already allows limited hotpatching, I find the reloader to be counterproductive most of the time and so I decided to disable it by:
System.setProperty("spring.devtools.restart.enabled", "false");
Since that exception is thrown by the reloader, this also solves this issue. Note that you'll have to use the System.setProperty
method instead of setting it in application.properties
.
Solution 4
My workaround:
public static void main(String[] args) {
try {
SpringApplication.run(App.class, args);
} catch (Throwable e) {
if(e.getClass().getName().contains("SilentExitException")) {
LOGGER.debug("Spring is restarting the main thread - See spring-boot-devtools");
} else {
LOGGER.error("Application crashed!", e);
}
}
}
It doesn't matter that we ignore the SilentExitException
because the devtools are just restarting the instance with a SilentExitException
which isn't very silent. This try block will silence it...
I had to use text matching on the class as the SilentExitException
is private in SilentExitExceptionHandler
.
It doesn't solve your problem with the breakpoint...
Solution 5
Delete these to Unknown Exceptions & it won't break there:
Unfortunately, I haven't found a way for this to be permanent, but it should last till the next time you restart eclipse.
Bruno De Freitas Barros
IT Analyst at Universidade Federal de Alagoas.
Updated on January 05, 2022Comments
-
Bruno De Freitas Barros over 2 years
Every time I run my Spring Boot project on debug mode in Eclipse IDE (Spring Tool Suite), the thread stops at
throw new SilentExitException();
line even without a breakpoint.Is there some solution to avoid this behavior?
org.springframework.boot.devtools.restart.SilentExitExceptionHandler.exitCurrentThread() (line 53):
public static void exitCurrentThread() { throw new SilentExitException(); }
This starts happening after upgrade to 1.3.0 Milestones.
Spring Tool Suite
Version: 3.7.0.RELEASE Build Id: 201506290649
Platform:
Eclipse Luna SR2 (4.4.2)
-
Stefan Falk over 7 yearsThis issue is still present unfortunately.
-
nabster over 4 yearsThis issue is still present.
-
Sachin Sharma over 4 yearsstill present :p
-
sivakadi over 4 yearsOut of other options, I used this. Thanks a lot for making my day!
-
src3369 about 4 yearsThis issue still present. using Eclipse Version: 2019-06 (4.12.0) & spring-boot 2.0.6. Window-> Preferences -.> Java -> Debig -> unchecked "Suspend execution on uncaught exceptions"
-
HDJEMAI about 4 yearsStill present with Eclipse version 2020-03 (4.15.0) & spring-boot 2.3.1
-
Shramik over 3 yearsStill present on spring boot 2.4.0 and eclipse Version: 2020-06 (4.16.0)
-
MBach about 3 yearsWell, you know, still present
-
Abhilash over 2 yearsWorked for me! Thanks :)
-
ScrappyDev over 2 yearsSetting the scope to runtime, didn't work for me.
-
borgmater over 2 yearsAnd all of a sudden, it became present for me too ..
-
Ivan Rodrigues over 2 yearsThank u for share!!! I used in the main method with: System.setProperty("spring.devtools.restart.enabled", "false");
-
Voronin almost 2 yearsSpring Boot 2.7.1 and the issue is still present....