Skip to content

Spring failed to start Circular SmartLifecycle dependencies [SPR-7266] #11925

@spring-projects-issues

Description

@spring-projects-issues

Liu, Yinwei David opened SPR-7266 and commented

If we have two beans Bar and Foo. Both beans implement SmartLifecycle, and they reference to each other. Spring will not be able to get started because it repetitively calls itself in DefaultLifecycleProcessor to start itself.

public class FooImpl implements Foo, SmartLifecycle{
Bar _bar;
public int getPhase(){ return 1; }
...
}
public class BarImpl implements Bar, SmartLifecycle
{
Foo _foo;
public int getPhase() { return 2; }
...
}

What I expected is that the bean FooImpl start first, and then Bar gets started.

However, Spring is not able to resolve it so that we get exception StactkOverflow. I tried to override DefaultLifecycleProcessor to make it not start bean twice, then spring can successfully get started.

Can we fix this bug in DefaultLifecycleProcessor to be able to resolve the circular reference? thanks


Affects: 3.0.2

Attachments:

Referenced from: commits 65622bd

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