@Test(expected = IllegalArgumentException.class) public void testMagicNumberCheckFail() throws Exception { ByteBuf buf = Unpooled.buffer(); buf.writeBytes(new byte[] { 1, 2, 3, 4 }); MessageCodec codec = new DefaultMessageCodec(); codec.decode("topic", buf, String.class); }
@Override public BaseConsumerMessage<?> decode(String topic, ByteBuf buf, Class<?> bodyClazz) { Magic.readAndCheckMagic(buf); MessageCodecVersion version = getVersion(buf); return version.getHandler().decode(topic, buf, bodyClazz); }
DefaultMessageCodec implements MessageCodec { @Override public BaseConsumerMessage<?> decode(String topic, ByteBuf buf, Class<?> bodyClazz) { Magic.readAndCheckMagic(buf); MessageCodecVersion version = getVersion(buf); return version.getHandler().decode(topic, buf, bodyClazz); } }
DefaultMessageCodec implements MessageCodec { @Override public BaseConsumerMessage<?> decode(String topic, ByteBuf buf, Class<?> bodyClazz) { Magic.readAndCheckMagic(buf); MessageCodecVersion version = getVersion(buf); return version.getHandler().decode(topic, buf, bodyClazz); }  }
DefaultMessageCodec implements MessageCodec { @Override public BaseConsumerMessage<?> decode(String topic, ByteBuf buf, Class<?> bodyClazz) { Magic.readAndCheckMagic(buf); MessageCodecVersion version = getVersion(buf); return version.getHandler().decode(topic, buf, bodyClazz); }  @Override void encode(ProducerMessage<?> msg, ByteBuf buf); @Override byte[] encode(ProducerMessage<?> msg); @Override PartialDecodedMessage decodePartial(ByteBuf buf); @Override BaseConsumerMessage<?> decode(String topic, ByteBuf buf, Class<?> bodyClazz); @Override void encodePartial(PartialDecodedMessage msg, ByteBuf buf); }
DefaultMessageCodec implements MessageCodec { @Override public BaseConsumerMessage<?> decode(String topic, ByteBuf buf, Class<?> bodyClazz) { Magic.readAndCheckMagic(buf); MessageCodecVersion version = getVersion(buf); return version.getHandler().decode(topic, buf, bodyClazz); }  @Override void encode(ProducerMessage<?> msg, ByteBuf buf); @Override byte[] encode(ProducerMessage<?> msg); @Override PartialDecodedMessage decodePartial(ByteBuf buf); @Override BaseConsumerMessage<?> decode(String topic, ByteBuf buf, Class<?> bodyClazz); @Override void encodePartial(PartialDecodedMessage msg, ByteBuf buf);  }