A small PR arrived in the service that prepares a summary for asynchronous checks. After the change, the method still compiles, but in some scenarios the final result became unpredictable: some data may disappear, and the behavior depends on which tasks finished earlier and with what outcome.
You need to review the change and find defects in the new version.
build method accepts a list of check identifiers checkIds.RemoteCheckClient service must perform an asynchronous check.items in the same order as the corresponding identifiers in the input list.failedChecks.auditLog field must contain one line for each successfully processed item in the format checkId:status.AsyncCheckSummaryService.build method from the code in the PR."slow-ok", "fast-ok", "broken";RemoteCheckClient.fetch("slow-ok") completes successfully later than fetch("fast-ok");fetch("broken") completes with an exception.For convenience, you can use the following launch example:
javac src/*.java && java -cp src Demo
SummaryResult for the entire input list, even if one of the checks failed.CompletableFutures.javac and execution with java -cp src DemoCompletableFuture and Executors.newFixedThreadPool(3) inside the demo clientRemoteCheckClient.fetch can complete either successfully or with an exception; delays between tasks differUse line comments to explain the problem, its impact, the fix and how to test it.