in import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/cstore/multipledest/MultipleDestinationUploadService.java [147:167]
private void waitOnUploadFutures(String uniqueFileName, List<CompletableFuture> futures) {
List<Throwable> exceptions = new ArrayList<>();
for (CompletableFuture uploadFuture : futures) {
try {
uploadFuture.get();
} catch (ExecutionException eex) {
exceptions.add(eex.getCause());
} catch (InterruptedException iex) {
Thread.currentThread().interrupt();
exceptions.add(new MultipleDestinationUploadServiceException(iex).getCause());
}
}
// If there are no exceptions, then we remove the file. Otherwise leave it for follow-up.
if (exceptions.isEmpty()) {
backupUploadService.removeBackup(uniqueFileName);
} else {
log.error(
"Exception messages of the upload async jobs:\n{}",
exceptions.stream().map(t -> t.getMessage()).collect(Collectors.joining("\n")));
}
}