Report when packets are not fully read.

This commit is contained in:
Steven Smith 2015-08-24 20:15:51 -07:00
parent 62d5509768
commit 885d03759d

View file

@ -39,6 +39,11 @@ public class TcpPacketCodec extends ByteToMessageCodec<Packet> {
Packet packet = this.session.getPacketProtocol().createIncomingPacket(id); Packet packet = this.session.getPacketProtocol().createIncomingPacket(id);
packet.read(in); packet.read(in);
if(buf.readableBytes() > 0) {
throw new IllegalStateException("Packet \"" + packet.getClass().getSimpleName() + "\" not fully read.");
}
if(packet.isPriority()) { if(packet.isPriority()) {
this.session.callEvent(new PacketReceivedEvent(this.session, packet)); this.session.callEvent(new PacketReceivedEvent(this.session, packet));
} }