United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4703132 : flush() throws an IllegalStateException on a removed node

Details
Type:
Bug
Submit Date:
2002-06-17
Status:
Closed
Updated Date:
2002-11-27
Project Name:
JDK
Resolved Date:
2002-11-07
Component:
core-libs
OS:
solaris_7
Sub-Component:
java.util
CPU:
sparc
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.1
Fixed Versions:
1.4.2 (mantis)

Related Reports

Sub Tasks

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
PUBLIC COMMENTS

Do not call flush() on a removed node.


###@###.### 2002-06-17
                                     
2002-06-17
EVALUATION

To be fixed in Mantis
                                     
2004-06-11
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
mantis

FIXED IN:
mantis

INTEGRATED IN:
mantis
mantis-b07

VERIFIED IN:
mantis-beta


                                     
2004-06-14



Hardware and Software, Engineered to Work Together