Fix Jdk8 compatibility
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / HandshakeManagerImpl.java
index bdb13f748fdca34e563f1ba795bb73a5114869ac..b108d336380b8429d28a512c53d9a7b19873220e 100644 (file)
@@ -13,6 +13,11 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
+import org.opendaylight.openflowplugin.ConnectionException;
+import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
+import org.opendaylight.openflowplugin.api.openflow.md.core.ErrorHandler;
+import org.opendaylight.openflowplugin.api.openflow.md.core.HandshakeListener;
+import org.opendaylight.openflowplugin.api.openflow.md.core.HandshakeManager;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput;
@@ -115,6 +120,7 @@ public class HandshakeManagerImpl implements HandshakeManager {
         } catch (Exception ex) {
             errorHandler.handleException(ex, null);
             connectionAdapter.disconnect();
+            handshakeListener.onHandshakeFailure();
             LOG.trace("ret - shake fail: {}", ex.getMessage());
         }
     }
@@ -287,8 +293,11 @@ public class HandshakeManagerImpl implements HandshakeManager {
             RpcUtil.smokeRpc(helloResult);
             LOG.debug("FIRST HELLO sent.");
         } catch (Exception e) {
-            LOG.debug("FIRST HELLO sending failed.");
-            throw e;
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("FIRST HELLO sent.", e);
+            }
+            handshakeListener.onHandshakeFailure();
+            throw new ConnectionException("FIRST HELLO sending failed because of connection issue.");
         }
     }
 
@@ -296,7 +305,7 @@ public class HandshakeManagerImpl implements HandshakeManager {
     /**
      * after handshake set features, register to session
      * @param proposedVersion
-     * @param xId
+     * @param xid
      * @throws Exception 
      */
     protected void postHandshake(Short proposedVersion, Long xid) throws Exception {
@@ -330,11 +339,13 @@ public class HandshakeManagerImpl implements HandshakeManager {
             // handshake failed
             LOG.warn("issuing disconnect during handshake, reason: future expired", e);
             connectionAdapter.disconnect();
+            handshakeListener.onHandshakeFailure();
             throw e;
         } catch (Exception e) {
             // handshake failed
             LOG.warn("issuing disconnect during handshake, reason - RPC: {}", e.getMessage(), e);
             connectionAdapter.disconnect();
+            handshakeListener.onHandshakeFailure();
             throw e;
         }