X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fnetconf-netty-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fnettyutil%2FAbstractNetconfSessionNegotiator.java;h=b6a26804fd3ca9879dd170e879cc509fd51e667a;hb=8c4f05fff7e41debdda08c9132e84c602d1b87cb;hp=a9adf2a668177af9dc0e5c165e028a96cea5def1;hpb=45cfee1861924b4a8086d38079ce8cbd320386d6;p=netconf.git
diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java
index a9adf2a668..b6a26804fd 100644
--- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java
+++ b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java
@@ -79,25 +79,34 @@ public abstract class AbstractNetconfSessionNegotiator
sslHandler = getSslHandler(channel);
- if (sslHandler.isPresent()) {
- Future future = sslHandler.get().handshakeFuture();
- future.addListener(new GenericFutureListener>() {
- @Override
- public void operationComplete(final Future super Channel> future) {
- Preconditions.checkState(future.isSuccess(), "Ssl handshake was not successful");
- LOG.debug("Ssl handshake complete");
- start();
- }
- });
+ if (ifNegotiatedAlready()) {
+ LOG.debug("Negotiation on channel {} already started", channel);
} else {
- start();
+ final Optional sslHandler = getSslHandler(channel);
+ if (sslHandler.isPresent()) {
+ Future future = sslHandler.get().handshakeFuture();
+ future.addListener(new GenericFutureListener>() {
+ @Override
+ public void operationComplete(final Future super Channel> future) {
+ Preconditions.checkState(future.isSuccess(), "Ssl handshake was not successful");
+ LOG.debug("Ssl handshake complete");
+ start();
+ }
+ });
+ } else {
+ start();
+ }
}
}
+ protected final synchronized boolean ifNegotiatedAlready() {
+ // Indicates whether negotiation already started
+ return this.state != State.IDLE;
+ }
+
private static Optional getSslHandler(final Channel channel) {
final SslHandler sslHandler = channel.pipeline().get(SslHandler.class);
- return sslHandler == null ? Optional.absent() : Optional.of(sslHandler);
+ return sslHandler == null ? Optional.absent() : Optional.of(sslHandler);
}
public P getSessionPreferences() {
@@ -239,7 +248,9 @@ public abstract class AbstractNetconfSessionNegotiator