tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r702628 - in /tomcat/trunk: java/org/apache/el/lang/ELSupport.java test/org/apache/el/lang/TestELSupport.java
Date Tue, 07 Oct 2008 20:48:45 GMT
Author: markt
Date: Tue Oct  7 13:48:45 2008
New Revision: 702628

URL: http://svn.apache.org/viewvc?rev=702628&view=rev
Log:
Revert patch - it caused a regression. Correct patch to follow.

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=702628&r1=702627&r2=702628&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/lang/ELSupport.java (original)
+++ tomcat/trunk/java/org/apache/el/lang/ELSupport.java Tue Oct  7 13:48:45 2008
@@ -224,18 +224,18 @@
                 return ((BigDecimal) number).toBigInteger();
             }
             if (number instanceof BigInteger) {
-                return number;
+                return new BigInteger(number.toString());
             }
             return BigInteger.valueOf(number.longValue());
         }
         if (BigDecimal.class.equals(type)) {
             if (number instanceof BigDecimal) {
-                return number;
+                return new BigDecimal(number.toString());
             }
             if (number instanceof BigInteger) {
                 return new BigDecimal((BigInteger) number);
             }
-            return new BigDecimal(number.toString());
+            return new BigDecimal(number.doubleValue());
         }
         if (Byte.TYPE == type || Byte.class.equals(type)) {
             return new Byte(number.byteValue());
@@ -341,7 +341,7 @@
     public final static Object coerceToType(final Object obj, final Class type)
             throws IllegalArgumentException {
         if (type == null || Object.class.equals(type) ||
-                (obj != null && type.isAssignableFrom(obj.getClass()))) {
+                (obj != null && type.equals(obj.getClass()))) {
             return obj;
         }
         if (String.class.equals(type)) {
@@ -356,6 +356,9 @@
         if (Boolean.class.equals(type) || Boolean.TYPE == type) {
             return coerceToBoolean(obj);
         }
+        if (obj != null && type.isAssignableFrom(obj.getClass())) {
+            return obj;
+        }
         if (type.isEnum()) {
             return coerceToEnum(obj, 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=702628&r1=702627&r2=702628&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/lang/TestELSupport.java (original)
+++ tomcat/trunk/test/org/apache/el/lang/TestELSupport.java Tue Oct  7 13:48:45 2008
@@ -56,12 +56,6 @@
         testIsSame(Float.valueOf(0.123456F));
     }
 
-    public void testCoerceIntegerToNumber() {
-        Integer input = 4390241;
-        Object output = ELSupport.coerceToType(input, Number.class);
-        assertEquals(input, output);
-    }
-
     private static void testIsSame(Object value) {
         assertEquals(value, ELSupport.coerceToNumber(value, value.getClass()));
     }



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


Mime
View raw message