@Override
    public HandlerStatus onRead() throws Exception {
        src.flip();
        try {
            while (src.hasRemaining()) {
                Packet packet = packetReader.readFrom(src);
                if (packet == null) {
                    break;
                }
                onPacketComplete(packet);
            }

            return CLEAN;
        } finally {
            compactOrClear(src);
        }
    }
@Test
    public void whenPriorityPacket() throws Exception {
        ByteBuffer src = ByteBuffer.allocate(1000);
        Packet packet = new Packet(serializationService.toBytes("foobar"))
                .raiseFlags(Packet.FLAG_URGENT);
        new PacketIOHelper().writeTo(packet, src);

        decoder.src(src);
        decoder.onRead();

        assertEquals(1, dispatcher.packets.size());
        Packet found = dispatcher.packets.get(0);
        assertEquals(packet, found);
        assertEquals(0, normalPacketCounter.get());
        assertEquals(1, priorityPacketCounter.get());
    }