Skip to content
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

Cglib2AopProxy should have an HashCodeInterceptor [SPR-2234] #6924

Closed
spring-projects-issues opened this issue Jul 4, 2006 · 3 comments
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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

@spring-projects-issues
Copy link
Collaborator Author

Rob Harrop commented

Christopher,

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.

Rob

@spring-projects-issues
Copy link
Collaborator Author

Christopher Sahnwaldt commented

Note: a HashCodeInterceptor was added in version 1.65 of Cglib2AopProxy

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Indeed, this has been revisited for 2.0.3. I've changed the status of this issue accordingly.

Juergen

@spring-projects-issues spring-projects-issues added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 10, 2019
@spring-projects-issues spring-projects-issues added this to the 2.0.3 milestone Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants