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

Preferences.remove() logs error if value already removed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.2
    • 1.4.0
    • core-libs
    • mantis
    • x86
    • windows_2000
    • Verified



      Name: nt126004 Date: 06/28/2002


      FULL PRODUCT VERSION :
      java version "1.4.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
      Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      Calling Preferences.remove() on a key that does not exist
      or has already been removed results in an error message
      being logged from WindowsPreferences that Win32 API
      RegDeleteValue has returned error code 2 (which is
      ERROR_FILE_NOT_FOUND).

      It also resets
      java.util.prefs.WindowsPreferences.isBackingStoreAvailable
      to false, which means Preferences.flush() will throw an
      exception instead of storing the pref changes.

      The docs for Preferences.remove() say:
      "Removes the value associated with the specified key in
      this preference node, if any."

      The "if any" implies that it is OK to call remove on a non-
      existing key - if there is no value it won't be removed
      (because it doesn't exist).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the attached RemovePref.java testcase
      2. Observe the error logged

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      I expect Preferences.remove() to do nothing if the key does
      not exist. Instead it logs a warning and disabled flushing
      prefs to the registry.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Jun 21, 2002 4:54:57 PM java.util.prefs.WindowsPreferences removeSpi
      WARNING: Could not delete windows registry value
      Software\JavaSoft\Prefs\<unnamed>\[B@372a1a at root 0x80000001. Windows
      RegDeleteValue(...) returned error code 2.



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.prefs.*;
      public class RemovePref {
      public static void main(String args[]) throws Exception {
      Preferences prefs = Preferences.userNodeForPackage
      (RemovePref.class);
      prefs.put("foo", "value");
      prefs.remove("foo");
      prefs.remove("foo");
      }
      }
      ---------- END SOURCE ----------
      (Review ID: 153975)
      ======================================================================

            busersunw Btplusnull User (Inactive)
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: