2012/2/15  <ma...@apache.org>:
> Author: markt
> Date: Wed Feb 15 16:30:37 2012
> New Revision: 1244574
>
> URL: http://svn.apache.org/viewvc?rev=1244574&view=rev
> Log:
> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=52666
> Correct coercion order in EL for A {==,!=,eq,ne} B
>
> Modified:
>    tomcat/tc7.0.x/trunk/   (props changed)
>    tomcat/tc7.0.x/trunk/java/org/apache/el/lang/ELSupport.java
>    tomcat/tc7.0.x/trunk/test/org/apache/el/lang/TestELSupport.java
>    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
>

Regarding ELSupport#compare() and ELSupport#equals()
Their Javadoc comments document how those methods are implemented.
With this fix applied the equals() method Javadoc does not match
implementation anymore.

I think it should mention EL 1.8.1 and EL 1.8.2 as specifications
behind this implementation.

Though there is some small difference between EL 1.8.1 and compare()
in handling of null values. Anyway compare() cannot handle nulls per
EL 1.8.1 as it cannot return "false" but returns an integer. The
compare() method has its own special treatment of nulls as its javadoc
says.

It is only documentation issue. The code itself is OK.
It is not an issue for 6.0, because Javadoc for these methods is
essentially empty there.

I plan to look into fixing this later, but anyone can beat me over it.

Best regards,
Konstantin Kolinko


> Modified: tomcat/tc7.0.x/trunk/java/org/apache/el/lang/ELSupport.java
> URL: 
> http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/el/lang/ELSupport.java?rev=1244574&r1=1244573&r2=1244574&view=diff
> ==============================================================================
> --- tomcat/tc7.0.x/trunk/java/org/apache/el/lang/ELSupport.java (original)
> +++ tomcat/tc7.0.x/trunk/java/org/apache/el/lang/ELSupport.java Wed Feb 15 
> 16:30:37 2012
> @@ -127,35 +127,31 @@ public class ELSupport {
>             return true;
>         } else if (obj0 == null || obj1 == null) {
>             return false;
> -        } else if (obj0 instanceof Boolean || obj1 instanceof Boolean) {
> -            return coerceToBoolean(obj0).equals(coerceToBoolean(obj1));
> -        } else if (obj0.getClass().isEnum()) {
> -            return obj0.equals(coerceToEnum(obj1, obj0.getClass()));
> -        } else if (obj1.getClass().isEnum()) {
> -            return obj1.equals(coerceToEnum(obj0, obj1.getClass()));
> -        } else if (obj0 instanceof String || obj1 instanceof String) {
> -            int lexCompare = 
> coerceToString(obj0).compareTo(coerceToString(obj1));
> -            return (lexCompare == 0) ? true : false;
> -        }
> -        if (isBigDecimalOp(obj0, obj1)) {
> +        } else if (isBigDecimalOp(obj0, obj1)) {
>             BigDecimal bd0 = (BigDecimal) coerceToNumber(obj0, 
> BigDecimal.class);
>             BigDecimal bd1 = (BigDecimal) coerceToNumber(obj1, 
> BigDecimal.class);
>             return bd0.equals(bd1);
> -        }
> -        if (isDoubleOp(obj0, obj1)) {
> +        } else if (isDoubleOp(obj0, obj1)) {
>             Double d0 = (Double) coerceToNumber(obj0, Double.class);
>             Double d1 = (Double) coerceToNumber(obj1, Double.class);
>             return d0.equals(d1);
> -        }
> -        if (isBigIntegerOp(obj0, obj1)) {
> +        } else if (isBigIntegerOp(obj0, obj1)) {
>             BigInteger bi0 = (BigInteger) coerceToNumber(obj0, 
> BigInteger.class);
>             BigInteger bi1 = (BigInteger) coerceToNumber(obj1, 
> BigInteger.class);
>             return bi0.equals(bi1);
> -        }
> -        if (isLongOp(obj0, obj1)) {
> +        } else         if (isLongOp(obj0, obj1)) {
>             Long l0 = (Long) coerceToNumber(obj0, Long.class);
>             Long l1 = (Long) coerceToNumber(obj1, Long.class);
>             return l0.equals(l1);
> +        } else if (obj0 instanceof Boolean || obj1 instanceof Boolean) {
> +            return coerceToBoolean(obj0).equals(coerceToBoolean(obj1));
> +        } else if (obj0.getClass().isEnum()) {
> +            return obj0.equals(coerceToEnum(obj1, obj0.getClass()));
> +        } else if (obj1.getClass().isEnum()) {
> +            return obj1.equals(coerceToEnum(obj0, obj1.getClass()));
> +        } else if (obj0 instanceof String || obj1 instanceof String) {
> +            int lexCompare = 
> coerceToString(obj0).compareTo(coerceToString(obj1));
> +            return (lexCompare == 0) ? true : false;
>         } else {
>             return obj0.equals(obj1);
>         }
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to