-
Notifications
You must be signed in to change notification settings - Fork 799
MockBean behaviour for Feign Clients change since Spring Boot 2.2.7 Release #336
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
Comments
Feign has nothing to do with mock bean support so I hesitate to see how this is done change in behavior with feign. |
@spencergibb True, but I could also imagine Spring Boot saying that they're not responsible for how Feign creates its beans. |
Feign bean creation hasn't had major changes in a long time. Something in boot changes and there's a problem all of a sudden? Let's open there and if they say differently we can reopen. |
@spencergibb This would seem to be the issue: #337 |
Bug
Versions:
Spring Boot: 2.2.7
Spring Cloud: Hoxton.SR4
Before the Spring Boot 2.2.7 release, we used to create a Feign client (no fallback needed) and in certain situations we needed to create a
MockBean
of the Feign client to test. This worked fine; the mocked feign client overruled the actual feign client (even if it was marked as primary by default). Since the Spring Boot 2.2.7 release, this does not work anymore.Other beans marked as
@Primary
continue to be replaced by a mocked bean, making me believe this is specific to the implementation of Feign Clients and not a problem higher up in the Spring Boot eco system.We have been able to trace it back to this change in the 2.2.7 Release:
spring-projects/spring-boot@b9c2b7b#diff-e5e8e2d1fb541676ad4921f5e52f5f55L250
Sample
This now throws the following error since Spring Boot 2.2.7 Release:
Workaround
One workaround we found is marking the FeignClient itself as non-primary and adding the bean name to the mocked bean in order for it to be used instead of the actual Feign client.
The text was updated successfully, but these errors were encountered: