From 885d03759dce99d1d0a4b49b156d447c0d97b70e Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Mon, 24 Aug 2015 20:15:51 -0700 Subject: [PATCH] Report when packets are not fully read. --- src/main/java/org/spacehq/packetlib/tcp/TcpPacketCodec.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/spacehq/packetlib/tcp/TcpPacketCodec.java b/src/main/java/org/spacehq/packetlib/tcp/TcpPacketCodec.java index f445e7df..83192225 100644 --- a/src/main/java/org/spacehq/packetlib/tcp/TcpPacketCodec.java +++ b/src/main/java/org/spacehq/packetlib/tcp/TcpPacketCodec.java @@ -39,6 +39,11 @@ public class TcpPacketCodec extends ByteToMessageCodec { Packet packet = this.session.getPacketProtocol().createIncomingPacket(id); packet.read(in); + + if(buf.readableBytes() > 0) { + throw new IllegalStateException("Packet \"" + packet.getClass().getSimpleName() + "\" not fully read."); + } + if(packet.isPriority()) { this.session.callEvent(new PacketReceivedEvent(this.session, packet)); }