X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fconnection%2Flistener%2FSystemNotificationsListenerImpl.java;h=5f7a8e9d04d1decb93e6ccbbf9fb7cdf6858ce7c;hb=e8c5df4f582ceadbe6cfea719a2308cc26058e78;hp=1d5263a8a7af15d1f55d1f09f7425ea4fde43bcf;hpb=da5cf58ce1a5dd90aa84e2d5dd984d6cfa030a21;p=openflowplugin.git diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.java index 1d5263a8a7..5f7a8e9d04 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/connection/listener/SystemNotificationsListenerImpl.java @@ -11,6 +11,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import java.net.InetSocketAddress; import java.util.Date; +import java.util.Objects; import java.util.concurrent.Future; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -33,8 +34,10 @@ import org.slf4j.LoggerFactory; */ public class SystemNotificationsListenerImpl implements SystemNotificationsListener { - private final ConnectionContext connectionContext; private static final Logger LOG = LoggerFactory.getLogger(SystemNotificationsListenerImpl.class); + private static final Xid ECHO_XID = new Xid(0L); + + private final ConnectionContext connectionContext; @VisibleForTesting static final long MAX_ECHO_REPLY_TIMEOUT = 2000; private final long echoReplyTimeout; @@ -71,14 +74,14 @@ public class SystemNotificationsListenerImpl implements SystemNotificationsListe connectionContext.changeStateToTimeouting(); EchoInputBuilder builder = new EchoInputBuilder(); builder.setVersion(features.getVersion()); - Xid xid = new Xid(0L); - builder.setXid(xid.getValue()); + builder.setXid(ECHO_XID.getValue()); Future> echoReplyFuture = connectionContext.getConnectionAdapter().echo(builder.build()); try { RpcResult echoReplyValue = echoReplyFuture.get(echoReplyTimeout, TimeUnit.MILLISECONDS); - if (echoReplyValue.isSuccessful()) { + if (echoReplyValue.isSuccessful() && + Objects.equals(echoReplyValue.getResult().getXid(), ECHO_XID.getValue())) { connectionContext.changeStateToWorking(); shouldBeDisconnected = false; } else {