harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r427411 - in /incubator/harmony/enhanced/classlib/trunk/modules/text/src: main/java/java/text/NumberFormat.java test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
Date Tue, 01 Aug 2006 02:38:00 GMT
Author: pyang
Date: Mon Jul 31 19:37:59 2006
New Revision: 427411

URL: http://svn.apache.org/viewvc?rev=427411&view=rev
Log:
Fix for HARMONY-1003 ([classlib][text] unexpected StringIndexOutOfBoundsException for java.text.NumberFormat.parseObject(String
source, ParsePosition pos < 0))

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java?rev=427411&r1=427410&r2=427411&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/NumberFormat.java
Mon Jul 31 19:37:59 2006
@@ -455,7 +455,11 @@
 	 * @return the Number resulting from the parse, or null if there is an error
 	 */
 	public final Object parseObject(String string, ParsePosition position) {
-		return parse(string, position);
+		try {
+			return parse(string, position);
+		} catch (Exception e) {
+			return null;
+		}
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java?rev=427411&r1=427410&r2=427411&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java
Mon Jul 31 19:37:59 2006
@@ -19,6 +19,7 @@
 import java.text.FieldPosition;
 import java.text.NumberFormat;
 import java.text.ParseException;
+import java.text.ParsePosition;
 import java.util.Currency;
 import java.util.Locale;
 
@@ -213,7 +214,14 @@
         } catch (UnsupportedOperationException e) {
         }
     }
-
+    /**
+     * @tests java.text.NumberFormat#parseObject(java.lang.String, java.text.ParsePosition)
+     */
+    public void test_parseObjectLjava_lang_StringLjava_text_ParsePosition() {
+    	// regression test for HARMONY-1003
+    	assertNull(NumberFormat.getInstance().parseObject("0", new ParsePosition(-1)));
+    }
+    
     protected void setUp() {
     }
 



Mime
View raw message