Skip to content

Doc: Avoid deadlock in @PostConstruct through SmartInitializingSingleton or ContextRefreshedEvent #25074

@izeye

Description

@izeye

Affects: 5.2.6.RELEASE

The following scenario triggers deadlock:

  • Run non-main threads that invoke a method of @Repository bean in @PostConstruct block.
  • The method throws an exception.
  • Wait the non-main threads to be completed in @PostConstruct block.

This is a sample project to demonstrate it: https://github.com/izeye/spring-boot-throwaway-branches/tree/post-construct-deadlock

Just running it will trigger deadlock.

I'm not sure if this is unsupported usage or bug.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions