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

Corrected to set bean class instead of bean class name to factoryBeanObjectType of BeanDefinition attribute #865

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

kazuki43zoo
Copy link
Member

@kazuki43zoo kazuki43zoo commented Oct 23, 2023

Fixes gh-855

Changes

We used the factoryBeanObjectType of BeanDefinition attribute for supporting @MockBean/@SpyBean provided Spring Boot via gh-494. But since Spring Framework 6.1, this attribute cannot pass value of String type. Thefore we change to pass the bean type instead of bean class name. This change valid on latest version of Spring Boot 3.0.x and 3.1.x and 3.2.x.

Related Links

@kazuki43zoo kazuki43zoo added the enhancement Improve a feature or add a new feature label Oct 23, 2023
@kazuki43zoo kazuki43zoo added this to the 3.0.3 milestone Oct 23, 2023
@kazuki43zoo kazuki43zoo self-assigned this Oct 23, 2023
@kazuki43zoo kazuki43zoo changed the title Corrected to set bean class instead of bnea class name to factoryBeanObjectType of BeanDefinition attribute Corrected to set bean class instead of bean class name to factoryBeanObjectType of BeanDefinition attribute Oct 23, 2023
@coveralls
Copy link

coveralls commented Oct 23, 2023

Coverage Status

coverage: 89.633% (+0.01%) from 89.622% when pulling a781e86 on kazuki43zoo:gh-855 into 4275397 on mybatis:master.

@kazuki43zoo kazuki43zoo merged commit a7e4ca9 into mybatis:master Oct 23, 2023
8 checks passed
@kazuki43zoo kazuki43zoo deleted the gh-855 branch October 23, 2023 11:57
@harawata
Copy link
Member

Thank you, @kazuki43zoo !

So, mybatis/spring-boot-starter#475 was not actually fixed?

@kazuki43zoo
Copy link
Member Author

@harawata

Thank you, @kazuki43zoo !

So, mybatis/spring-boot-starter#475 was not actually fixed?

No, at least it worked fine for @MockBean/@SpyBean. I will investigate a mechanism it at later.

@harawata
Copy link
Member

Okay, thanks!

djkeh added a commit to djkeh/springmockk that referenced this pull request Feb 1, 2024
This upgrade includes
some changes of the test codes
which corresponds to significant changes
that have been made in Spring Boot 3.2.

mybatis project encountered the same issue,
so its pr helped a lot making this upgrade done.
The brief explanations are:

1. As of Spring Framework 6.1, we can't pass the value of `factoryBeanObjectType` as `String` to `BeanDefinition`.
2. `BeanFactory.getBean()` in `BeanFactoryExtensions` has been changed.

Good thing is, the changes above
don't seem to affact the implementations.
All we need to do is to correct the test code.

For the details, please check the references below.

## Reference

* mybatis pr: mybatis/spring#865
* as-is 1: https://github.com/spring-projects/spring-framework/blob/66f4509c2c7a1ad0255ed84f9e5efb340bd0b470/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java#L74-L83
* to-be 1: https://github.com/spring-projects/spring-framework/blob/00577ed80acfc22104b41d6a631f433a3fa7e6af/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java#L74-L87
* as-is 2: https://github.com/spring-projects/spring-framework/blob/66f4509c2c7a1ad0255ed84f9e5efb340bd0b470/spring-beans/src/main/kotlin/org/springframework/beans/factory/BeanFactoryExtensions.kt#L28
* to-be 2: https://github.com/spring-projects/spring-framework/blob/00577ed80acfc22104b41d6a631f433a3fa7e6af/spring-beans/src/main/kotlin/org/springframework/beans/factory/BeanFactoryExtensions.kt#L29-L30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve a feature or add a new feature
Projects
None yet
3 participants