harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r438041 - in /incubator/harmony/enhanced/classlib/trunk/modules/text/src: main/java/java/text/DecimalFormat.java test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
Date Tue, 29 Aug 2006 10:42:05 GMT
Author: hindessm
Date: Tue Aug 29 03:42:02 2006
New Revision: 438041

URL: http://svn.apache.org/viewvc?rev=438041&view=rev
Log:
Appled fixes from "#HARMONY-1070] [classlib][text]
java.text.DecimalFormat.setDecimalFormatSymbols(null) throws unspecified NPE".

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java?rev=438041&r1=438040&r2=438041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormat.java
Tue Aug 29 03:42:02 2006
@@ -457,10 +457,12 @@
      *            the DecimalFormatSymbols
      */
     public void setDecimalFormatSymbols(DecimalFormatSymbols value) {
-        symbols = (DecimalFormatSymbols) value.clone();
-        icuSymbols = dform.getDecimalFormatSymbols();
-        copySymbols(icuSymbols, symbols);
-        dform.setDecimalFormatSymbols(icuSymbols);
+        if (value != null){
+            symbols = (DecimalFormatSymbols) value.clone();
+            icuSymbols = dform.getDecimalFormatSymbols();
+            copySymbols(icuSymbols, symbols);
+            dform.setDecimalFormatSymbols(icuSymbols);
+        }
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java?rev=438041&r1=438040&r2=438041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java
Tue Aug 29 03:42:02 2006
@@ -1570,4 +1570,18 @@
         assertTrue(number instanceof Double);
         assertTrue(Double.isInfinite(number.doubleValue()));
     }
+    
+    /**
+     * Test if setDecimalFormatSymbols method wont throw NullPointerException 
+     * when it is called with null parameter.
+     */
+    public void testSetDecimalFormatSymbolsAsNull(){
+	// Regression for HARMONY-1070
+        try {                                                                   
+            DecimalFormat format = (DecimalFormat)DecimalFormat.getInstance();
+            format.setDecimalFormatSymbols(null);                     
+        } catch (Exception e) {
+            fail("Unexpected exception caught: " + e);
+        }  
+    }
 }



Mime
View raw message