equals and hashCode implementations in MockitoSpyBeanOverrideMetadata
care about getClass()
but shouldn't: https://github.com/spring-projects/spring-framework/blob/28f62abda44c607997c5a32ba3fbd857a092ab4e/spring-test/src/main/java/org/springframework/test/context/bean/override/mockito/MockitoSpyBeanOverrideMetadata.java#L105-L109
This looks like a copy/paste from the Spring Boot implementation that doesn't have the notion of BeanOverrideStrategy
that is enough already to differentiate between those two.
Comment From: snicoll
Looking a bit more after having removed that code, it turns out things are working but could stop if someone created an OverrideMetadata
with the same settings in a different class. For instance something similar to TestBeanOverrideMetadata
but with a completely different approach to how the override is created. While very unlikely, harmonizing equals/hashCode so that the OverrideMetadata
implementation is part of the key sounds sensible.