You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The proxy created by Cglib2AopProxy handles calls to equals() with an EqualsInterceptor, but calls to hashCode() are handled by the advisors. Shouldn't there also be a HashCodeInterceptor that handles calls to hashCode()? Otherwise, two proxies for which equals() returns true may have different hash codes.
JdkDynamicAopProxy is different - it intercepts equals() and handles it itself (just like Cglib2AopProxy), but it also intercepts hashCode() and handles it itself.
I only browsed the code, though. Maybe I missed something and Cglib2AopProxy is correct.
Affects: 2.0 RC1
The text was updated successfully, but these errors were encountered:
In the case of JDK proxies, the hash code for the proxy is obtained by delegating to the TargetSource which will, in general, delegate directly to the target, or will at least correspond one to one with the target. Further to this, equals() will only return in the case where the TargetSources of the two proxies are equals() and in which case the hashCode() method should returns values that are ==.
For CGLIB the exact same behaviour is present, although hash code requires no special handling here - it is simply handled as either a calll directly to the target or a call to the TargetSource. In the presence of TargetSources with a correct equals()/hashCode() contract the desired behaviour will be present on the proxy.
Christopher Sahnwaldt opened SPR-2234 and commented
The proxy created by Cglib2AopProxy handles calls to equals() with an EqualsInterceptor, but calls to hashCode() are handled by the advisors. Shouldn't there also be a HashCodeInterceptor that handles calls to hashCode()? Otherwise, two proxies for which equals() returns true may have different hash codes.
JdkDynamicAopProxy is different - it intercepts equals() and handles it itself (just like Cglib2AopProxy), but it also intercepts hashCode() and handles it itself.
I only browsed the code, though. Maybe I missed something and Cglib2AopProxy is correct.
Affects: 2.0 RC1
The text was updated successfully, but these errors were encountered: