Author: markt
Date: Thu Sep 12 10:06:16 2013
New Revision: 1522512

URL: http://svn.apache.org/r1522512
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=55552
Separate the return type (which must be an object) from the expected type which 
may be a primitive. This is necessary for EL 3.0 onwards as the default 
handling of nulls is now different for primitives and objects. The expression 
engine needs to know what the true expected type is in order to correctly 
coerce the result to the right type.

Modified:
    tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java

Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java?rev=1522512&r1=1522511&r2=1522512&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JspUtil.java Thu Sep 12 
10:06:16 2013
@@ -357,32 +357,33 @@ public class JspUtil {
          * Determine whether to use the expected type's textual name or, if 
it's
          * a primitive, the name of its correspondent boxed type.
          */
-        String targetType = expectedType.getCanonicalName();
+        String returnType = expectedType.getCanonicalName();
+        String targetType = returnType;
         String primitiveConverterMethod = null;
         if (expectedType.isPrimitive()) {
             if (expectedType.equals(Boolean.TYPE)) {
-                targetType = Boolean.class.getName();
+                returnType = Boolean.class.getName();
                 primitiveConverterMethod = "booleanValue";
             } else if (expectedType.equals(Byte.TYPE)) {
-                targetType = Byte.class.getName();
+                returnType = Byte.class.getName();
                 primitiveConverterMethod = "byteValue";
             } else if (expectedType.equals(Character.TYPE)) {
-                targetType = Character.class.getName();
+                returnType = Character.class.getName();
                 primitiveConverterMethod = "charValue";
             } else if (expectedType.equals(Short.TYPE)) {
-                targetType = Short.class.getName();
+                returnType = Short.class.getName();
                 primitiveConverterMethod = "shortValue";
             } else if (expectedType.equals(Integer.TYPE)) {
-                targetType = Integer.class.getName();
+                returnType = Integer.class.getName();
                 primitiveConverterMethod = "intValue";
             } else if (expectedType.equals(Long.TYPE)) {
-                targetType = Long.class.getName();
+                returnType = Long.class.getName();
                 primitiveConverterMethod = "longValue";
             } else if (expectedType.equals(Float.TYPE)) {
-                targetType = Float.class.getName();
+                returnType = Float.class.getName();
                 primitiveConverterMethod = "floatValue";
             } else if (expectedType.equals(Double.TYPE)) {
-                targetType = Double.class.getName();
+                returnType = Double.class.getName();
                 primitiveConverterMethod = "doubleValue";
             }
         }
@@ -408,7 +409,7 @@ public class JspUtil {
         targetType = toJavaSourceType(targetType);
         StringBuilder call = new StringBuilder(
                 "("
-                        + targetType
+                        + returnType
                         + ") "
                         + 
"org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate"
                         + "(" + Generator.quote(expression) + ", " + targetType



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

Reply via email to