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

  • 29917

  • 33774

  • https://github.com/spring-projects/spring-boot/issues/5837