Uploaded image for project: 'OpenWebBeans'
  1. OpenWebBeans
  2. OWB-1233

WrappedValueExpression.equals(Object arg0) always false if arg0 is an instance of WrappedValueExpression

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.3
    • 2.0.5
    • Enterprise Web Beans
    • None

    Description

      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:

      1. Create two equal org.apache.el.ValueExpressionImpl instances ve1 and ve2 such that ve1.equals(ve2) is true.
      2. Wrap ve1 with we1 = new WrappedValueExpression(ve1);
      3. Wrap ve2 with we2 = new WrappedValueExpression(ve2);
      4. assertTrue(we1.equals(we2)); -> fails
      5. assertTrue(we1.equals(ve2)); -> succeeds
      6. assertTrue(we1.equals(we1)); -> fails
      7. assertTrue(we1.equals(ve1)); -> succeeds
      8. assertTrue(ve2.equals(we1)); -> fails, breaking symmetry rule with (5.)
      9. 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()); }

      Attachments

        Activity

          People

            struberg Mark Struberg
            holger.sunke@bodo-peters.de Holger Sunke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: