Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling System.exit() from within ContextRefreshedEvent listener causes a deadlock #25496

Closed
notjustacoder opened this issue Mar 4, 2021 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@notjustacoder
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 4, 2021
@wilkinsona
Copy link
Member

Duplicates #23625 (comment).

@wilkinsona wilkinsona added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants