Skip to content

Scope repeated Client resolution warning to the application context - #1417

Open
kdelay wants to merge 1 commit into
spring-cloud:mainfrom
kdelay:fix/scope-client-init-warning-to-application-context
Open

Scope repeated Client resolution warning to the application context#1417
kdelay wants to merge 1 commit into
spring-cloud:mainfrom
kdelay:fix/scope-client-init-warning-to-application-context

Conversation

@kdelay

@kdelay kdelay commented Sep 11, 2026

Copy link
Copy Markdown

FeignClientFactoryBean tracks resolved context ids in a private static final Set, so the "is being initialized more than once. Ensure the Client bean is Singleton scoped" warning is JVM-wide and never cleared.

A second ApplicationContext in the same JVM, which is normal in a Spring Boot test suite or after @DirtiesContext, resolves the Client for a context id exactly once and still warns. The advice is wrong there: the bean is singleton scoped.

The detection is unchanged. The set is now per application context, keyed weakly on the owning BeanFactory so closed contexts are not retained.

FeignClientFactoryBeanTests covers both sides: a second resolution inside one context still warns, two separate contexts do not. The second test fails on main and passes here.

The set of already resolved context ids was JVM wide and never cleared, so a
second ApplicationContext in the same JVM warned about repeated Client
initialization even though every context resolved the client exactly once.
Track the ids per application context instead, keyed weakly on the owning
BeanFactory so closed contexts are not retained.

Signed-off-by: kdelay <kdelay20@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants