I have an ExecutorService which is used to invoke a Collection of Callable obejcts and returns a List of Future objects corresponding to Callable elements in the collection.
However, somewhere while traversing the list, it throws the following exception :
java.util.concurrent.ExecutionException: java.lang.IndexOutOfBoundsException: Index: 7, Size: 1
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at com.soc.transformcsv.ParallelTransformationPool.doExecute(ParallelTransformationPool.java:91)
The code I have been executing is
List<Future<StringBuilder>> futures = executor.invokeAll(builders);
executor.shutdown();
HashMap<String, List<StringBuilder>> allServiceTypeRows = new LinkedHashMap<>();
for (Future<StringBuilder> future : futures) {
// I have tried putting future.isDone() which always prints true before the exception
StringBuilder recordBuilder = future.get();
// do more
}
It gives me error at future.get()
line.
Please help to resolve the roadblock or let me know what else do I provide.