Skip to content

Race condition between AbstractApplicationContext.close() and Spring's shutdownHook [SPR-6793] #11459

@spring-projects-issues

Description

@spring-projects-issues

Liu, Yinwei David opened SPR-6793 and commented

In Spring's AbstractApplicationContext.registerShutdownHook() , it will register a shutdownhook to jvm. however, this shutdownhook is not threadsafe.

If we call AbstractApplicationContext.close(), it will stop all lifecycle beans in its context. however, as soon as all non-daemon threads have been stopped during applictioncontext.close(), jvm will shutdown itself and call shutdownhooks.

The issue is that AbstractApplicationContext.close() will also try to remove the shutdownhook from jvm, so close() will throw one exception java.lang.IllegalStateException: Shutdown in progress.

Could spring fix this issue? thanks.


Affects: 3.0 GA

Attachments:

Referenced from: commits 03e9e45, 82178b8

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions