Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Reduce log level when invalid messages received from peers #274

Merged
merged 9 commits into from
Nov 19, 2018
Prev Previous commit
Next Next commit
Check type of cause of DecoderException since Netty will have wrapped…
… it.
  • Loading branch information
ajsutton committed Nov 18, 2018
commit 01063f972ac10e474d1b1b42c7c6f859fe8cd6c6
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.DecoderException;
import io.netty.handler.timeout.IdleStateHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -126,13 +127,17 @@ private PeerInfo parsePeerInfo(final MessageData message) {
@Override
public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable throwable)
throws Exception {
if (throwable instanceof FramingException) {
final Throwable cause =
throwable instanceof DecoderException && throwable.getCause() != null
? throwable.getCause()
: throwable;
if (cause instanceof FramingException) {
LOG.debug("Invalid incoming message", throwable);
if (connectFuture.isDone()) {
connectFuture.get().disconnect(DisconnectReason.BREACH_OF_PROTOCOL);
return;
}
} else if (throwable instanceof IOException) {
} else if (cause instanceof IOException) {
// IO failures are routine when communicating with random peers across the network.
LOG.debug("IO error while processing incoming message", throwable);
} else {
Expand Down