private static CouchbaseResponse handleSubdocumentMultiLookupResponseMessages ( BinaryRequest request , FullBinaryMemcacheResponse msg , ChannelHandlerContext ctx , ResponseStatus status ) { if ( ! ( request instanceof BinarySubdocMultiLookupRequest ) ) return null ; BinarySubdocMultiLookupRequest subdocRequest = ( BinarySubdocMultiLookupRequest ) request ; short statusCode = msg . getStatus ( ) ; long cas = msg . getCAS ( ) ; String bucket = request . bucket ( ) ; ByteBuf body = msg . content ( ) ; List < MultiResult < Lookup > > responses ; if ( status . isSuccess ( ) || ResponseStatus . SUBDOC_MULTI_PATH_FAILURE . equals ( status ) ) { long bodyLength = body . readableBytes ( ) ; List < LookupCommand > commands = subdocRequest . commands ( ) ; responses = new ArrayList < MultiResult < Lookup > > ( commands . size ( ) ) ; for ( LookupCommand cmd : commands ) { if ( msg . content ( ) . readableBytes ( ) < 6 ) { body . release ( ) ; throw new IllegalStateException ( "Expected " + commands . size ( ) + " lookup responses, only got " + responses . size ( ) + ", total of " + bodyLength + " bytes" ) ; } short cmdStatus = body . readShort ( ) ; int valueLength = body . readInt ( ) ; ByteBuf value = ctx . alloc ( ) . buffer ( valueLength , valueLength ) ; value . writeBytes ( body , valueLength ) ; responses . add ( MultiResult . create ( cmdStatus , ResponseStatusConverter . fromBinary ( cmdStatus ) , cmd . path ( ) , cmd . lookup ( ) , value ) ) ; } } else { responses = Collections . emptyList ( ) ; } body . release ( ) ; return new MultiLookupResponse ( status , statusCode , bucket , responses , subdocRequest , cas ) ; }
Helper method to decode all multi lookup response messages .