Showing
3 changed files
with
23 additions
and
0 deletions
| ... | @@ -8,11 +8,16 @@ import io.netty.handler.codec.ReplayingDecoder; | ... | @@ -8,11 +8,16 @@ import io.netty.handler.codec.ReplayingDecoder; |
| 8 | import java.util.Arrays; | 8 | import java.util.Arrays; |
| 9 | import java.util.List; | 9 | import java.util.List; |
| 10 | 10 | ||
| 11 | +import org.slf4j.Logger; | ||
| 12 | +import org.slf4j.LoggerFactory; | ||
| 13 | + | ||
| 11 | /** | 14 | /** |
| 12 | * Decoder for inbound messages. | 15 | * Decoder for inbound messages. |
| 13 | */ | 16 | */ |
| 14 | public class MessageDecoder extends ReplayingDecoder<DecoderState> { | 17 | public class MessageDecoder extends ReplayingDecoder<DecoderState> { |
| 15 | 18 | ||
| 19 | + private final Logger log = LoggerFactory.getLogger(getClass()); | ||
| 20 | + | ||
| 16 | private final NettyMessagingService messagingService; | 21 | private final NettyMessagingService messagingService; |
| 17 | 22 | ||
| 18 | private static final KryoSerializer SERIALIZER = new KryoSerializer(); | 23 | private static final KryoSerializer SERIALIZER = new KryoSerializer(); |
| ... | @@ -57,4 +62,10 @@ public class MessageDecoder extends ReplayingDecoder<DecoderState> { | ... | @@ -57,4 +62,10 @@ public class MessageDecoder extends ReplayingDecoder<DecoderState> { |
| 57 | checkState(false, "Must not be here"); | 62 | checkState(false, "Must not be here"); |
| 58 | } | 63 | } |
| 59 | } | 64 | } |
| 65 | + | ||
| 66 | + @Override | ||
| 67 | + public void exceptionCaught(ChannelHandlerContext context, Throwable cause) { | ||
| 68 | + log.error("Exception inside channel handling pipeline.", cause); | ||
| 69 | + context.close(); | ||
| 70 | + } | ||
| 60 | } | 71 | } | ... | ... |
| 1 | package org.onlab.netty; | 1 | package org.onlab.netty; |
| 2 | 2 | ||
| 3 | +import org.slf4j.Logger; | ||
| 4 | +import org.slf4j.LoggerFactory; | ||
| 5 | + | ||
| 3 | import io.netty.buffer.ByteBuf; | 6 | import io.netty.buffer.ByteBuf; |
| 4 | import io.netty.channel.ChannelHandler.Sharable; | 7 | import io.netty.channel.ChannelHandler.Sharable; |
| 5 | import io.netty.channel.ChannelHandlerContext; | 8 | import io.netty.channel.ChannelHandlerContext; |
| ... | @@ -11,6 +14,8 @@ import io.netty.handler.codec.MessageToByteEncoder; | ... | @@ -11,6 +14,8 @@ import io.netty.handler.codec.MessageToByteEncoder; |
| 11 | @Sharable | 14 | @Sharable |
| 12 | public class MessageEncoder extends MessageToByteEncoder<InternalMessage> { | 15 | public class MessageEncoder extends MessageToByteEncoder<InternalMessage> { |
| 13 | 16 | ||
| 17 | + private final Logger log = LoggerFactory.getLogger(getClass()); | ||
| 18 | + | ||
| 14 | // onosiscool in ascii | 19 | // onosiscool in ascii |
| 15 | public static final byte[] PREAMBLE = "onosiscool".getBytes(); | 20 | public static final byte[] PREAMBLE = "onosiscool".getBytes(); |
| 16 | public static final int HEADER_VERSION = 1; | 21 | public static final int HEADER_VERSION = 1; |
| ... | @@ -47,4 +52,10 @@ public class MessageEncoder extends MessageToByteEncoder<InternalMessage> { | ... | @@ -47,4 +52,10 @@ public class MessageEncoder extends MessageToByteEncoder<InternalMessage> { |
| 47 | // write payload. | 52 | // write payload. |
| 48 | out.writeBytes(payload); | 53 | out.writeBytes(payload); |
| 49 | } | 54 | } |
| 55 | + | ||
| 56 | + @Override | ||
| 57 | + public void exceptionCaught(ChannelHandlerContext context, Throwable cause) { | ||
| 58 | + log.error("Exception inside channel handling pipeline.", cause); | ||
| 59 | + context.close(); | ||
| 60 | + } | ||
| 50 | } | 61 | } | ... | ... |
| ... | @@ -248,6 +248,7 @@ public class NettyMessagingService implements MessagingService { | ... | @@ -248,6 +248,7 @@ public class NettyMessagingService implements MessagingService { |
| 248 | 248 | ||
| 249 | @Override | 249 | @Override |
| 250 | public void exceptionCaught(ChannelHandlerContext context, Throwable cause) { | 250 | public void exceptionCaught(ChannelHandlerContext context, Throwable cause) { |
| 251 | + log.error("Exception inside channel handling pipeline.", cause); | ||
| 251 | context.close(); | 252 | context.close(); |
| 252 | } | 253 | } |
| 253 | } | 254 | } | ... | ... |
-
Please register or login to post a comment