Bug-6005: PCErr generated while parsing of received PCRpt message is not sent out 69/39969/3
authorAjay <ajayl.bro@gmail.com>
Tue, 7 Jun 2016 18:08:06 +0000 (18:08 +0000)
committerMilos Fabian <milfabia@cisco.com>
Wed, 8 Jun 2016 09:46:03 +0000 (09:46 +0000)
- use Channel#writeAndFlush instead of ChannelHandlerContext#write when sending out PCEP error message so that decode handler is invoked
- added listener to ChannelFuture to log result of send operation

Change-Id: I03003577003c2f509b5a7a5ae0d1decdd12555c6
Signed-off-by: Ajay <ajayl.bro@gmail.com>
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPByteToMessageDecoder.java

index 6b00897598cf72022de22cafb660310a1a723617..c7cbd42fbdd4a73fa06e6a41bef0486c181e92f0 100644 (file)
@@ -269,7 +269,7 @@ public class BGPSessionImpl extends SimpleChannelInboundHandler<Notification> im
                     @Override
                     public void operationComplete(final ChannelFuture f) {
                         if (!f.isSuccess()) {
-                            LOG.warn("Failed to send message {} to socket {}", msg, f.cause(), BGPSessionImpl.this.channel);
+                            LOG.warn("Failed to send message {} to socket {}", msg, BGPSessionImpl.this.channel, f.cause());
                         } else {
                             LOG.trace("Message {} sent to socket {}", msg, BGPSessionImpl.this.channel);
                         }
index 1060db9e055fad480fee9ca1aeb7af647efc9132..2b3809ead0a98fb5120b03b8b8a897b256acb16c 100644 (file)
@@ -10,6 +10,8 @@ package org.opendaylight.protocol.pcep.impl;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufUtil;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelFutureListener;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.handler.codec.ByteToMessageDecoder;
 import java.util.ArrayList;
@@ -55,9 +57,17 @@ public final class PCEPByteToMessageDecoder extends ByteToMessageDecoder {
         if (!errors.isEmpty()) {
             // We have a bunch of messages, send them out
             for (final Object e : errors) {
-                ctx.write(e);
+                ctx.channel().writeAndFlush(e).addListener(new ChannelFutureListener() {
+                    @Override
+                    public void operationComplete(final ChannelFuture f) {
+                        if (!f.isSuccess()) {
+                            LOG.warn("Failed to send message {} to socket {}", e, ctx.channel(), f.cause());
+                        } else {
+                            LOG.trace("Message {} sent to socket {}", e, ctx.channel());
+                        }
+                    }
+                });
             }
-            ctx.flush();
         }
     }