JDK 9 RFC on 8151955: java.util.prefs: removeNode() / removeNodeSpi(): Node is permanently removed even when no flush() is invoked
Roger Riggs
Roger.Riggs at Oracle.com
Thu Dec 15 15:21:05 UTC 2016
Hi Brian,
I read it to say that changes can become permanent at any time (lazy or
aggressive) and
are guaranteed to be permanent only with a flush().
It does indicate for normal termination, the equivalent of flush occurs,
making pending changes permanent.
There is no statement that ensures a change will *not* become permanent
until a specific action.
So, not a bug.
$.02, Roger
On 12/14/2016 6:20 PM, Brian Burkhalter wrote:
> 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
More information about the core-libs-dev
mailing list