The issue [1] does not seem like a bug to me as the behavior appears to be as 
expected from the specification but I would like to see whether anyone else 
agrees.

Assuming the nodes “userRoot/a” and “userRoot/a/a1” do not already exist, if 
the test [2] is run twice in succession, the printed output of the first run is

"a" exists: false
"a1" exists: false

and that of the second run is

"a" exists: true
"a1" exists: false

This appears to be consistent with this statement in the class level 
specification of j.u.Preferences [3]:

"Normal termination of the Java Virtual Machine will not result in the loss of 
pending updates -- an explicit flush invocation is not required upon 
termination to ensure that pending updates are made persistent.”

I verified that the behavior is consistent with this across Linux, OS X, and 
Windows.

Any comment would be appreciated.

Thanks,

Brian

[1] https://bugs.openjdk.java.net/browse/JDK-8151955
[2] RemoveNodeTest.java

import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;

public class RemoveNodeTest {
    public static void main(String[] args) throws BackingStoreException {
        Preferences userRoot = Preferences.userRoot();
        System.out.printf("\"a\" exists: %s%n", userRoot.nodeExists("a"));
        Preferences a = userRoot.node("a");
        System.out.printf("\"a1\" exists: %s%n", a.nodeExists("a1"));
        Preferences a1 = a.node("a1");
        a.flush();
        a1.removeNode();
    }
}

[3] http://download.java.net/java/jdk9/docs/api/java/util/prefs/Preferences.html

Reply via email to