Complete future outside of lock 19/103619/14
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 6 Dec 2022 22:41:32 +0000 (23:41 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 8 Dec 2022 01:21:24 +0000 (02:21 +0100)
We should not be completing futures while holding locks, as that can
lead to deadlocks. Move completion to once we have released to lock.

JIRA: NETCONF-924
Change-Id: Ic75e953bafa0b15372588a9f5c79c9436a876002
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/listener/NetconfDeviceCommunicator.java

index 9644a9d6d3375fdcdc5f74d2056562ca609b8114..510de677852c6203b7e0c91eba0a1ea0aabbba55 100644 (file)
@@ -126,13 +126,14 @@ public class NetconfDeviceCommunicator implements NetconfClientSessionListener,
             }
 
             remoteDevice.onRemoteSessionUp(netconfSessionPreferences, this);
-            if (!firstConnectionFuture.isDone()) {
-                // FIXME: right, except ... this does not include the device schema setup, so is it really useful?
-                firstConnectionFuture.set(Empty.value());
-            }
         } finally {
             sessionLock.unlock();
         }
+
+        // FIXME: right, except ... this does not include the device schema setup, so is it really useful?
+        if (!firstConnectionFuture.set(Empty.value())) {
+            LOG.trace("{}: First connection already completed", id);
+        }
     }
 
     /**