Author: markt
Date: Thu May 5 13:39:09 2011
New Revision: 1099789
URL: http://svn.apache.org/viewvc?rev=1099789&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=47371
Correctly coerce the empty string to zero when used as an operand in EL
arithmetic.
Patch provided by gbt.
Modified:
tomcat/trunk/java/org/apache/el/lang/ELArithmetic.java
tomcat/trunk/test/org/apache/el/lang/TestELArithmetic.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/el/lang/ELArithmetic.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/lang/ELArithmetic.java?rev=1099789&r1=1099788&r2=1099789&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/lang/ELArithmetic.java (original)
+++ tomcat/trunk/java/org/apache/el/lang/ELArithmetic.java Thu May 5 13:39:09
2011
@@ -394,13 +394,12 @@ public abstract class ELArithmetic {
if (isNumber(obj)) {
return coerce((Number) obj);
}
- if (obj instanceof String) {
- return coerce((String) obj);
- }
if (obj == null || "".equals(obj)) {
return coerce(ZERO);
}
-
+ if (obj instanceof String) {
+ return coerce((String) obj);
+ }
if (obj instanceof Character) {
return coerce(Short.valueOf((short) ((Character)
obj).charValue()));
}
Modified: tomcat/trunk/test/org/apache/el/lang/TestELArithmetic.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/lang/TestELArithmetic.java?rev=1099789&r1=1099788&r2=1099789&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/lang/TestELArithmetic.java (original)
+++ tomcat/trunk/test/org/apache/el/lang/TestELArithmetic.java Thu May 5
13:39:09 2011
@@ -49,4 +49,9 @@ public class TestELArithmetic extends Te
assertEquals("1.1",
String.valueOf(ELArithmetic.mod(a, b)));
}
+
+ public void testBug47371() throws Exception {
+ assertEquals("1",
+ String.valueOf(ELArithmetic.add("", Integer.valueOf(1))));
+ }
}
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1099789&r1=1099788&r2=1099789&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu May 5 13:39:09 2011
@@ -164,6 +164,10 @@
</subsection>
<subsection name="Jasper">
<changelog>
+ <fix>
+ <bug><47371/bug>: Correctly coerce the empty string to zero when used
as
+ an operand in EL arithmetic. Patch provided by gbt. (markt)
+ </fix>
<add>
Label JSP/tag file line and column numbers when reporting errors since
it may not be immediately obvious what the numbers represent. (markt)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]