I have wrote a piece of java code for a springboot controller:
@GetMapping("/exception")
public void exceptionInThread() {
Thread newThread = new Thread(new Runnable() {
@Override
public void run() {
throw new NullPointerException();
}
});
log.info("daemon: {}, threadGroup: {}, defaultUncaught: {}",
newThread.isDaemon(),
newThread.getThreadGroup(),
Thread.getDefaultUncaughtExceptionHandler()
);
newThread.start();
}
After I compile the project, I run java -jar application.jar and call restapi (http://localhost:8080/exception). I can get a NPE trace.
But in our production environment, we compile sprintboot in to a WAR and put the WAR into Tomcat's webapps directory. Then happens the weird thing. When I triggered the restapi to run the method, there is not any NPE trace popped out. As if there is a default uncaught exception handler set underneath which consume the exception without a trace. But the application log I printed is all the same in both environments (sprintboot application & tomcat webapp):
2017-07-19 10:35:33.479 INFO 38070 --- [nio-8080-exec-1] com.ruan.restful.ThreadController : daemon: true, threadGroup: java.lang.ThreadGroup[name=main,maxpri=10], defaultUncaught: null
That confuses me a lot. Is there something Tomcat set for me? Can you guys give me some pointers?