Reactive firestore repositories cause bean dependency cycle when used in a MeterBinder
See original GitHub issueSpring Boot version: 2.6.7 Spring cloud gcp version (BOM): 3.2.1
We seem to be running into an issue similar to https://github.com/spring-projects/spring-boot/issues/27591.
We recently migrated one of our metric sources to use a spring data repository. This seems to cause a bean dependency cycle caused by startupTimeMetrics
(See attached bean cycle screenshot).
Looks to me like Firestore repositories cause the metrics stack to be initialized, which then causes a cycle if the repository is used in a Meterbinder.
A project to reproduce the issue is located at https://github.com/JakobFels/FirestoreMetricsReproducer
Issue Analytics
- State:
- Created a year ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Circular Dependencies in Spring - Baeldung
A quick writeup on dealing with circular dependencies in Spring: how they occur ... cycle is by injecting a dependency using @Autowired on...
Read more >Spring Security circular bean dependency - Stack Overflow
One possible solution is to edit the source code of some classes to be configured by setters rather than constructors. Alternatively, avoid ...
Read more >How to resolve circular dependencies in Spring? - LogicBig
Circular dependencies are the scenarios when two or more beans try to inject each other via constructor.
Read more >Circular Dependencies in Spring - Websparrow
Circular dependencies are the issue caused during dependency injection ... of some of the beans in the application context form a cycle: ...
Read more >Unresolved circular dependency in spring dependency injection
This means that said other beans do not use the final version of the bean. This is often the result of over-eager type...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, @elefeint. I’ve re-opened the Spring Boot issue.
Right; because spring-data-jpa does not implement
RepositoryFactoryBeanSupport
. But spring-data-r2dbc does, so it makes for a good reproducer.https://github.com/elefeint/FirestoreMetricsReproducer/tree/h2-reproducer shows the same issue with H2 R2DBC driver.
While implementing
MeterBinder
works in principle, when combined withRepositoryFactoryBeanSupport
, and likely other event-publishing infrastructure, the end-user application ends up creating a cycle.