[weld-dev] Overridden equals() are ignored on client proxy

Emily Jiang EMIJIANG at uk.ibm.com
Wed Dec 2 18:43:22 EST 2015


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 at uk.ibm.com 
Lotus Notes: Emily Jiang/UK/IBM at 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20151202/7d96d6aa/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cdiEquals.war
Type: application/octet-stream
Size: 3464 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/weld-dev/attachments/20151202/7d96d6aa/attachment-0001.obj 


More information about the weld-dev mailing list