Fix NETCONF session(channel) activation for the CallHome(over TLS) 48/94248/4
authorOleksii Mozghovyi <oleksii.mozghovyi@pantheon.tech>
Tue, 15 Dec 2020 13:55:16 +0000 (15:55 +0200)
committerRobert Varga <nite@hq.sk>
Wed, 16 Dec 2020 18:21:11 +0000 (18:21 +0000)
This patch fixes an issue when activation always fails with a message
saying that "Session is already activated". The root cause is the behavior
of the compareAndExchange method(returns the witness value, which will
be the same as the expected value if successful).

JIRA: NETCONF-5
Change-Id: Ib9b0acead1091c8e881330c22b99c9138605e1f1
Signed-off-by: Oleksii Mozghovyi <oleksii.mozghovyi@pantheon.tech>
netconf/callhome-protocol/src/main/java/org/opendaylight/netconf/callhome/protocol/tls/CallHomeTlsSessionContext.java

index 7d8334c1460db11def88b2e07710b64a5e6dd46e..ed62468428a99932873aca4b87ed2e70ebb637a2 100644 (file)
@@ -69,7 +69,7 @@ final class CallHomeTlsSessionContext implements CallHomeProtocolSessionContext
 
     private Promise<NetconfClientSession> doActivate(final Channel ch, final NetconfClientSessionListener listener) {
         final Promise<NetconfClientSession> activationPromise = newSessionPromise();
-        if (!activated.compareAndExchange(false, true)) {
+        if (activated.compareAndExchange(false, true)) {
             return activationPromise.setFailure(new IllegalStateException("Session (channel) already activated."));
         }