Eberhard Wolff opened SPR-12317 and commented
In the attached project we have
- Java Configuration class A. It uses a bean of type Z that is
@Autowired. It provides a bean of type B.
- Java Configuration class AStrich provides the bean of type Z and has a bean of type B
@Autowired.
So the two Java Configuration classes are in a cyclic dependency due to the Beans of type B and Z.
When bean B in A is created Z is not injected - which IMHO is wrong. It should be possible to rely on Spring autowiring all fields before a bean is created. Note that the problem disappears if B is not injected in AStrich any more and no cyclic dependency is present.
This might look like a corner case but at my client it caused some headaches during an XML->JavaConfig migration.
The attached project can be run with mvn test and fails due to the bug.
Affects: 4.1.1
Attachments:
Issue Links:
2 votes, 6 watchers
Eberhard Wolff opened SPR-12317 and commented
In the attached project we have
@Autowired. It provides a bean of type B.@Autowired.So the two Java Configuration classes are in a cyclic dependency due to the Beans of type B and Z.
When bean B in A is created Z is not injected - which IMHO is wrong. It should be possible to rely on Spring autowiring all fields before a bean is created. Note that the problem disappears if B is not injected in AStrich any more and no cyclic dependency is present.
This might look like a corner case but at my client it caused some headaches during an XML->JavaConfig migration.
The attached project can be run with mvn test and fails due to the bug.
Affects: 4.1.1
Attachments:
Issue Links:
@Beanmethod leads to early call (pre injection)2 votes, 6 watchers