ConcurrentModificationException in getLogs()
See original GitHub issueWe tried LogCaptor in some integration-style tests, where logging actually happens in background thread.
Occasionally getLogs() throws ConcurrentModificationException -
quick look into code shows that ListAppender.list is not thread-safe, so it’s almost certainly a race between test and application threads. I think it’s not a problem for actual logging since AppenderBase::doAppend is synchronized, but it is a problem when scanning the list.
One possible fix would be to wrap all access to list into synchronized(listAppender). Or, maybe even better, swap it for CopyOnWrite / Collections::synchronizedList.
Any views on that? Happy to submit PR as well.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
ConcurrentModificationException caught · Issue #363 - GitHub
RemoteReporter-QueueProcessor" java.util.ConcurrentModificationException at java.util. ... getLogs() returns an unmodifiable collection.
Read more >Resolve java.util.ConcurrentModificationException
Below the code that goes into error: Map<String, List<Note>> noteByCod = notes.stream().collect(Collectors.groupingBy(Note::getCod)); noteByCod.
Read more >78741: ConcurrentModificationException exception cause ...
Description: Application crashes when trying to add slaves at startup. Same thread is iterating and modifying the map, synchronization does ...
Read more >[#AXIS-2800] Axis locators not thread safe (java.util ...
ConcurrentModificationException : concurrent access to HashMap attempted by Thread). Status: Assignee: Priority: ... getParameterTypes()[0] == URL.class)).
Read more >How to Avoid the Concurrent Modification Exception in Java
The ConcurrentModificationException in Java occurs when an object is attempted to be modified concurrently without permission.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Hakky54 Awesome, thanks for the quick turnaround!
@AndreyNudko The latest changes are now available within version 2.7.2