tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r701432 - in /tomcat/trunk: java/org/apache/el/lang/ELSupport.java test/org/apache/el/lang/TestELSupport.java
Date Fri, 03 Oct 2008 16:19:02 GMT
Author: markt
Date: Fri Oct  3 09:19:01 2008
New Revision: 701432

URL: http://svn.apache.org/viewvc?rev=701432&view=rev
Log:
Fix regression in previous fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=43656
Patch provided by Nils Eckert.

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=701432&r1=701431&r2=701432&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/el/lang/ELSupport.java (original)
+++ tomcat/trunk/java/org/apache/el/lang/ELSupport.java Fri Oct  3 09:19:01 2008
@@ -224,18 +224,18 @@
                 return ((BigDecimal) number).toBigInteger();
             }
             if (number instanceof BigInteger) {
-                return new BigInteger(number.toString());
+                return number;
             }
             return BigInteger.valueOf(number.longValue());
         }
         if (BigDecimal.class.equals(type)) {
             if (number instanceof BigDecimal) {
-                return new BigDecimal(number.toString());
+                return number;
             }
             if (number instanceof BigInteger) {
                 return new BigDecimal((BigInteger) number);
             }
-            return new BigDecimal(number.doubleValue());
+            return new BigDecimal(number.toString());
         }
         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.equals(obj.getClass()))) {
+                (obj != null && type.isAssignableFrom(obj.getClass()))) {
             return obj;
         }
         if (String.class.equals(type)) {
@@ -356,9 +356,6 @@
         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=701432&r1=701431&r2=701432&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/el/lang/TestELSupport.java (original)
+++ tomcat/trunk/test/org/apache/el/lang/TestELSupport.java Fri Oct  3 09:19:01 2008
@@ -56,6 +56,12 @@
         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