List<CompletableFuture<String>> checkFutures = checkFilterList.parallelStream().map(checkFilter->
CompletableFuture.supplyAsync(() -> {
String checkType = checkFilter.obtainCheckType();
if (!resultMap.containsKey(checkType)) {
StringBuilder strBuilder = new StringBuilder();
resultMap.put(checkType, strBuilder);
}
StringBuilder resultSaver = resultMap.get(checkType);
String result = StringConstant.JOB_SUCCESS;
try {
result = checkFilter.doFilter(sourceMediaDup, targetMediaDup, tableMappingInfo);
} catch (Exception e) {
logger.error("checkInputValid error happend", e);
result = StringConstant.JOB_ERROR;
}
if (!Objects.equals(result, StringConstant.JOB_SUCCESS)) {
resultSaver.append(result).append("\r\n");
}
return StringConstant.JOB_SUCCESS;
}, myExecutor).exceptionally(e -> {
logger.error("{} checkInputValid error", checkFilter.obtainCheckName(), e); //java.lang.ArithmeticException: / by zero
return "";
})).collect(Collectors.toList());
checkFutures.stream().map(CompletableFuture::join).collect(Collectors.toList());