Skip to content
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

Clarify FactoryBean.OBJECT_TYPE_ATTRIBUTE supported types #29799

Closed
philwebb opened this issue Jan 10, 2023 · 5 comments
Closed

Clarify FactoryBean.OBJECT_TYPE_ATTRIBUTE supported types #29799

philwebb opened this issue Jan 10, 2023 · 5 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@philwebb
Copy link
Member

The FactoryBean.OBJECT_TYPE_ATTRIBUTE can be used to give type information to a FactoryBean. The documentation isn't clear about what types can be used.

Both Spring Boot and Feign have used String values. It appears that in reality only Class and ResolvableType are supported.

Should AbstractBeanFactory also accept String values containing class names? Or should the types supported be documented in FactoryBean.OBJECT_TYPE_ATTRIBUTE? If String types are not supported, the openfeign code should probably change.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 10, 2023
@rstoyanchev rstoyanchev added the in: core Issues in core modules (aop, beans, core, context, expression) label Jan 24, 2023
@wilkinsona
Copy link
Member

wilkinsona commented Jun 15, 2023

Spring Data also uses a String value.

@snicoll
Copy link
Member

snicoll commented Jun 16, 2023

I thought they would have removed it with the change to specify the targetType (the line above in your link). Ping @mp911de

Irrespective of this issue, setTargetType is a better candidate for letting the container know about the type of the bean.

@mp911de
Copy link
Member

mp911de commented Jun 16, 2023

FWIW, Spring Data sets a Class object for FactoryBean.OBJECT_TYPE_ATTRIBUTE.
We could remove the attribute as we set the targetType as well.

@wilkinsona
Copy link
Member

Sorry for the confusion. There are two usages in Spring Data and I evidently linked to the wrong one. This is where a String is used.

@sbrannen sbrannen changed the title Clarify FactoryBean.OBJECT_TYPE_ATTRIBUTE supported types Clarify FactoryBean.OBJECT_TYPE_ATTRIBUTE supported types Jun 16, 2023
@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 1, 2023
@snicoll snicoll added this to the 6.1.0-M4 milestone Aug 1, 2023
@snicoll
Copy link
Member

snicoll commented Aug 1, 2023

As of Spring Framework 6.1, a FactoryBean.OBJECT_TYPE_ATTRIBUTE value that is neither a Class nor a ResolvableType is rejected upfront, see 4786e2b.

@snicoll snicoll closed this as completed Aug 1, 2023
artur1211 referenced this issue in spring-cloud/spring-cloud-openfeign Sep 21, 2023
It was previously ignored, changing it to a class introduces behaviour that breaks aot.

This is required by spring-projects/spring-framework@a6ff95a
kazuki43zoo added a commit to kazuki43zoo/spring that referenced this issue Oct 23, 2023
kazuki43zoo added a commit to kazuki43zoo/spring that referenced this issue Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

7 participants