Fix checkstyle warnings for impl/connection package and OpenFlowPluginProviderImpl
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / connection / listener / HandshakeListenerImpl.java
index 696743f31a744ffa8f3a8576457affd239d35dfd..9ec64066e0c3655593c69a4e31f0c047661b6d05 100644 (file)
@@ -28,9 +28,6 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- *
- */
 public class HandshakeListenerImpl implements HandshakeListener {
 
     private static final Logger LOG = LoggerFactory.getLogger(HandshakeListenerImpl.class);
@@ -40,10 +37,13 @@ public class HandshakeListenerImpl implements HandshakeListener {
     private HandshakeContext handshakeContext;
 
     /**
-     * @param connectionContext
-     * @param deviceConnectedHandler
+     * Constructor.
+     *
+     * @param connectionContext - connection context
+     * @param deviceConnectedHandler - device connected handler
      */
-    public HandshakeListenerImpl(final ConnectionContext connectionContext, final DeviceConnectedHandler deviceConnectedHandler) {
+    public HandshakeListenerImpl(final ConnectionContext connectionContext,
+                                 final DeviceConnectedHandler deviceConnectedHandler) {
         this.connectionContext = connectionContext;
         this.deviceConnectedHandler = deviceConnectedHandler;
     }
@@ -67,28 +67,31 @@ public class HandshakeListenerImpl implements HandshakeListener {
     private FutureCallback<RpcResult<BarrierOutput>> addBarrierCallback() {
         return new FutureCallback<RpcResult<BarrierOutput>>() {
             @Override
+            @SuppressWarnings("checkstyle:IllegalCatch")
             public void onSuccess(@Nullable final RpcResult<BarrierOutput> result) {
                 if (LOG.isDebugEnabled()) {
-                    LOG.debug("succeeded by getting sweep barrier after post-handshake for device {}", connectionContext.getNodeId().getValue());
+                    LOG.debug("succeeded by getting sweep barrier after post-handshake for device {}",
+                            connectionContext.getDeviceInfo());
                 }
                 try {
                     ConnectionStatus connectionStatusResult = deviceConnectedHandler.deviceConnected(connectionContext);
-                    if (!ConnectionStatus.MAY_CONTINUE.equals(connectionStatusResult)) {
-                        connectionContext.closeConnection(true);
+                    if (connectionStatusResult != ConnectionStatus.MAY_CONTINUE) {
+                        connectionContext.closeConnection(false);
                     }
-                    SessionStatistics.countEvent(connectionContext.getNodeId().toString(),
+                    SessionStatistics.countEvent(connectionContext.getDeviceInfo().toString(),
                             SessionStatistics.ConnectionStatus.CONNECTION_CREATED);
                 } catch (final Exception e) {
-                    LOG.error("ConnectionContext initial processing failed: ", e);
-                    SessionStatistics.countEvent(connectionContext.getNodeId().toString(),
+                    LOG.warn("initial processing failed for device {}", connectionContext.getDeviceInfo(), e);
+                    SessionStatistics.countEvent(connectionContext.getDeviceInfo().toString(),
                             SessionStatistics.ConnectionStatus.CONNECTION_DISCONNECTED_BY_OFP);
                     connectionContext.closeConnection(true);
                 }
             }
 
             @Override
-            public void onFailure(final Throwable t) {
-                LOG.error("failed to get sweep barrier after post-handshake for device {}", connectionContext.getNodeId());
+            public void onFailure(final Throwable throwable) {
+                LOG.warn("failed to get sweep barrier after post-handshake for device {}",
+                        connectionContext.getDeviceInfo(), throwable);
                 connectionContext.closeConnection(false);
             }
         };