United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4709908 Preferences.remove() logs error if value already removed
JDK-4709908 : Preferences.remove() logs error if value already removed

Details
Type:
Bug
Submit Date:
2002-06-28
Status:
Closed
Updated Date:
2003-04-12
Project Name:
JDK
Resolved Date:
2002-09-02
Component:
core-libs
OS:
windows_2000
Sub-Component:
java.util
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
1.4.2 (mantis)

Related Reports
Duplicate:

Sub Tasks

Description

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

                                    

Comments
EVALUATION

   The reporter is correct; the observed behavior violates the spec and is inconsistent with the behavior on Solaris.

###@###.### 2002-07-15
                                     
2002-07-15
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
mantis
mantis-b02

FIXED IN:
mantis
mantis-b02

INTEGRATED IN:
mantis
mantis-b02

VERIFIED IN:
mantis


                                     
2004-06-14



Hardware and Software, Engineered to Work Together