tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1024224 - in /tomcat/trunk: java/org/apache/el/parser/AstCompositeExpression.java test/org/apache/el/TestValueExpressionImpl.java test/org/apache/el/TesterEnum.java webapps/docs/changelog.xml
Date Tue, 19 Oct 2010 13:03:02 GMT
Author: markt
Date: Tue Oct 19 13:03:01 2010
New Revision: 1024224

URL: http://svn.apache.org/viewvc?rev=1024224&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50105
Use Enum.name() rather than Enum.toString() in composite expressions

Added:
    tomcat/trunk/test/org/apache/el/TesterEnum.java   (with props)
Modified:
    tomcat/trunk/java/org/apache/el/parser/AstCompositeExpression.java
    tomcat/trunk/test/org/apache/el/TestValueExpressionImpl.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/el/parser/AstCompositeExpression.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/parser/AstCompositeExpression.java?rev=1024224&r1=1024223&r2=1024224&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/parser/AstCompositeExpression.java (original)
+++ tomcat/trunk/java/org/apache/el/parser/AstCompositeExpression.java Tue Oct 19 13:03:01
2010
@@ -20,6 +20,7 @@ package org.apache.el.parser;
 
 import javax.el.ELException;
 
+import org.apache.el.lang.ELSupport;
 import org.apache.el.lang.EvaluationContext;
 
 
@@ -48,7 +49,7 @@ public final class AstCompositeExpressio
             for (int i = 0; i < this.children.length; i++) {
                 obj = this.children[i].getValue(ctx);
                 if (obj != null) {
-                    sb.append(obj);
+                    sb.append(ELSupport.coerceToString(obj));
                 }
             }
         }

Modified: tomcat/trunk/test/org/apache/el/TestValueExpressionImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TestValueExpressionImpl.java?rev=1024224&r1=1024223&r2=1024224&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/TestValueExpressionImpl.java (original)
+++ tomcat/trunk/test/org/apache/el/TestValueExpressionImpl.java Tue Oct 19 13:03:01 2010
@@ -81,4 +81,27 @@ public class TestValueExpressionImpl ext
         assertEquals(beanB, vr.getBase());
         assertEquals("name", vr.getProperty());
     }
+
+
+    public void testBug50105() {
+        ExpressionFactory factory = ExpressionFactory.newInstance();
+        ELContext context = new ELContextImpl();
+        
+        TesterEnum testEnum = TesterEnum.APPLE;
+        
+        ValueExpression var =
+            factory.createValueExpression(testEnum, TesterEnum.class);
+        context.getVariableMapper().setVariable("testEnum", var);
+
+        // When coercing an Enum to a String, name() should always be used.
+        ValueExpression ve1 = factory.createValueExpression(
+                context, "${testEnum}", String.class);
+        String result1 = (String) ve1.getValue(context);
+        assertEquals("APPLE", result1);
+        
+        ValueExpression ve2 = factory.createValueExpression(
+                context, "foo${testEnum}bar", String.class);
+        String result2 = (String) ve2.getValue(context);
+        assertEquals("fooAPPLEbar", result2);
+    }
 }

Added: tomcat/trunk/test/org/apache/el/TesterEnum.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TesterEnum.java?rev=1024224&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/el/TesterEnum.java (added)
+++ tomcat/trunk/test/org/apache/el/TesterEnum.java Tue Oct 19 13:03:01 2010
@@ -0,0 +1,10 @@
+package org.apache.el;
+
+public enum TesterEnum {
+    APPLE, ORANGE;
+    
+    @Override
+    public String toString() {
+        return "This is a " + this.name();
+    }
+}

Propchange: tomcat/trunk/test/org/apache/el/TesterEnum.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1024224&r1=1024223&r2=1024224&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Tue Oct 19 13:03:01 2010
@@ -37,6 +37,13 @@
 <body>
 <!--  Catalina, Coyote, Jasper, Cluster, Web applications, Extras, Other -->
 <section name="Tomcat 7.0.5 (markt)">
+  <subsection name="Jasper">
+    <changelog>
+      <bug>50105</bug>: When processing composite EL expressions use
+      <code>Enum.name()</code> rather than <code>Enum.toString()</code>
as
+      required by the EL specification. (markt)
+    </changelog>
+  </subsection>
   <subsection name="Web applications">
     <changelog>
       <fix>



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


Mime
View raw message