question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reactive firestore repositories cause bean dependency cycle when used in a MeterBinder

See original GitHub issue

Spring 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). image

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:closed
  • Created a year ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
wilkinsonacommented, Aug 9, 2022

Thanks, @elefeint. I’ve re-opened the Spring Boot issue.

0reactions
elefeintcommented, Aug 9, 2022

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 with RepositoryFactoryBeanSupport, and likely other event-publishing infrastructure, the end-user application ends up creating a cycle.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found