spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.77k stars 38.16k forks source link

Remove `proxyTargetAware` attribute from `@MockitoSpyBean` #33775

Closed sbrannen closed 1 month ago

sbrannen commented 1 month ago

Overview

During my recent analysis of our @MockitoSpyBean support, it became apparent that we do not need the proxyTargetAware attribute.

The proxyTargetAware attribute was originally introduced in Spring Boot's @SpyBean support in order to address https://github.com/spring-projects/spring-boot/issues/5837; however, Spring Framework's @MockitoSpyBean support works differently and does not modify existing Spring AOP advice chains. In other words, setting that flag to true does not make anything "proxy target aware". In addition, we are not aware of any compelling use cases for which one would want to set that flag to false.

In light of the above, we should remove the proxyTargetAware attribute from @MockitoSpyBean while keeping the underlying feature in tact (i.e., transparent verification for spies created via @MockitoSpyBean), which was the behavior when proxyTargetAware was set to true (the default value for the attribute).

Related Issues