@DisplayName("test_decode_WithNotIntact") @Test void testDecodeWithNotIntact() { ByteBuf out = PooledByteBufAllocator.DEFAULT.heapBuffer(); out.writeByte(0xbc); out.writeByte(0xc0); out.writeByte(1); out.writeByte(0); out.writeInt(1); out.writeByte(0); out.writeInt(1); MultiMessage msg = (MultiMessage) codec.decode(connection, out); assertNull(msg); }
@Override public Object decode(Connection connection, ByteBuf in) throws CodecException { MultiMessage multiMessage = null; while (in.readableBytes() > 0) { int readerIndex = in.readerIndex(); try { Object msg = super.decode(connection, in); if (multiMessage == null) { multiMessage = MultiMessage.create(); } multiMessage.addMessage(msg); } catch (PacketUnknownCodecException | PacketSizeLimitCodecException e) { in.readerIndex(readerIndex); throw e; } catch (PacketNotIntactCodecException e) { in.readerIndex(readerIndex); break; } } return multiMessage; }
MultiPacketCodec extends MessageToPacketCodec { @Override public Object decode(Connection connection, ByteBuf in) throws CodecException { MultiMessage multiMessage = null; while (in.readableBytes() > 0) { int readerIndex = in.readerIndex(); try { Object msg = super.decode(connection, in); if (multiMessage == null) { multiMessage = MultiMessage.create(); } multiMessage.addMessage(msg); } catch (PacketUnknownCodecException | PacketSizeLimitCodecException e) { in.readerIndex(readerIndex); throw e; } catch (PacketNotIntactCodecException e) { in.readerIndex(readerIndex); break; } } return multiMessage; } }
MultiPacketCodec extends MessageToPacketCodec { @Override public Object decode(Connection connection, ByteBuf in) throws CodecException { MultiMessage multiMessage = null; while (in.readableBytes() > 0) { int readerIndex = in.readerIndex(); try { Object msg = super.decode(connection, in); if (multiMessage == null) { multiMessage = MultiMessage.create(); } multiMessage.addMessage(msg); } catch (PacketUnknownCodecException | PacketSizeLimitCodecException e) { in.readerIndex(readerIndex); throw e; } catch (PacketNotIntactCodecException e) { in.readerIndex(readerIndex); break; } } return multiMessage; } MultiPacketCodec();  MultiPacketCodec(PacketToMessageConverter converter);  MultiPacketCodec(PacketToMessageConverter converter, PacketCodec packetCodec); }
MultiPacketCodec extends MessageToPacketCodec { @Override public Object decode(Connection connection, ByteBuf in) throws CodecException { MultiMessage multiMessage = null; while (in.readableBytes() > 0) { int readerIndex = in.readerIndex(); try { Object msg = super.decode(connection, in); if (multiMessage == null) { multiMessage = MultiMessage.create(); } multiMessage.addMessage(msg); } catch (PacketUnknownCodecException | PacketSizeLimitCodecException e) { in.readerIndex(readerIndex); throw e; } catch (PacketNotIntactCodecException e) { in.readerIndex(readerIndex); break; } } return multiMessage; } MultiPacketCodec();  MultiPacketCodec(PacketToMessageConverter converter);  MultiPacketCodec(PacketToMessageConverter converter, PacketCodec packetCodec); @Override void encode(Connection connection, Object message, ByteBuf out); @Override Object decode(Connection connection, ByteBuf in); }
MultiPacketCodec extends MessageToPacketCodec { @Override public Object decode(Connection connection, ByteBuf in) throws CodecException { MultiMessage multiMessage = null; while (in.readableBytes() > 0) { int readerIndex = in.readerIndex(); try { Object msg = super.decode(connection, in); if (multiMessage == null) { multiMessage = MultiMessage.create(); } multiMessage.addMessage(msg); } catch (PacketUnknownCodecException | PacketSizeLimitCodecException e) { in.readerIndex(readerIndex); throw e; } catch (PacketNotIntactCodecException e) { in.readerIndex(readerIndex); break; } } return multiMessage; } MultiPacketCodec();  MultiPacketCodec(PacketToMessageConverter converter);  MultiPacketCodec(PacketToMessageConverter converter, PacketCodec packetCodec); @Override void encode(Connection connection, Object message, ByteBuf out); @Override Object decode(Connection connection, ByteBuf in);  }