Skip to content

Commit

Permalink
Make java file write wait by using reduce instead of count (#528)
Browse files Browse the repository at this point in the history
* Make java file write wait by using reduce instead of count

* Remove unused pool

* Cleanup unused imports

---------

Co-authored-by: Karthik Ramgopal <kramgopa@linkedin.com>
  • Loading branch information
karthikrg and li-kramgopa authored Jan 10, 2024
1 parent dd5ed71 commit 64d54e9
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,18 +341,18 @@ private void writeJavaFilesToDisk(Collection<JavaFile> javaFiles, Path outputFol
long writeStart = System.currentTimeMillis();

// write out the files we generated
long numFilesWritten = javaFiles.parallelStream().map(javaFile -> {
int filesWritten = javaFiles.parallelStream().map(javaFile -> {
try {
javaFile.writeToPath(outputFolderPath);
} catch (Exception e) {
throw new IllegalStateException("while writing file " + javaFile.typeSpec.name, e);
}

return null;
}).count();
return 1;
}).reduce(0, Integer::sum);

long writeEnd = System.currentTimeMillis();
LOGGER.info("wrote out {} generated java source files under {} in {} millis", numFilesWritten, outputFolderPath,
LOGGER.info("wrote out {} generated java source files under {} in {} millis", filesWritten, outputFolderPath,
writeEnd - writeStart);
}
}

0 comments on commit 64d54e9

Please sign in to comment.