ramanathan1504 commented on code in PR #4111:
URL: https://github.com/apache/logging-log4j2/pull/4111#discussion_r3266474455
##########
log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/appender/ListAppender.java:
##########
@@ -188,36 +179,43 @@ public boolean stop(final long timeout, final TimeUnit
timeUnit) {
return true;
}
- public ListAppender clear() {
+ public synchronized ListAppender clear() {
events.clear();
messages.clear();
data.clear();
return this;
}
/** Returns an immutable snapshot of captured log events */
- public List<LogEvent> getEvents() {
- return Collections.<LogEvent>unmodifiableList(new ArrayList<>(events));
+ public synchronized List<LogEvent> getEvents() {
+ return Collections.unmodifiableList(new ArrayList<>(events));
}
/** Returns an immutable snapshot of captured messages */
- public List<String> getMessages() {
- return Collections.<String>unmodifiableList(new ArrayList<>(messages));
+ public synchronized List<String> getMessages() {
+ return Collections.unmodifiableList(new ArrayList<>(messages));
}
/**
* Polls the messages list for it to grow to a given minimum size at most
timeout timeUnits and return a copy of
* what we have so far.
*/
- 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);
Review Comment:
You're correct. Replacing the polling loop with remainingNanos blocks the
thread for the full duration, which is a regression. I will revert this to the
original polling structure and ensure the diff is minimal and non-disruptive.
Thanks for the feedback.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]