Revamped ListAppender for thread-safety#4111
Open
ramanathan1504 wants to merge 4 commits intoapache:2.xfrom
Open
Revamped ListAppender for thread-safety#4111ramanathan1504 wants to merge 4 commits intoapache:2.xfrom
ListAppender for thread-safety#4111ramanathan1504 wants to merge 4 commits intoapache:2.xfrom
Conversation
* Returned snapshots no longer require an unmodifiable view
- Remove synchronizedList wrappers; replace with plain ArrayLists - Annotate all public methods as synchronized on `this` - Replace Awaitility polling in getMessages(int,long,TimeUnit) with wait/notifyAll - Update class-level JavaDoc to reflect thread-safety guarantee - Rewrite countDownLatch field JavaDoc with a self-contained example - Remove redundant explicit generic type arguments (IDE cleanup) - Add ListAppenderTest: unit tests + @RepeatedTest(10) concurrency tests that hammer append with 10 workers x 1000 deterministic events each and verify getEvents/getMessages are consistent Fixes apache#3926
vy
reviewed
May 2, 2026
| public List<String> getMessages(final int minSize, final long timeout, final TimeUnit timeUnit) | ||
| public synchronized List<String> getMessages(final int minSize, final long timeout, final TimeUnit timeUnit) | ||
| throws InterruptedException { | ||
| Awaitility.waitAtMost(timeout, timeUnit).until(() -> messages.size() >= minSize); |
Contributor
Author
There was a problem hiding this comment.
We achieved the same wait/notify behavior using only standard Java (no external dependencies). If you prefer, we can revert to the old Awaitility-based approach instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3926
Revamp ListAppender: Thread-Safety, Clarity, and Robust Testing
Summary
ListAppenderfor consistent thread-safety:Collections.synchronizedListusage.synchronizedfor clear, uniform locking.getMessages(int, long, TimeUnit):Object#wait/notifyAllfor in-JVM notification and reduced CPU usage.countDownLatchJavadoc with usage examples and clearer intent.ListAppender.Testing