Skip to content

Fix unconditional overwrite of resolved fallbackFactory in FeignClientsRegistrar#1378

Merged
ryanjbaxter merged 1 commit into
spring-cloud:4.3.xfrom
seonwooj0810:fix/issue-1367-fallback-factory-overwrite
May 27, 2026
Merged

Fix unconditional overwrite of resolved fallbackFactory in FeignClientsRegistrar#1378
ryanjbaxter merged 1 commit into
spring-cloud:4.3.xfrom
seonwooj0810:fix/issue-1367-fallback-factory-overwrite

Conversation

@seonwooj0810
Copy link
Copy Markdown
Contributor

Fixes gh-1367

Summary

FeignClientsRegistrar.eagerlyRegisterFeignClientBeanDefinition resolves the fallbackFactory attribute via ClassUtils.resolveClassName(...) when it is supplied as a String, but the very next line unconditionally re-sets the same property to the raw attribute value, discarding the resolved Class and rendering the resolution dead code:

https://github.com/spring-cloud/spring-cloud-openfeign/blob/main/spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientsRegistrar.java#L239-L244

Object fallbackFactory = attributes.get(\"fallbackFactory\");
if (fallbackFactory != null) {
    definition.addPropertyValue(\"fallbackFactory\", fallbackFactory instanceof Class ? fallbackFactory
            : ClassUtils.resolveClassName(fallbackFactory.toString(), null));
}
definition.addPropertyValue(\"fallbackFactory\", attributes.get(\"fallbackFactory\")); // unconditional overwrite

The duplicate, unconditional addPropertyValue mirrors a pattern that the same method already gets right for fallback (lines 234-238 — single conditional set, no overwrite) and that the lazy registration path also gets right (lazilyRegisterFeignClientBeanDefinition, lines 288-292). It looks unintentional.

Change

Remove the duplicate line so the resolved value survives.

Test plan

  • ./mvnw -pl spring-cloud-openfeign-core -am test -Dtest=FeignClientsRegistrarTests — 15 tests, 0 failures, 0 errors, 1 skipped (existing testFallback and testFallbackFactory still pass with the Class<?> annotation path).

@ryanjbaxter
Copy link
Copy Markdown
Contributor

Can you please sign your commit so the DCO passes?

Could you submit the PR against the 4.3.x branch?

eagerlyRegisterFeignClientBeanDefinition resolves the fallbackFactory
attribute via ClassUtils.resolveClassName when it is provided as a
String, but then unconditionally re-sets the property to the raw
attribute value, discarding the resolution. Remove the duplicate
addPropertyValue so the resolved value survives, matching the handling
already present for fallback (a few lines above) and for the lazy
registration path.

Fixes spring-cloudgh-1367

Signed-off-by: seonwoo_jung <laborlawseon@kap.kr>
@seonwooj0810 seonwooj0810 force-pushed the fix/issue-1367-fallback-factory-overwrite branch from b2cbc2f to 843e32a Compare May 27, 2026 14:06
@seonwooj0810 seonwooj0810 changed the base branch from main to 4.3.x May 27, 2026 14:07
@seonwooj0810
Copy link
Copy Markdown
Contributor Author

Thanks for the review, @ryanjbaxter!

I've rebased the commit onto 4.3.x and added a Signed-off-by so DCO should pass now. The PR base has also been switched from main to 4.3.x. Please take another look when you have a moment.

@ryanjbaxter ryanjbaxter merged commit e9693bc into spring-cloud:4.3.x May 27, 2026
1 check passed
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.

fallbackFactory property unconditionally overwritten in eagerlyRegisterFeignClientBeanDefinition

3 participants