harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r765529 - in /harmony/enhanced/classlib/trunk/modules/prefs/src: main/java/java/util/prefs/AbstractPreferences.java test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java
Date Thu, 16 Apr 2009 09:11:55 GMT
Author: regisxu
Date: Thu Apr 16 09:11:55 2009
New Revision: 765529

URL: http://svn.apache.org/viewvc?rev=765529&view=rev
Log:
Apply patch for HARMONY-6108:  [classlib] [prefs] Preferences.nodeExists(null) should throw
NPE when Preferences node has been removed

Modified:
    harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
    harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java

Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java?rev=765529&r1=765528&r2=765529&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
Thu Apr 16 09:11:55 2009
@@ -609,6 +609,9 @@
 
     @Override
     public boolean nodeExists(String name) throws BackingStoreException {
+        if (null == name) {
+            throw new NullPointerException();
+        }
         AbstractPreferences startNode = null;
         synchronized (lock) {
             if (isRemoved()) {

Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java?rev=765529&r1=765528&r2=765529&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java
Thu Apr 16 09:11:55 2009
@@ -553,6 +553,25 @@
         assertTrue(pref.nodeExists("child2/grandchild"));
     }
 
+    public void test_nodeExists() throws BackingStoreException {
+        AbstractPreferences test = (AbstractPreferences) Preferences.userRoot()
+                .node("test");
+        try {
+            test.nodeExists(null);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+
+        test.removeNode();
+        try {
+            test.nodeExists(null);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
     public void testParent() {
         assertSame(parent, pref.parent());
         AbstractPreferences child1 = new MockAbstractPreferences(pref, "child1");



Mime
View raw message