Repository navigation
Conversation
Replace `ArrayList` with a thread-safe `Set` implementation to avoid concurrency issues when `MultiThreadMDC` is used in parallel batch processing scenarios. Replace `contains` checks with the corresponding `add` or `remove` calls, since these methods return the information needed and are idempotent. GitHub issue number: aws-powertools#2712
|
There is an obvious gap in the existing unit test coverage for However, since its public interface only modifies the MDC (which is a no-op unless an implementation is added as a test-scope dependency) and its internal state, without returning any value, testing it is practically impossible. The simplest solution would be to change the signatures of the two methods to return a boolean indicating whether any change was made, essentially returning the values produced by the respective |
Change `copyMDCToThread` and `removeThread` to return boolean values indicating operation success, enabling basic unit testing. Related GitHub issue number: aws-powertools#2712
|
|
@phipag, I pushed an additional commit with the interface change and basic tests I mentioned. Let me know what you think. Not sure if you'd maybe like that to be a separate PR, since it's a refactor (or even a feature?) and not a fix. |
Thanks, this is okay since this is an I will run E2E tests now and then we can get ready to merge this PR. Could you move it out of draft mode please? |
|
Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience! |



Summary
Changes
Replace
ArrayListwith a thread-safeSetimplementation to avoid concurrency issues whenMultiThreadMDCis used in parallel batch processing scenarios.Replace
containschecks with the correspondingaddorremovecalls, since these methods return the information needed and are idempotent.Additionally, change
copyMDCToThreadandremoveThreadto return boolean values indicating operation success, enabling basic unit testing.Issue number: Fixes #2712
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.