Skip to content

Add FactoryBean.OBJECT_TYPE_ATTRIBUTE to registered beans #337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
philwebb opened this issue May 10, 2020 · 6 comments
Closed

Add FactoryBean.OBJECT_TYPE_ATTRIBUTE to registered beans #337

philwebb opened this issue May 10, 2020 · 6 comments
Labels
enhancement New feature or request
Milestone

Comments

@philwebb
Copy link
Contributor

See spring-projects/spring-boot#21379 for more background.

It would be helpful if FeignClientsRegistrar could add a FactoryBean.OBJECT_TYPE_ATTRIBUTE attribute to the registered bean definition. The value of the attribute should be the type of bean that the FeignClientFactoryBean will ultimately create.

With such an attribute in place, it will be possible for Spring Boot's @MockBean support to tell the type without needing to instantiate the factory bean.

@spencergibb
Copy link
Member

@philwebb something like this?

beanDefinitionBuilder.addPropertyValue(FactoryBean.OBJECT_TYPE_ATTRIBUTE, className);

@spencergibb
Copy link
Member

@MPoorter I'm unable to recreate the issue to validate a fix. I've copied code from #336 (comment) but the mock bean works without errors.

@philwebb
Copy link
Contributor Author

philwebb commented May 13, 2020

@spencergibb It needs to be added to the attributes. Something more like this:

beanDefinitionBuilder.getBeanDefinition()
    .setAttribute(FactoryBean.OBJECT_TYPE_ATTRIBUTE, className);

@spencergibb
Copy link
Member

ah, I figured I was missing something. Thanks @philwebb

@spencergibb
Copy link
Member

@MPoorter can you try Hoxton.BUILD-SNAPSHOTS?

@maresja1
Copy link

@spencergibb Just hit the same problem and it seems to be resolved in Hoxton.BUILD-20200515.034536-2455. Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants