The PR changed the service for batch preparation of text previews for files. After the change, the behavior became unstable: some results disappear, and temporary data can remain on disk after an unsuccessful run.
You need to review the after version and find two independent bugs.
Expected service behavior:
build(List<String> docs) method returns BatchPreviewResult;<doc>.preview.txt is created inside a separate temporary directory for the run;bad-, preparation of that item is considered unsuccessful, and its name must be added to failedDocs;preparedDocs;Compile and run the code in any convenient way on Java 21.
Example scenario for observing the problems:
build(["doc-1", "bad-2", "doc-3", "bad-4", "doc-5"])
What is important to check:
build(...).preparedDocs contains all successfully prepared documents;failedDocs contains all documents that ended with an error;reviewjava.nio.file.FilesCompletableFuture.runAsync(...) and Executors.newFixedThreadPool(4)Use line comments to explain the problem, its impact, the fix and how to test it.