JDK-4709908 : Preferences.remove() logs error if value already removed
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-06-28
  • Updated: 2003-04-12
  • Resolved: 2002-09-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2 mantisFixed
Related Reports
Duplicate :  
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
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
14-06-2004

EVALUATION The reporter is correct; the observed behavior violates the spec and is inconsistent with the behavior on Solaris. ###@###.### 2002-07-15
15-07-2002