1
2
3
4
5
6
Use the "Verify Solution" button to get AI feedback on your Java code.
Implement a service that concurrently fetches and processes data from multiple simulated external sources using CompletableFuture. The primary goal is to ensure that even if one or more data sources fail to provide data, the overall process completes successfully, returning available data from the successful sources and gracefully handling failures by substituting an empty list for any failed source's data.
Your task involves:
fetchData: Make it truly asynchronous, simulating network delays and potential errors.processAllSources: Orchestrate the concurrent fetching, processing, and combining of results from all sources. Implement robust error handling for each individual source operation, ensuring that an exception from one source does not halt the entire pipeline.