[weld-issues] [JBoss JIRA] Commented: (WELD-695) Client proxies should delegate equals and hashCode to the underlying instance

Stuart Douglas (JIRA) jira-events at lists.jboss.org
Wed Dec 1 21:24:04 EST 2010


    [ https://jira.jboss.org/browse/WELD-695?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12566720#comment-12566720 ] 

Stuart Douglas commented on WELD-695:
-------------------------------------

Actually this does not make sense for client proxies. There are quite a few problems, but these are the main ones:

- hashCode will change when the underlying instance changes - Also different threads will have see different underlying bean instances, and will get different hashCodes as well. This will cause all kinds of weirdness

- equals cannot be made transitive
if we unwrap the proxy we end up with a situation were a.equals(proxy) != proxy.equals(a)

At the moment the behaviour of the client proxies in hash maps/sets is quite well defined, however if we change this behaviour then anything can happen, and the problems will likely be intermittent and almost impossible to debug.

I think for client proxies the strategy we should use is:

hashCode: getClass().hashCode() 

equals: this.getClass().equals(other.getClass())

So client proxies are only equal to other client proxies for the same bean.

> Client proxies should delegate equals and hashCode to the underlying instance
> -----------------------------------------------------------------------------
>
>                 Key: WELD-695
>                 URL: https://jira.jboss.org/browse/WELD-695
>             Project: Weld
>          Issue Type: Bug
>          Components: Proxies
>    Affects Versions: 1.1.0.Beta1
>            Reporter: Stuart Douglas
>            Assignee: Stuart Douglas
>             Fix For: 1.1.0.CR1
>
>


-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the weld-issues mailing list