@@ -376,39 +376,14 @@ private Map<Integer, Object[]> partitionArguments(final DataSourceProvider dataS
376
376
return argumentsByShardId ;
377
377
}
378
378
379
- @ Immutable
380
- private static final class Call implements Callable <Object > {
381
-
382
- private final Executor executor ;
383
- private final DataSource shardDs ;
384
- private final String query ;
385
- private final Object [] params ;
386
- private final int [] types ;
387
- private final InvocationContext invocation ;
388
- private final Class <?> returnType ;
389
-
390
- Call (final Executor executor ,
391
- final DataSource shardDs ,
392
- final String query ,
393
- final Object [] params ,
394
- final int [] types ,
395
- final InvocationContext invocation ,
396
- final Class <?> returnType ) {
397
-
398
- this .executor = executor ;
399
- this .shardDs = shardDs ;
400
- this .query = query ;
401
- this .params = params ;
402
- this .types = types ;
403
- this .invocation = invocation ;
404
- this .returnType = returnType ;
405
- }
406
-
407
- @ Override
408
- public Object call () throws Exception {
409
- return executor .executeSProc (shardDs , query , params , types , invocation , returnType );
410
- }
411
-
379
+ private Callable <Object > with (final DataSource shardDs , final Object [] params , final InvocationContext invocation ) {
380
+ final StoredProcedure sproc = this ;
381
+ return new Callable <Object >() {
382
+ @ Override
383
+ public Object call () throws Exception {
384
+ return sproc .executor .executeSProc (shardDs , sproc .query , params , sproc .types , invocation , sproc .returnType );
385
+ }
386
+ };
412
387
}
413
388
414
389
private static ExecutorService parallelThreadPool = Executors .newCachedThreadPool ();
@@ -592,15 +567,7 @@ private Object executeInParallel(final DataSourceProvider dp, final InvocationCo
592
567
LOG .debug (getDebugLog (paramValues .get (i )));
593
568
}
594
569
595
- final FutureTask <Object > task = new FutureTask <>(new Call (
596
- executor ,
597
- shardDs ,
598
- query ,
599
- paramValues .get (i ),
600
- types ,
601
- invocation ,
602
- returnType
603
- ));
570
+ final FutureTask <Object > task = new FutureTask <>(with (shardDs , paramValues .get (i ), invocation ));
604
571
tasks .put (shardId , task );
605
572
parallelThreadPool .execute (task );
606
573
i ++;
0 commit comments