Thank you Martin for the info! It is strange that the application works on OWB

Many thanks,
Emily
===========================
Emily Jiang
WebSphere Application Server, CDI Development Lead

 
MP 211, DE3A20, Winchester, Hampshire, England, SO21 2JN
Phone:  +44 (0)1962 816278  Internal: 246278

Email: emijiang@uk.ibm.com
Lotus Notes: Emily Jiang/UK/IBM@IBMGB




From:        Martin Kouba <mkouba@redhat.com>
To:        Emily Jiang/UK/IBM@IBMGB,
Cc:        Weld <weld-dev@lists.jboss.org>
Date:        03/12/2015 08:27
Subject:        Re: [weld-dev] Overridden equals() are ignored on client proxy
Sent by:        weld-dev-bounces@lists.jboss.org




Hi Emily,

yes, the spec is clear and for good reasons. This was already discussed
in EG and weld community - see for example WELD-695 [1]. And the
consensus is: "it does not make sense to delegate equals/hashcode to
bean instances for client proxies".

One of the problems is that client proxies may be shared between
multiple injection points (and in Weld they are).

Also in Weld a client proxy is equal to a client proxy for the same bean.

Anyway, it seems it doesn't work on OWB either - see also OWB-458 [2].

Martin


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

[2]
https://issues.apache.org/jira/browse/OWB-458

Dne 3.12.2015 v 00:43 Emily Jiang napsal(a):
> Hi Martin,
>
> For some reason, a proxied bean's equals cannot be called. Are you aware
> of this problem? Although the spec says:
>
> The behavior of all methods declared by java.lang.Object, except for
> toString(), is
> undefined for a client proxy. Portable applications should not invoke
> any method declared by
> java.lang.Object, except for toString(), on a client proxy.
>
> I thought the overridden equals is different from the methods defined by
> Object class and it should be invoked.
>
> Please find attached a very simple test case that shows a .equals()
> method not being invoked on a bean proxied by Weld.
>
>
> In a debugger one can see that GenericBean.equals() is not invoked
> within the Servlet:
>
>          protected void doGet(HttpServletRequest request,
> HttpServletResponse response) throws ServletException, IOException {
>        PrintWriter pw = response.getWriter();
>        pw.println ("Hello");
>        if (gb.equals(new GenericBean(10))) {  // GenericBean.equals() is
> not invoked; test prints 'fail'
>                pw.println("pass");
>        } else {
>                pw.println ("fail");
>        }
>          }
>
> The .war contains source and object code. As you can see there's only
> two classes.
>
> Many thanks,
> Emily
> ===========================
> Emily Jiang
> WebSphere Application Server, CDI Development Lead
>
> MP 211, DE3A20, Winchester, Hampshire, England, SO21 2JN
> Phone:  +44 (0)1962 816278  Internal: 246278
>
> Email: emijiang@uk.ibm.com
> Lotus Notes: Emily Jiang/UK/IBM@IBMGB
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with number
> 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
>

--
Martin Kouba
Software Engineer
Red Hat, Czech Republic
_______________________________________________
weld-dev mailing list
weld-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/weld-dev