Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.3
-
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:
- 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()); }