Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7160242

(prefs) Preferences.remove(null) does not throw NPE [macosx]

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • 7, 8
    • core-libs
    • b38
    • generic
    • os_x
    • Verified

        Preferences remove(String key) should throw
        NullPointerException - if key is null.

        But on Mac OS X (tested with Lion), the expected NPE is not thrown.


        import java.util.prefs.*;
        import java.util.*;

        public class Remove {
            public static void main(String[] args) throws Exception {
               try {
                   Nodes userNode = new Nodes();
                   Preferences userRoot = Preferences.userRoot();
                   Preferences N1 = userRoot.node("N1");
                   N1.remove(null);
                   System.out.println("Test Fail: expected exception not thrown");
               } catch(NullPointerException npe) {
                   System.out.println("Test Pass: Expected NullPointerException thrown = " + npe);
               } catch(Exception e) {
                   System.out.println("Test Fail");
                   e.printStackTrace();
               }

             }

        }

              khazra Kurchi Subhra Hazra
              amlu Amy Lu (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: