JDK-4703132 : flush() throws an IllegalStateException on a removed node
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 1.4.1
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_7
  • CPU: sparc
  • Submitted: 2002-06-17
  • Updated: 2002-11-27
  • Resolved: 2002-11-07
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
Description

Name: ngR10108			Date: 06/17/2002



    According to JDK 1.4 documentation (see Preferences.removeNode() javadocs) :

    "Removes this preference node and all of its descendants, invalidating any
    preferences contained in the removed nodes. Once a node has been removed,
    attempting any method other than name(), absolutePath(), isUserNode(),
    flush() or nodeExists("") on the corresponding Preferences instance will
    fail with an IllegalStateException...

    The removal is not guaranteed to be persistent until the flush method is
    called on this node (or an ancestor)"

    But, according to Preferences.flush() javadocs :

    "...
    Throws : 
	IllegalStateException - if this node (or an ancestor) has been removed
                                with the removeNode() method"

    There is a conflict : I have to call flush() to make my changes persistent
    but I can not call flush() because a node has been removed.

    The implementation does demonstrate the conflict. Test case :

	import java.util.prefs.*;
	
	public final class Prefs14 {
	
	    public static void main(String args[]) {
		Preferences root = Preferences.userRoot();
	
		try {
		    Preferences node = root.node("1/2/3");
		    node.flush();
		    System.out.println("Node "+node+" has been created");
		    System.out.println("Removing node "+node);
		    node.removeNode();
		    node.flush();
		} catch  (Exception e) {
		    e.printStackTrace();
		}
	    }
	}

    Result:

    Node User Preference Node: /1/2/3 has been created
    Removing node User Preference Node: /1/2/3
    java.lang.IllegalStateException: Node has been removed
        at java.util.prefs.AbstractPreferences.sync2(AbstractPreferences.java:1311)
        at java.util.prefs.AbstractPreferences.sync(AbstractPreferences.java:1303)
        at java.util.prefs.FileSystemPreferences.sync(FileSystemPreferences.java:740)
        at java.util.prefs.FileSystemPreferences.flush(FileSystemPreferences.java:814)
        at Prefs14.main(Prefs14.java:14)

  
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis FIXED IN: mantis INTEGRATED IN: mantis mantis-b07 VERIFIED IN: mantis-beta
14-06-2004

EVALUATION To be fixed in Mantis
11-06-2004

PUBLIC COMMENTS Do not call flush() on a removed node. ###@###.### 2002-06-17
17-06-2002