tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r909875 - in /tomcat/trunk: java/org/apache/el/lang/ELSupport.java test/org/apache/el/lang/TestELSupport.java
Date Sat, 13 Feb 2010 19:22:03 GMT
Author: markt
Date: Sat Feb 13 19:22:02 2010
New Revision: 909875

URL: http://svn.apache.org/viewvc?rev=909875&view=rev
Log:
Address review comments
Don't use toString() to try and co-erce any old object to an Enum - the spec only mentions
String

Modified:
    tomcat/trunk/java/org/apache/el/lang/ELSupport.java
    tomcat/trunk/test/org/apache/el/lang/TestELSupport.java

Modified: tomcat/trunk/java/org/apache/el/lang/ELSupport.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/el/lang/ELSupport.java?rev=909875&r1=909874&r2=909875&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/lang/ELSupport.java (original)
+++ tomcat/trunk/java/org/apache/el/lang/ELSupport.java Sat Feb 13 19:22:02 2010
@@ -185,9 +185,15 @@
         if (type.isAssignableFrom(obj.getClass())) {
             return (Enum<?>) obj;
         }
+        
+        if (!(obj instanceof String)) {
+            throw new ELException(MessageFactory.get("error.convert",
+                    obj, obj.getClass(), type));
+        }
+
         Enum<?> result;
         try {
-             result = Enum.valueOf(type, obj.toString());
+             result = Enum.valueOf(type, (String) obj);
         } catch (IllegalArgumentException iae) {
             throw new ELException(MessageFactory.get("error.convert",
                     obj, obj.getClass(), type));

Modified: tomcat/trunk/test/org/apache/el/lang/TestELSupport.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/lang/TestELSupport.java?rev=909875&r1=909874&r2=909875&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/lang/TestELSupport.java (original)
+++ tomcat/trunk/test/org/apache/el/lang/TestELSupport.java Sat Feb 13 19:22:02 2010
@@ -92,9 +92,10 @@
         Object output = null;
         try {
             output = ELSupport.coerceToEnum(TestEnumA.VALA1, TestEnumC.class);
-        } finally {
-            assertEquals(TestEnumC.VALA1, output);
+        } catch (ELException ele) {
+            // Ignore
         }
+        assertNull(output);
     }
 
     private static void testIsSame(Object value) {



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


Mime
View raw message