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

Preferences.remove() of non-existing key causes warning

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.4.0
    • core-libs
    • x86
    • windows_2000



      Name: rmT116609 Date: 10/31/2002


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

      FULL OPERATING SYSTEM VERSION :
      Windows 2000, SP 2

      A DESCRIPTION OF THE PROBLEM :
      Get a Preferences node, then invoke remove("does_not_exist")
      and see the warning message printed to the screen. You may
      need to set up a Logger that catches the warning and
      displays it somewhere. It seems that attempting to delete a
      key that does not exist causes this. Note that this only
      happens on Windows. It is okay on Solaris and Linux (same
      JDK versions).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Get a Preferences node.
      2. Invoke remove(String) with a non-existent key.
      3. See error message.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Should not generate a warning. Probably the
      WindowsPreferences code should check if the key exists
      before trying to delete it.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Jul 12, 2002 3:42:40 PM java.util.prefs.WindowsPreferences removeSpi
      WARNING: Could not delete windows registry value Software\JavaSoft\Prefs\test\[B
      @372a1a at root 0x80000001. Windows RegDeleteValue(...) returned error code 2.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.prefs.Preferences;

      public class prefs {

          public static void main(String[] args) {
              Preferences prefs = Preferences.userRoot().node("test");
              prefs.remove("does_not_exist");
              System.out.println("test compwelete");
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      Check if the key exists before invoking remove().
      (Review ID: 159320)
      ======================================================================

            jjb Josh Bloch (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: