Skip to content

done async-request-processor task#252

Open
VitaliyProgrammer wants to merge 1 commit into
mate-academy:mainfrom
VitaliyProgrammer:async-request-processor-branch
Open

done async-request-processor task#252
VitaliyProgrammer wants to merge 1 commit into
mate-academy:mainfrom
VitaliyProgrammer:async-request-processor-branch

Conversation

@VitaliyProgrammer

Copy link
Copy Markdown

This implementation uses request coalescing to prevent duplicate concurrent calls for the same key.
It maintains a cache for completed results and an in-flight map to deduplicate ongoing requests.
Asynchcronous execution is handled via a custom executor, and completed results ae cached for fast subsequent access.
In-flight entries are cleaned up after completion to avoid memory leaks.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Your solution is approved because it correctly implements asynchronous request processing with CompletableFuture, uses a thread-safe ConcurrentHashMap cache, and returns cached results when the same userId is requested again. The processRequest(String userId) method in AsyncRequestProcessor meets the requirements by simulating a delay in fetchUserData, populating the cache after processing, and returning CompletableFuture<UserData> so multiple requests can run concurrently. It’s also a nice touch that you added an in-flight map to deduplicate concurrent requests for the same userId, which avoids doing the same work twice under load. One minor improvement would be in Main.java near the end of main, where after calling executor.shutdown() you could also wait for termination (for example with awaitTermination) to make shutdown behavior more robust in different environments. Another small consideration is that, because of true concurrency, the order of printed results may differ from the example; if you ever need deterministic ordering, you could collect the futures and print the results in the original input order using join(). Overall, you’ve satisfied the functional requirements and demonstrated solid use of async patterns and caching—well done.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants