question: @ Override public void messageReceived ( NextFilter nextFilter , IoSession session , Object message ) throws Exception { LOGGER . debug ( "Processing a MESSAGE_RECEIVED for session {}" , session . getId ( ) ) ; if ( ! ( message instanceof IoBuffer ) ) { nextFilter . messageReceived ( session , message ) ; return ; } IoBuffer in = ( IoBuffer ) message ; ProtocolDecoder decoder = factory . getDecoder ( session ) ; ProtocolDecoderOutput decoderOut = getDecoderOut ( session , nextFilter ) ; while ( in . hasRemaining ( ) ) { int oldPos = in . position ( ) ; try { lock . acquire ( ) ; decoder . decode ( session , in , decoderOut ) ; decoderOut . flush ( nextFilter , session ) ; } catch ( Exception e ) { ProtocolDecoderException pde ; if ( e instanceof ProtocolDecoderException ) { pde = ( ProtocolDecoderException ) e ; } else { pde = new ProtocolDecoderException ( e ) ; } if ( pde . getHexdump ( ) == null ) { int curPos = in . position ( ) ; in . position ( oldPos ) ; pde . setHexdump ( in . getHexDump ( ) ) ; in . position ( curPos ) ; } decoderOut . flush ( nextFilter , session ) ; nextFilter . exceptionCaught ( session , pde ) ; if ( ! ( e instanceof RecoverableProtocolDecoderException ) || ( in . position ( ) == oldPos ) ) { break ; } } finally { lock . release ( ) ; } } }
target:  Process the incoming message, calling the session decoder. As the incoming buffer might contains more than one messages, we have to loop until the decoder throws an exception. while ( buffer not empty ) try decode ( buffer ) catch break;