You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwebbeans.apache.org by "Holger Sunke (JIRA)" <ji...@apache.org> on 2018/02/28 12:03:00 UTC

[jira] [Created] (OWB-1233) WrappedValueExpression.equals(Object arg0) always false if arg0 is an instance of WrappedValueExpression

Holger Sunke created OWB-1233:
---------------------------------

             Summary: WrappedValueExpression.equals(Object arg0) always false if arg0 is an instance of WrappedValueExpression
                 Key: OWB-1233
                 URL: https://issues.apache.org/jira/browse/OWB-1233
             Project: OpenWebBeans
          Issue Type: Bug
          Components: Enterprise Web Beans
    Affects Versions: 2.0.3
            Reporter: Holger Sunke


Hello,

 

I found that _org.apache.webbeans.el22.WrappedValueExpression.equals(Object arg0)_ does not consider that arg0 might also bee an instance of WrappedValueExpression always returns _false_ in this case.

 

Reproduce:
 # Create two equal org.apache.el.ValueExpressionImpl instances _ve1_ and _ve2_ such that ve1.equals(ve2) is true.
 # Wrap _ve1_ with _we1_ = new WrappedValueExpression(_ve1_);
 # Wrap _ve2_ with _we2_ = new WrappedValueExpression(_ve2_);
 # assertTrue(we1.equals(we2)); -> fails
 # assertTrue(we1.equals(ve2)); -> succeeds
 # assertTrue(we1.equals(we1)); -> fails
 # assertTrue(we1.equals(ve1)); -> succeeds
 # assertTrue(ve2.equals(we1)); -> fails, breaking symmetry rule with (5.)
 # assertTrue(ve1.equals(we1)); -> fails, breaking symmetry rule with (7.)

I'd expect all assertions to succeed in accordance to the contract as described in documentation of java.lang.Object.equals(Object).

 

Btw: isn't it quite dangerous to rely on the hashCode() only in ValueExpressionImpl.equals(Object)?


public boolean equals(Object obj) {
        return (obj instanceof ValueExpressionImpl && obj.hashCode() == this
                .hashCode());
 }



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)