Fix permanent lock on the running configuration via RESTconf 58/95358/3
authorOleksii Mozghovyi <oleksii.mozghovyi@pantheon.tech>
Wed, 24 Feb 2021 21:41:34 +0000 (23:41 +0200)
committerRobert Varga <nite@hq.sk>
Sat, 27 Feb 2021 17:43:42 +0000 (17:43 +0000)
This resolves the issue when the NETCONF device with both
:writable-running and :candidate capabilities gets permanently
locked after the commit happens via RESTconf.

JIRA: NETCONF-705
Change-Id: I90c6ec104a9309dd25fc66cd74f469c2f033ee5f
Signed-off-by: Oleksii Mozghovyi <oleksii.mozghovyi@pantheon.tech>
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/AbstractNetconfDataTreeService.java

index de820bacdc6b6662c77442dbe38002654118a940..771f29e6ce5d510961f193cd5d35b18e29de07d7 100644 (file)
@@ -91,13 +91,12 @@ public abstract class AbstractNetconfDataTreeService implements NetconfDataTreeS
             Futures.addCallback(result, new FutureCallback<>() {
                 @Override
                 public void onSuccess(final RpcResult<Void> result) {
-                    unlock();
+                    // do nothing, as callback is only used to catch failures
                 }
 
                 @Override
                 public void onFailure(final Throwable throwable) {
                     discardChanges();
-                    unlock();
                 }
             }, MoreExecutors.directExecutor());
             return result;
@@ -329,11 +328,13 @@ public abstract class AbstractNetconfDataTreeService implements NetconfDataTreeS
                             errors.toArray(new RpcError[errors.size()])));
                     return;
                 }
+                unlock();
                 resultFuture.set(CommitInfo.empty());
             }
 
             @Override
             public void onFailure(final Throwable failure) {
+                unlock();
                 resultFuture.setException(new TransactionCommitFailedException(
                         String.format("Commit of transaction %s failed", this), failure));
             }