A small service collects a summary from several external requests and returns it synchronously after all background tasks finish. In this change, the behavior became incorrect in two independent places: when one request fails and when there are repeated keys in the input list.
SummaryService.summarize(List<String> keys) must start processing for each input key and return the result in the order of the input list.['alpha', 'fail', 'alpha'].summarize(...) to complete.fail is not lost and that the repeated alpha is not collapsed into a single entry.Example input data:
List<String> keys = List.of("alpha", "fail", "alpha");
fail, the method must return an error, not replace it with a successful result.mvn test is not used; verification is done by ordinary compilation and running JUnit-compatible tests in a Java 21 environmentsrc/main/javaUse line comments to explain the problem, its impact, the fix and how to test it.