This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git


The following commit(s) were added to refs/heads/master by this push:
     new ca0994b5 Fix ClassCastException in DoubleLocaleConverter when input is 
non-Double Number (#422).
ca0994b5 is described below

commit ca0994b5d8e4472124c554110c58d9b2790f27b3
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Jul 20 06:43:28 2026 -0700

    Fix ClassCastException in DoubleLocaleConverter when input is non-Double
    Number (#422).
---
 src/changes/changes.xml                            |  1 +
 .../converters/DoubleLocaleConverterTest.java      | 22 +++++++++++-----------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a77df1aa..74c2b2f1 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -48,6 +48,7 @@
       <action type="fix" dev="ggregory" due-to="Naveed Khan, Gary 
Gregory">Make WrapDynaClass instance cache thread-safe (#418).</action>
       <action type="fix" dev="ggregory" due-to="Naveed Khan, Gary 
Gregory">Reject out-of-range color components in ColorConverter (#420).</action>
       <action type="fix" dev="ggregory" due-to="Naveed Khan, Gary 
Gregory">Pass configured locale to SimpleDateFormat in DateTimeConverter 
(#421).</action>
+      <action type="fix" dev="ggregory" due-to="Naveed Khan, Gary Gregory">Fix 
ClassCastException in DoubleLocaleConverter when input is non-Double Number 
(#422).</action>
       <!-- ADD -->
       <action type="add" dev="ggregory" due-to="Gary Gregory">Use varargs for 
org.apache.commons.beanutils2.MethodUtils.getAccessibleMethod(Class, String, 
Class...), and remove last argument variants using Class[] and Class.</action>
       <action type="add" dev="ggregory" due-to="SethFalco, Melloware, Gary 
Gregory">Add Instant converter and improve enum converter #49.</action>
diff --git 
a/src/test/java/org/apache/commons/beanutils2/converters/DoubleLocaleConverterTest.java
 
b/src/test/java/org/apache/commons/beanutils2/converters/DoubleLocaleConverterTest.java
index 4e8daf1d..40bd470d 100644
--- 
a/src/test/java/org/apache/commons/beanutils2/converters/DoubleLocaleConverterTest.java
+++ 
b/src/test/java/org/apache/commons/beanutils2/converters/DoubleLocaleConverterTest.java
@@ -39,17 +39,6 @@ class DoubleLocaleConverterTest extends 
AbstractLocaleConverterTest<Double> {
         expectedValue = Double.valueOf(expectedDecimalValue);
     }
 
-    /**
-     * Passing a non-Double Number directly (e.g. Integer) must return a 
Double, not throw ClassCastException.
-     */
-    @Test
-    void testConvertFromNonDoubleNumber() {
-        final DoubleLocaleConverter c = DoubleLocaleConverter.builder().get();
-        assertEquals(Double.valueOf(42.0), c.convert(Double.class, 
Integer.valueOf(42), null));
-        assertEquals(Double.valueOf(3.14f), c.convert(Double.class, 
Float.valueOf(3.14f), null));
-        assertEquals(Double.valueOf(100L), c.convert(Double.class, 
Long.valueOf(100L), null));
-    }
-
     /**
      * Test Converter() constructor Uses the default locale, no default value
      */
@@ -203,4 +192,15 @@ class DoubleLocaleConverterTest extends 
AbstractLocaleConverterTest<Double> {
         convertInvalid(converter, "(C)", defaultValue);
         convertNull(converter, "(C)", defaultValue);
     }
+
+    /**
+     * Passing a non-Double Number directly (e.g. Integer) must return a 
Double, not throw ClassCastException.
+     */
+    @Test
+    void testConvertFromNonDoubleNumber() {
+        final DoubleLocaleConverter c = DoubleLocaleConverter.builder().get();
+        assertEquals(Double.valueOf(42.0), c.convert(Double.class, 
Integer.valueOf(42), null));
+        assertEquals(Double.valueOf(3.14f), c.convert(Double.class, 
Float.valueOf(3.14f), null));
+        assertEquals(Double.valueOf(100L), c.convert(Double.class, 
Long.valueOf(100L), null));
+    }
 }

Reply via email to