ramanathan1504 commented on code in PR #4111:
URL: https://github.com/apache/logging-log4j2/pull/4111#discussion_r3177685350


##########
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:
   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 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]

Reply via email to