Skip to content

fallbackFactory property unconditionally overwritten in eagerlyRegisterFeignClientBeanDefinition #1367

@sshworld

Description

@sshworld

Describe the bug

In FeignClientsRegistrar.eagerlyRegisterFeignClientBeanDefinition() (Spring Cloud OpenFeign 5.0.2-SNAPSHOT / main branch), the fallbackFactory property is set twice:

  1. Lines 239-243: Conditionally set with proper ClassUtils.resolveClassName() handling
  2. Line 244: Unconditionally overwritten with the raw attribute value

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")); // always overwrites

Line 244 unconditionally overwrites the resolved value from lines 239-243, making the ClassUtils.resolveClassName() logic dead code.

This appears to be unintentional because:

  • fallback in the same method (lines 234-238) uses conditional set only — no unconditional overwrite
  • lazilyRegisterFeignClientBeanDefinition() (lines 288-292) handles fallbackFactory with conditional set only

The fix would be removing line 244 to align with both the fallback handling and the lazy registration path.

I'd be happy to submit a PR with the fix and test if you agree this is a bug.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions