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

PublisherAnnotationBeanPostProcessor has dependency on itself, breaks when using Spring Boot #3694

Closed
kewne opened this issue Dec 14, 2021 · 2 comments · Fixed by #3695
Closed
Assignees
Milestone

Comments

@kewne
Copy link

kewne commented Dec 14, 2021

If I declare the following configuration class in a Spring Boot application:

@Configuration
@EnablePublisher
public class IntegrationConfiguration

the application fails to start because the instantiated PublisherAnnotationBeanPostProcessor requests itself as a bean.

By default, Spring Boot disallows this unless you set spring.main.allow-circular-references: true, which IMO you shouldn't do without a good reason.

Expected behavior

No circular dependency error should be raised.

PublisherAnnotationBeanPostProcessor could still check for a duplicate with an explicit bean request;
perhaps just checking whether a definition exists would be enough.

@artembilan
Copy link
Member

Confirmed:

2021-12-14 10:18:17.182 ERROR 3896 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The dependencies of some of the beans in the application context form a cycle:

┌──->──┐
|  org.springframework.integration.internalPublisherAnnotationBeanPostProcessor
└──<-──┘

@artembilan artembilan added this to the 5.5.7 milestone Dec 14, 2021
@artembilan artembilan self-assigned this Dec 14, 2021
artembilan added a commit to artembilan/spring-integration that referenced this issue Dec 14, 2021
Fixes spring-projects#3694

* Move check for `PublisherAnnotationBeanPostProcessor` bean into the
`SmartInitializingSingleton.afterSingletonsInstantiated()` to break a circular dependency revealed
in the `InitializingBean.afterPropertiesSet()`
garyrussell pushed a commit that referenced this issue Dec 14, 2021
* GH-3694: Resolve circular dep in PublisherAnnBPP

Fixes #3694

* Move check for `PublisherAnnotationBeanPostProcessor` bean into the
`SmartInitializingSingleton.afterSingletonsInstantiated()` to break a circular dependency revealed
in the `InitializingBean.afterPropertiesSet()`

* * Fix unused import
@kewne
Copy link
Author

kewne commented Feb 8, 2022

Just wanted to leave a (late) note of appreciation for taking the time to fix this, thank you very much 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants