JDK-4772255 : Preferences.remove() of non-existing key causes warning
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-10-31
  • Updated: 2002-12-12
  • Resolved: 2002-12-12
Related Reports
Duplicate :  
Description

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) 
======================================================================

Comments
EVALUATION I believe that this is a duplicate and has been fixed, but this should be confirmed. ###@###.### 2002-11-15
15-11-2002