Breakpoint at "throw new SilentExitException()" in Eclipse + Spring Boot

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)
1

10 Answers

This is unfortunately a know issue with the new spring-boot-devtools module (see ). 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.

11

Add the property as a VM argument:

-Dspring.devtools.restart.enabled=false

enter image description here

That way you don't have to change your code, as it is the case when using:

System.setProperty("spring.devtools.restart.enabled", "false");
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");

Reference:

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.

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...

Delete these to Unknown Exceptions & it won't break there:enter image description here

Unfortunately, I haven't found a way for this to be permanent, but it should last till the next time you restart eclipse.

I had same issue while running spring boot project. I found TRY CATCH block used in Main method.

Remove the try catch block run the code. that error will not come again. like below:

public static void main(String[] args) {

 SpringApplication.run(TrewAuthApplication.class, args);
}

Set this in your application.properties file to true.

spring.devtools.restart.enabled=false

Also go sure that if you use a spring cloud config server, there is no propertie file that enables this.

1

Try to run devtools at scope runtime:

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope>
</dependency>
2

My workaround in Kotlin:

@JvmStatic
fun main(args: Array<String>) { val app = SpringApplication(Application::class.java) try { app.run(*args) } catch (e: Exception) { preventNonNullExitCodeOnSilentExitException(e) }
}
private fun preventNonNullExitCodeOnSilentExitException(e: Exception) { if (e.toString().contains("SilentExitException")) { log.info("Ignoring Silent Exit Exception...") e.printStackTrace() return } throw e
}

In the meantime this seems fixed when you use Spring Tools Suite latest. BUT when you START your application the exception still occurs and the debugger stops. Just after the first live-/hot-reload it will be ignored by STS. If you take a look at Preferences - Spring, there is a flag for this exception.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like