Only patch the encoder if it was found.

This commit is contained in:
Kristian S. Stangeland 2013-12-08 14:34:55 +01:00
parent b947ed1193
commit be95fbc430

View File

@ -200,12 +200,12 @@ class ChannelInjector extends ByteToMessageDecoder {
// Get the vanilla decoder, so we don't have to replicate the work // Get the vanilla decoder, so we don't have to replicate the work
vanillaDecoder = (ByteToMessageDecoder) originalChannel.pipeline().get("decoder"); vanillaDecoder = (ByteToMessageDecoder) originalChannel.pipeline().get("decoder");
vanillaEncoder = (MessageToByteEncoder<Object>) originalChannel.pipeline().get("encoder"); vanillaEncoder = (MessageToByteEncoder<Object>) originalChannel.pipeline().get("encoder");
patchEncoder(vanillaEncoder);
if (vanillaDecoder == null) if (vanillaDecoder == null)
throw new IllegalArgumentException("Unable to find vanilla decoder.in " + originalChannel.pipeline()); throw new IllegalArgumentException("Unable to find vanilla decoder.in " + originalChannel.pipeline());
if (vanillaEncoder == null) if (vanillaEncoder == null)
throw new IllegalArgumentException("Unable to find vanilla encoder in " + originalChannel.pipeline()); throw new IllegalArgumentException("Unable to find vanilla encoder in " + originalChannel.pipeline());
patchEncoder(vanillaEncoder);
if (DECODE_BUFFER == null) if (DECODE_BUFFER == null)
DECODE_BUFFER = FuzzyReflection.getMethodAccessor(vanillaDecoder.getClass(), DECODE_BUFFER = FuzzyReflection.getMethodAccessor(vanillaDecoder.getClass(),