if (undecodables == decoders.length) {
// Throw an exception if all decoders cannot decode data.
String dump = in.getHexDump();
in.position(in.limit()); // Skip data
ProtocolDecoderException e = new ProtocolDecoderException(
"No appropriate message decoder: " + dump);
e.setHexdump(dump);
throw e;
}
if (state.currentDecoder == null) {
// Decoder is not determined yet (i.e. we need more data)
return false;
}
}
MessageDecoderResult result = state.currentDecoder.decode(session, in,
out);
if (result == MessageDecoder.OK) {
state.currentDecoder = null;
return true;
} else if (result == MessageDecoder.NEED_DATA) {
return false;
} else if (result == MessageDecoder.NOT_OK) {
state.currentDecoder = null;
throw new ProtocolDecoderException(
"Message decoder returned NOT_OK.");
} else {
state.currentDecoder = null;
throw new IllegalStateException(
"Unexpected decode result (see your decode()): "