protocol-framework: use lambdas
[controller.git] / opendaylight / commons / protocol-framework / src / main / java / org / opendaylight / protocol / framework / AbstractSessionNegotiator.java
index 8a19828c578d21b5a29b0c6ca14ddbea5831b889..a883eaf4ea1fa55980f3f897d4dcb45ca500c2bf 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.protocol.framework;
 
 import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelFutureListener;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.ChannelInboundHandlerAdapter;
@@ -25,7 +24,7 @@ import com.google.common.base.Preconditions;
  * needing to provide only
  *
  * @param <M> Protocol message type
- * @param <S> Protocol session type, has to extend ProtocolSession<M>
+ * @param <S> Protocol session type, has to extend {@code ProtocolSession<M>}
  */
 @Deprecated
 public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSession<?>> extends ChannelInboundHandlerAdapter implements SessionNegotiator<S> {
@@ -61,15 +60,12 @@ public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSes
      */
     protected final void sendMessage(final M msg) {
         this.channel.writeAndFlush(msg).addListener(
-                new ChannelFutureListener() {
-                    @Override
-                    public void operationComplete(final ChannelFuture f) {
-                        if (!f.isSuccess()) {
-                            LOG.info("Failed to send message {}", msg, f.cause());
-                            negotiationFailed(f.cause());
-                        } else {
-                            LOG.trace("Message {} sent to socket", msg);
-                        }
+                (ChannelFutureListener) f -> {
+                    if (!f.isSuccess()) {
+                        LOG.info("Failed to send message {}", msg, f.cause());
+                        negotiationFailed(f.cause());
+                    } else {
+                        LOG.trace("Message {} sent to socket", msg);
                     }
                 });
     }
@@ -79,7 +75,7 @@ public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSes
         LOG.debug("Starting session negotiation on channel {}", channel);
         try {
             startNegotiation();
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOG.warn("Unexpected negotiation failure", e);
             negotiationFailed(e);
         }
@@ -91,7 +87,7 @@ public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSes
         LOG.debug("Negotiation read invoked on channel {}", channel);
         try {
             handleMessage((M)msg);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOG.debug("Unexpected error while handling negotiation message {}", msg, e);
             negotiationFailed(e);
         }