Skip to content

Commit

Permalink
undo async code
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshi0301 committed Jan 31, 2024
1 parent daf2703 commit 8b3286b
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private void loadPoliciesInFolder (File folder) {

String policiesDirName = folder.getName();
File[] policyFiles = folder.exists() ? folder.listFiles() : null;
List<File> fileList= new ArrayList<>(0);
// List<File> fileList= new ArrayList<>(0);


if (ArrayUtils.isNotEmpty(policyFiles)) {
Expand All @@ -115,17 +115,17 @@ private void loadPoliciesInFolder (File folder) {
if (!item.isFile()) {
loadPoliciesInFolder(item);
} else {
//loadPoliciesInFile(item);
fileList.add(item);
loadPoliciesInFile(item);
//fileList.add(item);
}
}

// loadPoliciesInFile in async
List<CompletableFuture<Void>> futures = fileList.stream()
.map(file -> CompletableFuture.runAsync(() -> loadPoliciesInFile(file)))
.collect(Collectors.toList());

CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
// List<CompletableFuture<Void>> futures = fileList.stream()
// .map(file -> CompletableFuture.runAsync(() -> loadPoliciesInFile(file)))
// .collect(Collectors.toList());
//
// CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
} else {
LOG.warn("No policies for Bootstrapping in directory {}..", policiesDirName);
}
Expand Down

0 comments on commit 8b3286b

Please sign in to comment.