diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/BaseService.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/BaseService.java index 2709efca..c625e711 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/BaseService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/BaseService.java @@ -56,9 +56,10 @@ protected UUID convertStringToGuid(String studentGuid) { return new UUID(ByteBuffer.wrap(data, 0, 8).getLong(), ByteBuffer.wrap(data, 8, 8).getLong()); } - protected void processReportGradStudentDataTasksAsync(List> tasks, List result, int numberOfThreads) { + protected void processReportGradStudentDataTasksAsync(List> tasks, List result) { + if(tasks.isEmpty()) return; List> executionResult; - ExecutorService executorService = Executors.newFixedThreadPool(numberOfThreads); + ExecutorService executorService = Executors.newWorkStealingPool(); try { executionResult = executorService.invokeAll(tasks); for (Future f : executionResult) { @@ -73,6 +74,7 @@ protected void processReportGradStudentDataTasksAsync(List> tas } } catch (InterruptedException | ExecutionException ex) { logger.error("Multithreading error during the task execution: {}", ex.getLocalizedMessage()); + Thread.currentThread().interrupt(); } finally { executorService.shutdown(); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java index a972b8db..795781c2 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/grad/report/service/CommonService.java @@ -710,7 +710,7 @@ private List processReportGradStudentDataList(Page