|
|
|
|
Re: CDO Concurrent Modfiication Exception [message #1771635 is a reply to message #1771560] |
Tue, 29 August 2017 03:40 |
Pavel Vlasov Messages: 23 Registered: December 2015 |
Junior Member |
|
|
I've stepped through the code and it looks like that the reason for this exception is that at CDOLockUtil line 67 a set of ReadLockOwners is returned from the lockState:
for (CDOCommonView view : lockState.getReadLockOwners())
The set is unmodifiable, but it is backed by org.eclipse.net4j.util.concurrent.RWOLockManager.LockState.readLockOwners set, which is modifiable. When this set is modified by another thread in org.eclipse.net4j.util.concurrent.RWOLockManager.LockState.doReadLock(CONTEXT) that causes ConcurrentModificationException.
Below are a couple of thoughts regarding how it might be addressed:
A simple solution might be to add synchronized blocks around the original set and return an unmodifiable copy from getReadLockOwners(). I don't know if that would be an acceptable solution because the iteration loop will not see concurrent modifications.
Another option is to protect readLockOwners by a lock, including the iteration loop, or wrap into a SynchronizedSet with Collections.synchronizedSet(). To keep the lock/synchronization encapsulated in the LockState getReadLockOwners() may be replaced by forEachReadLockOwner(Consumer<CONTEXT>).
[Updated on: Tue, 29 August 2017 19:24] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03054 seconds