You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2006/07/24 07:16:56 UTC

svn commit: r424905 - in /incubator/harmony/enhanced/classlib/trunk/modules/text/src: main/java/java/text/RuleBasedCollator.java test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java

Author: pyang
Date: Sun Jul 23 22:16:55 2006
New Revision: 424905

URL: http://svn.apache.org/viewvc?rev=424905&view=rev
Log:
Fix for HARMONY-836 (RuleBasedCollator.compare(null, null) doesn't throw NPE)

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/RuleBasedCollator.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/RuleBasedCollator.java?rev=424905&r1=424904&r2=424905&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/RuleBasedCollator.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/RuleBasedCollator.java Sun Jul 23 22:16:55 2006
@@ -1,4 +1,4 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2005, 2006 The Apache Software Foundation or its licensors, as applicable
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -148,6 +148,9 @@
 	 *         than, equivalent to, or greater than <code>target</code>.
 	 */
 	public int compare(String source, String target) {
+        if (source == null || target == null) {
+            throw new NullPointerException("one of arguments is null");
+        }
 		return this.icuColl.compare(source, target);
 	}
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java?rev=424905&r1=424904&r2=424905&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java Sun Jul 23 22:16:55 2006
@@ -264,6 +264,18 @@
     }
 
     /**
+     * @tests java.text.RuleBasedCollator.compare(java.lang.String, java.lang.String)
+     */
+    public void testCompareNull() throws Exception {
+        //Regression for HARMONY-836
+        try {
+            new RuleBasedCollator("< a").compare(null, null);
+            fail("RuleBasedCollator.compare(null, null) "
+                    + "should throw NullPointerException");
+        } catch (NullPointerException e) {}
+    }
+
+    /**
      * @tests java.text.RuleBasedCollator.RuleBasedCollator(java.lang.String)
      */
     public void testEmptyStringException() {