Problem
I've come across a side of effect of this fix. If you've something like below -
public void onApplicationEvent(ContextRefreshedEvent event) {
// some code
System.exit(0);
}
This creates a deadlock as the shutdown hook is created first and it acquires the very lock which System.exit(0) tries acquiring later on. I'm not sure if using System.exit(0) in context refreshed event listener would be discouraged for this reason.
Comment From: wilkinsona
Duplicates https://github.com/spring-projects/spring-boot/issues/23625#issuecomment-790847007.