bjmi commented on PR #3926:
URL: https://github.com/apache/logging-log4j2/pull/3926#issuecomment-3314609844

   Thank you for your reply.
   We use `ListAppender` and `@LoggerContextSource` extensively in our JUnit 
tests and they work great. We also like the idea of #3832 to get rid of all the 
unwanted dependencies of `log4j-core-test`.
   
   1. 
   Before LOG4J2-2527 the internal Lists _events_, _data_ and _messages_ were 
made public accessible via an unmodifiable view.
   Since snapshots are now being returned, the unmodifiable wrapper isn't 
necessary and the caller is free to choose how to proceed with the lists.
   For example, the caller isn't forced to create another copy of the copy in 
order to add entries or remove unwanted ones.
   -> unmodifiable wrapper is removed.
   
   2.
   I thought the copy constructors of the Collections API use the iterator of 
the list to be copied. And 
   
[synchronizedList(List)](https://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#synchronizedList-java.util.List-)
 clearly states 
   > It is imperative that the user manually synchronize on the returned list 
when iterating over it:
   But it turns out `ArrayList(Collection)` uses `Collection.toArray()` to 
create a copy that doesn't require manual synchronization.
   To avoid future surprises esp. with ConcurrentModificationException, making 
the snapshots is synchronized.
   -> as there is no bug at the moment, the additional synchronized blocks can 
be removed. WDYT?


-- 
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