Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=52666

Correct coercion order in EL for A {==,!=,eq,ne} B

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@1245686 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit bd34741eeba81ea02defd13090dec4eedf7f70ba 1 parent d755ede
@markt-asf markt-asf authored
View
6 STATUS.txt
@@ -134,12 +134,6 @@ PATCHES PROPOSED TO BACKPORT:
+1: markt, kkolinko, kfujino
-1:
-* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=52666
- Correct coercion order in EL for A {==,!=,eq,ne} B
- http://svn.apache.org/viewvc?rev=1244567&view=rev
- +1: markt, kkolinko, kfujino
- -1:
-
PATCHES/ISSUES THAT ARE STALLED
View
30 java/org/apache/el/lang/ELSupport.java
@@ -104,35 +104,31 @@ public final static boolean equals(final Object obj0, final Object obj1)
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);
}
View
4 test/org/apache/el/lang/TestELSupport.java
@@ -24,6 +24,10 @@
import junit.framework.TestCase;
public class TestELSupport extends TestCase {
+ public void testEquals() {
+ assertTrue(ELSupport.equals("01", Long.valueOf(1)));
+ }
+
public void testBigDecimal() {
testIsSame(new BigDecimal(
"0.123456789012345678901234567890123456789012345678901234567890123456789"));
View
4 webapps/docs/changelog.xml
@@ -104,6 +104,10 @@
<bug>52335</bug>: Only handle <code>&lt;\%</code> and not
<code>\%</code> as escaped in template text. (markt)
</fix>
+ <fix>
+ <bug>52666</bug>: Correct coercion order in EL when processing the
+ equality and inequality operators. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Webapps">
Please sign in to comment.
Something went wrong with that request. Please try again.