@@ -90,10 +90,11 @@ private <T> T chainedInstrument(InstrumentationState state, T input, ChainedInst
9090 }
9191
9292 protected <T > ImmutableList <T > chainedMapAndDropNulls (InstrumentationState state , BiFunction <Instrumentation , InstrumentationState , T > mapper ) {
93+ ChainedInstrumentationState chainedInstrumentationState = (ChainedInstrumentationState ) state ;
9394 ImmutableList .Builder <T > result = ImmutableList .builderWithExpectedSize (instrumentations .size ());
9495 for (int i = 0 ; i < instrumentations .size (); i ++) {
9596 Instrumentation instrumentation = instrumentations .get (i );
96- InstrumentationState specificState = (( ChainedInstrumentationState ) state ) .getState (i );
97+ InstrumentationState specificState = chainedInstrumentationState .getState (i );
9798 T value = mapper .apply (instrumentation , specificState );
9899 if (value != null ) {
99100 result .add (value );
@@ -102,10 +103,11 @@ protected <T> ImmutableList<T> chainedMapAndDropNulls(InstrumentationState state
102103 return result .build ();
103104 }
104105
105- protected <T > void chainedConsume (InstrumentationState state , BiConsumer <Instrumentation , InstrumentationState > stateConsumer ) {
106+ protected void chainedConsume (InstrumentationState state , BiConsumer <Instrumentation , InstrumentationState > stateConsumer ) {
107+ ChainedInstrumentationState chainedInstrumentationState = (ChainedInstrumentationState ) state ;
106108 for (int i = 0 ; i < instrumentations .size (); i ++) {
107109 Instrumentation instrumentation = instrumentations .get (i );
108- InstrumentationState specificState = (( ChainedInstrumentationState ) state ) .getState (i );
110+ InstrumentationState specificState = chainedInstrumentationState .getState (i );
109111 stateConsumer .accept (instrumentation , specificState );
110112 }
111113 }
@@ -358,7 +360,7 @@ public CompletableFuture<ExecutionResult> instrumentExecutionResult(ExecutionRes
358360 CompletableFuture <List <ExecutionResult >> resultsFuture = Async .eachSequentially (entries , (entry , prevResults ) -> {
359361 Instrumentation instrumentation = entry .getKey ();
360362 InstrumentationState specificState = entry .getValue ();
361- ExecutionResult lastResult = prevResults .size () > 0 ? prevResults .get (prevResults .size () - 1 ) : executionResult ;
363+ ExecutionResult lastResult = ! prevResults .isEmpty () ? prevResults .get (prevResults .size () - 1 ) : executionResult ;
362364 return instrumentation .instrumentExecutionResult (lastResult , parameters , specificState );
363365 });
364366 return resultsFuture .thenApply ((results ) -> results .isEmpty () ? executionResult : results .get (results .size () - 1 ));
@@ -483,10 +485,8 @@ public void onCompleted(Object result, Throwable t) {
483485 }
484486
485487 @ FunctionalInterface
486- private interface ChainedInstrumentationFunction <I , S , A , R > {
487-
488- R apply (I t , S u , A v );
489-
488+ private interface ChainedInstrumentationFunction <I , S , V , R > {
489+ R apply (I instrumentation , S state , V value );
490490 }
491491
492492
0 commit comments