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>
private Promise<NetconfClientSession> doActivate(final Channel ch, final NetconfClientSessionListener listener) {
final Promise<NetconfClientSession> activationPromise = newSessionPromise();
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."));
}
return activationPromise.setFailure(new IllegalStateException("Session (channel) already activated."));
}