@@ -35,9 +35,7 @@ public class ConfigurableDispatchInstrumentation extends DataLoaderDispatcherIns
3535
3636  private  final  Function <DataLoaderRegistry , TrackingApproach > approachFunction ;
3737
38-   /** 
39-    * Creates a DataLoaderDispatcherInstrumentation with the default options 
40-    */ 
38+   /** Creates a DataLoaderDispatcherInstrumentation with the default options */ 
4139  public  ConfigurableDispatchInstrumentation (
4240      Function <DataLoaderRegistry , TrackingApproach > approachFunction ) {
4341    this (DataLoaderDispatcherInstrumentationOptions .newOptions (), approachFunction );
@@ -48,7 +46,8 @@ public ConfigurableDispatchInstrumentation(
4846   * 
4947   * @param options the options to control the behaviour 
5048   */ 
51-   public  ConfigurableDispatchInstrumentation (DataLoaderDispatcherInstrumentationOptions  options ,
49+   public  ConfigurableDispatchInstrumentation (
50+       DataLoaderDispatcherInstrumentationOptions  options ,
5251      Function <DataLoaderRegistry , TrackingApproach > approachFunction ) {
5352    this .options  = options ;
5453    this .approachFunction  = approachFunction ;
@@ -60,27 +59,29 @@ public InstrumentationState createState(InstrumentationCreateStateParameters par
6059    return  new  DataLoaderDispatcherInstrumentationState (
6160        registry ,
6261        approachFunction .apply (registry ),
63-         parameters .getExecutionInput ().getExecutionId ()
64-     );
62+         parameters .getExecutionInput ().getExecutionId ());
6563  }
6664
6765  @ Override 
68-   public  DataFetcher <?> instrumentDataFetcher (DataFetcher <?> dataFetcher ,
69-       InstrumentationFieldFetchParameters  parameters , InstrumentationState  instrumentationState ) {
70-     DataLoaderDispatcherInstrumentationState  state  = InstrumentationState .ofState (
71-         instrumentationState );
66+   public  DataFetcher <?> instrumentDataFetcher (
67+       DataFetcher <?> dataFetcher ,
68+       InstrumentationFieldFetchParameters  parameters ,
69+       InstrumentationState  instrumentationState ) {
70+     DataLoaderDispatcherInstrumentationState  state  =
71+         InstrumentationState .ofState (instrumentationState );
7272    if  (state .isAggressivelyBatching ()) {
7373      return  dataFetcher ;
7474    }
7575    // 
7676    // currently only AsyncExecutionStrategy with DataLoader and hence this allows us to "dispatch" 
7777    // on every object if it's not using aggressive batching for other execution strategies 
7878    // which allows them to work if used. 
79-     return  (DataFetcher <Object >) environment  -> {
80-       Object  obj  = dataFetcher .get (environment );
81-       doImmediatelyDispatch (state );
82-       return  obj ;
83-     };
79+     return  (DataFetcher <Object >)
80+         environment  -> {
81+           Object  obj  = dataFetcher .get (environment );
82+           doImmediatelyDispatch (state );
83+           return  obj ;
84+         };
8485  }
8586
8687  private  void  doImmediatelyDispatch (DataLoaderDispatcherInstrumentationState  state ) {
@@ -92,8 +93,8 @@ public InstrumentationContext<ExecutionResult> beginExecuteOperation(
9293      InstrumentationExecuteOperationParameters  parameters ,
9394      InstrumentationState  instrumentationState ) {
9495    if  (!isDataLoaderCompatible (parameters .getExecutionContext ())) {
95-       DataLoaderDispatcherInstrumentationState  state  =  InstrumentationState . ofState ( 
96-           instrumentationState );
96+       DataLoaderDispatcherInstrumentationState  state  =
97+           InstrumentationState . ofState ( instrumentationState );
9798      state .setAggressivelyBatching (false );
9899    }
99100    return  SimpleInstrumentationContext .noOp ();
@@ -117,8 +118,8 @@ private boolean isDataLoaderCompatible(ExecutionContext executionContext) {
117118  public  ExecutionStrategyInstrumentationContext  beginExecutionStrategy (
118119      InstrumentationExecutionStrategyParameters  parameters ,
119120      InstrumentationState  instrumentationState ) {
120-     DataLoaderDispatcherInstrumentationState  state  =  InstrumentationState . ofState ( 
121-         instrumentationState );
121+     DataLoaderDispatcherInstrumentationState  state  =
122+         InstrumentationState . ofState ( instrumentationState );
122123    // 
123124    // if there are no data loaders, there is nothing to do 
124125    // 
@@ -141,8 +142,8 @@ public void onCompleted(ExecutionResult result, Throwable t) {
141142  @ Override 
142143  public  InstrumentationContext <Object > beginFieldFetch (
143144      InstrumentationFieldFetchParameters  parameters , InstrumentationState  instrumentationState ) {
144-     DataLoaderDispatcherInstrumentationState  state  =  InstrumentationState . ofState ( 
145-         instrumentationState );
145+     DataLoaderDispatcherInstrumentationState  state  =
146+         InstrumentationState . ofState ( instrumentationState );
146147    // 
147148    // if there are no data loaders, there is nothing to do 
148149    // 
@@ -154,25 +155,26 @@ public InstrumentationContext<Object> beginFieldFetch(
154155
155156  @ Override 
156157  public  CompletableFuture <ExecutionResult > instrumentExecutionResult (
157-       ExecutionResult  executionResult , InstrumentationExecutionParameters  parameters ,
158+       ExecutionResult  executionResult ,
159+       InstrumentationExecutionParameters  parameters ,
158160      InstrumentationState  instrumentationState ) {
159-     DataLoaderDispatcherInstrumentationState  state  =  InstrumentationState . ofState ( 
160-         instrumentationState );
161+     DataLoaderDispatcherInstrumentationState  state  =
162+         InstrumentationState . ofState ( instrumentationState );
161163    state .getApproach ().removeTracking (parameters .getExecutionInput ().getExecutionId ());
162164    if  (!options .isIncludeStatistics ()) {
163165      return  CompletableFuture .completedFuture (executionResult );
164166    } else  {
165167      Map <Object , Object > currentExt  = executionResult .getExtensions ();
166-       Map <Object , Object > statsMap  =  new   LinkedHashMap <>( 
167-           currentExt  == null  ? Collections .emptyMap () : currentExt );
168+       Map <Object , Object > statsMap  =
169+           new   LinkedHashMap <>( currentExt  == null  ? Collections .emptyMap () : currentExt );
168170      Map <Object , Object > dataLoaderStats  = buildStatisticsMap (state );
169171      statsMap .put ("dataloader" , dataLoaderStats );
170172
171173      log .debug ("Data loader stats : {}" , dataLoaderStats );
172174
173175      return  CompletableFuture .completedFuture (
174-           new  ExecutionResultImpl (executionResult . getData (),  executionResult . getErrors (), 
175-               statsMap ));
176+           new  ExecutionResultImpl (
177+               executionResult . getData (),  executionResult . getErrors (),  statsMap ));
176178    }
177179  }
178180
0 commit comments