Perform delegate cursor enter/exit first 95/45895/4
authorRobert Varga <rovarga@cisco.com>
Tue, 20 Sep 2016 14:01:08 +0000 (16:01 +0200)
committerRobert Varga <rovarga@cisco.com>
Wed, 21 Sep 2016 11:50:41 +0000 (13:50 +0200)
Delegate may fail to perform the operation, which would leave
our stack inconsistent, leading to confusion if the user ignores
exceptions. Perform enter/exit on delegate first and only if it
succeeds proceed to update our stack.

Change-Id: If6ebfd9b530e9052a5dc8cab120a5d0c8317f937
Signed-off-by: Robert Varga <rovarga@cisco.com>
dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeWriteTransaction.java

index ab41a4bc5e8e35979fcbc6d0b13c2d32fe36c920..53feef2dc4aa6a87c69734eaba1ce011aca8acf4 100644 (file)
@@ -173,8 +173,8 @@ final class ShardedDOMDataTreeWriteTransaction implements DOMDataTreeCursorAware
         @Override
         public void enter(@Nonnull final PathArgument child) {
             checkAvailable(child);
-            path.push(child);
             delegate.enter(child);
+            path.push(child);
         }
 
         @Override
@@ -193,16 +193,16 @@ final class ShardedDOMDataTreeWriteTransaction implements DOMDataTreeCursorAware
 
         @Override
         public void exit() {
-            path.pop();
             delegate.exit();
+            path.pop();
         }
 
         @Override
         public void exit(final int depth) {
+            delegate.exit(depth);
             for (int i = 0; i < depth; i++) {
                 path.pop();
             }
-            delegate.exit(depth);
         }
 
         @Override