Description
Maybe this is intended and expected, but in case it is not I thought I report it.
When you use the ListAppender and then when you verify the log events using some iteration like streams or in Groovy (using Spock) like
ListAppender.getListAppender('Test Appender').events.findAll { it.thrown }.each { throw it.thrown }
and while you iterate there are new log events, you get concurrent modification exceptions as the returned list (also for other methods like getMessages or getData) is backed by the original list when you use `Collections.unmodifiableList`.
If this is not expected, maybe it should instead return a copy of the underlying collections. If it is intended, maybe a second set of methods would make sense that return a snapshot at call time.
My current workaround is to copy the returned list like
new ArrayList<>(ListAppender.getListAppender('Test Appender').events).findAll { it.thrown }.each { throw it.thrown }
Attachments
Issue Links
- links to