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

(prefs) Document Preferences.put throws SecurityException writing to System Prefs

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4
    • None
    • 5.0
    • core-libs
    • x86
    • windows_xp

    Description

      FULL PRODUCT VERSION :
      JDK 1.5.0_01

      A DESCRIPTION OF THE PROBLEM :
      The Preferences.put(String, String) method throws a SecurityException when the documentation does not state so, and the general description of how Preferences are implemented indicates that puts are to an in memory location and only after a sync, which can throw a BackingStoreException, will the values be persisted.

      Here the put is apparently followed by an implicit sync, which fails (for obvious reasons of not having the permission to write the HKEY_LOCAL_MACHINE registry hive) not with a BackingStoreException, but with a SecurityException.

      At the very least the method should document the possible failure using a SecurityException.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Attempt to put a value in a System Preferences node when the current user running the process does not have Admin privileges on the machine, and thus cannot write to HKEY_LOCAL_MACHINE.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The put should succeeded, and later on a BackingStoreException should be thrown during an explicit or implicit sync.
      ACTUAL -
      An unexpected and undocumented exception is thrown by a simple put().

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.SecurityException: Could not open windows registry node Software\JavaSoft\Prefs\com\lgc\buildmagic at root 0x80000002: Access denied

              at java.util.prefs.WindowsPreferences.openKey(WindowsPreferences.java:496)

              at java.util.prefs.WindowsPreferences.openKey(WindowsPreferences.java:463)

              at java.util.prefs.WindowsPreferences.openKey(WindowsPreferences.java:449)

              at java.util.prefs.WindowsPreferences.putSpi(WindowsPreferences.java:595)

              at java.util.prefs.AbstractPreferences.put(AbstractPreferences.java:234)

              at com.lgc.buildmagic.BuildNumber.getPreferences(BuildNumber.java:201)



      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Don't write to System Prefs but the User prefs instead.

      Attachments

        Activity

          People

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Imported:
              Indexed: