Le 15/03/15 22:15, Jeff MAURY a écrit :
> Hello,
>
> I looked at the ProcolCodecFilter code and I discovered that the
> encoder/decoder states are stored in the session using a constant key.
This is clearly not going to fly.
> So
> what if a user will chain two ProtocolCodecFilter ? Am I missing something ?
No, this is actually a good catch.
Note that the ProtocolEncoder/Decoder interfaces has a
createEncoderState() method, which should be used when the codec is not
stateless. This was probably overlooked as we have only stateless decoders.
My understanding is that we should use the state from the
encoder/decoder instance, instead of depending on the one stored into
the session. A mathod like :
public void messageReceived(IoSession session, Object in,
ReadFilterChainController controller) {
LOGGER.debug("Processing a MESSAGE_RECEIVED for session {}",
session);
DECODING_STATE state = getDecodingState(session);
...
should be :
public void messageReceived(IoSession session, Object in,
ReadFilterChainController controller) {
LOGGER.debug("Processing a MESSAGE_RECEIVED for session {}",
session);
DECODING_STATE state = decoder.getDecodingState(session);
and we need two additional method (ie, getDecodingState( session ) ) in
both the encoder and decoder interfaces.