Revert patch - it caused a regression. Correct patch to follow.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 7 Oct 2008 20:48:45 +0000 (20:48 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 7 Oct 2008 20:48:45 +0000 (20:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@702628 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/el/lang/ELSupport.java
test/org/apache/el/lang/TestELSupport.java

index d65a6b3..51e3649 100644 (file)
@@ -224,18 +224,18 @@ public class ELSupport {
                 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 class ELSupport {
     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 @@ public class ELSupport {
         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);
         }
index 0563e78..c824b19 100644 (file)
@@ -56,12 +56,6 @@ public class TestELSupport extends TestCase {
         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()));
     }