private void onCachesCollected ( ) { if ( isTraceEnabled ( ) ) { log ( ) . tracef ( "[%s] All caches collected: %s" , xid , cacheNames ) ; } int size = cacheNames . size ( ) ; if ( size == 0 ) { //it can happen if all caches either commit or thrown an exception sendReply ( ) ; return ; } List < CompletableFuture < Void > > futures = new ArrayList <> ( size ) ; for ( ByteString cacheName : cacheNames ) { try { futures . add ( completeCache ( cacheName ) ) ; } catch ( Throwable t ) { hasErrors = true ; } } CompletableFuture . allOf ( futures . toArray ( new CompletableFuture [ 0 ] ) ) . thenRun ( this :: sendReply ) ; }
Invoked when all caches are ready to complete the transaction .