protected int processResponse ( byte [ ] b ) { if ( DumpProtocol ) { try { System . out . println ( "resp:" + new String ( b , "UTF-8" ) ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } } Object o [ ] = ( Object [ ] ) conf . asObject ( b ) ; if ( SENDDEBUG ) System . out . println ( "RECEIVE:" + ( o . length - 1 ) ) ; int seq = ( ( Number ) o [ o . length - 1 ] ) . intValue ( ) ; if ( seq == lastSeenSeq + 1 || lastSeenSeq == 0 || noSeqChecking ) { lastSeenSeq = seq ; processDecodedResultArray ( o ) ; Object next [ ] ; while ( ( next = ( Object [ ] ) sequenceCache . get ( lastSeenSeq + 1 ) ) != null ) { lastSeenSeq ++ ; sequenceCache . remove ( lastSeenSeq ) ; log ( "replay " + lastSeenSeq ) ; processDecodedResultArray ( next ) ; } } else { log ( "ignored result with sequence:" + seq + " lastSeen:" + lastSeenSeq ) ; if ( seq > lastSeenSeq ) { sequenceCache . put ( seq , o ) ; if ( sequenceCache . size ( ) > 5 ) { disconnect ( "Unrecoverable Gap" ) ; } } } return o . length - 1 ; }
caches early responses in case of response race