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

Bean Overrides for certain FactoryBean use cases no longer work #33800

Closed
romainmoreau opened this issue Oct 26, 2024 · 4 comments
Closed

Bean Overrides for certain FactoryBean use cases no longer work #33800

romainmoreau opened this issue Oct 26, 2024 · 4 comments
Assignees
Labels
in: test Issues in the test module type: regression A bug that is also a regression
Milestone

Comments

@romainmoreau
Copy link

romainmoreau commented Oct 26, 2024

Overview

Here's a demo unit test reproducing the issue: https://github.com/romainmoreau/spy-demo/blob/master/src/test/java/com/example/demo/DemoMockTest.java

The issue happens with Spring Boot 3.4.0-RC1, but it was working with Spring Boot 3.4.0-M3.

Here's the full stack trace: https://github.com/romainmoreau/spy-demo/actions/runs/11532983997/job/32105377666#step:4:2342

It works with Spring Boot 3.4.0-RC1 if Spring Framework is downgraded to 6.2.0-RC1.

Related Issues

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 26, 2024
@bclozel bclozel transferred this issue from spring-projects/spring-boot Oct 26, 2024
@bclozel bclozel added in: test Issues in the test module type: regression A bug that is also a regression labels Oct 26, 2024
@sbrannen sbrannen self-assigned this Oct 26, 2024
@sbrannen sbrannen removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 27, 2024
@sbrannen sbrannen added this to the 6.2.0 milestone Oct 27, 2024
@sbrannen sbrannen changed the title @MockitoSpyBean on a JpaRepository broken Bean Overrides no longer work with a Spring Data JpaRepository Oct 27, 2024
@sbrannen
Copy link
Member

Thanks for reporting the issue.

The root cause is that AbstractBeanFactory.isSingleton() throws a BeanCreationException for a Spring Data JpaRepository.

We'll look into it!

@sbrannen
Copy link
Member

This has been addressed on main and tested against the provided sample project.

@romainmoreau, please try it out with 6.2.0-SNAPSHOT and let us know if that addresses your issues.

Thanks,

Sam

@romainmoreau
Copy link
Author

@sbrannen I tested 6.2.0-SNAPSHOT also with the demo project and with a real project with various uses of @MockitoSpyBean some of which were affected by this issue and this patch fixed both, thanks!

@sbrannen
Copy link
Member

@sbrannen I tested 6.2.0-SNAPSHOT also with the demo project and with a real project with various uses of @MockitoSpyBean some of which were affected by this issue and this patch fixed both, thanks!

Awesome! 🚀

Thanks so much for trying it out and letting us know it works!

@sbrannen sbrannen changed the title Bean Overrides no longer work with a Spring Data JpaRepository Bean Overrides for certain FactoryBean use cases no longer work Oct 29, 2024
JKatzwinkel added a commit to JKatzwinkel/tla-es that referenced this issue Oct 31, 2024
JKatzwinkel added a commit to JKatzwinkel/tla-es that referenced this issue Oct 31, 2024
* build(deps): bump the spring-boot group with 5 updates

Bumps the spring-boot group with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [org.springframework.boot:spring-boot-starter-tomcat](https://github.com/spring-projects/spring-boot) | `3.4.0-M3` | `3.4.0-RC1` |
| [org.springframework.boot:spring-boot-autoconfigure](https://github.com/spring-projects/spring-boot) | `3.4.0-M3` | `3.4.0-RC1` |
| [org.springframework.boot:spring-boot-starter-logging](https://github.com/spring-projects/spring-boot) | `3.4.0-M3` | `3.4.0-RC1` |
| [org.springframework.boot:spring-boot-starter-test](https://github.com/spring-projects/spring-boot) | `3.4.0-M3` | `3.4.0-RC1` |
| [org.springframework.boot](https://github.com/spring-projects/spring-boot) | `3.4.0-M3` | `3.4.0-RC1` |


Updates `org.springframework.boot:spring-boot-starter-tomcat` from 3.4.0-M3 to 3.4.0-RC1
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v3.4.0-M3...v3.4.0-RC1)

Updates `org.springframework.boot:spring-boot-autoconfigure` from 3.4.0-M3 to 3.4.0-RC1
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v3.4.0-M3...v3.4.0-RC1)

Updates `org.springframework.boot:spring-boot-starter-logging` from 3.4.0-M3 to 3.4.0-RC1
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v3.4.0-M3...v3.4.0-RC1)

Updates `org.springframework.boot:spring-boot-starter-test` from 3.4.0-M3 to 3.4.0-RC1
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v3.4.0-M3...v3.4.0-RC1)

Updates `org.springframework.boot` from 3.4.0-M3 to 3.4.0-RC1
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v3.4.0-M3...v3.4.0-RC1)

---
updated-dependencies:
- dependency-name: org.springframework.boot:spring-boot-starter-tomcat
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: spring-boot
- dependency-name: org.springframework.boot:spring-boot-autoconfigure
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: spring-boot
- dependency-name: org.springframework.boot:spring-boot-starter-logging
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: spring-boot
- dependency-name: org.springframework.boot:spring-boot-starter-test
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: spring-boot
- dependency-name: org.springframework.boot
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: spring-boot
...

Signed-off-by: dependabot[bot] <support@github.com>

* ci: execute entire test matrix

* add workaround for spy bean override issue in spring 6.2.0-RC3

see spring-projects/spring-framework#33800

can be reverted when spring 6.2.0 GA comes out.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JKatzwinkel <JKatzwinkel@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

4 participants