-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.0] Bugfix: java.util.ConcurrentModificationException at IdentityMa… #1291
base: 3.0
Are you sure you want to change the base?
[3.0] Bugfix: java.util.ConcurrentModificationException at IdentityMa… #1291
Conversation
…pManager.invalidateQueryCache PROBLEM ======= ConcurrentModificationException raising while evicting shared caches. CAUSE ======= Set 'invalidations' is changing in while we iterate over it. SOLVING ======= Add thread synchronization Signed-off-by: Vladimir Ivanov <ivvlev@ivvlev.com>
Eclipselink3_Bug_ConcurAccess.zip |
Sorry, but there are test failures see continuous-integration/jenkins/pr-merge . This is major blocker for PR approval. |
There are no failures currently, what can we do to get PR approval? |
this.queryResults.remove(queryKey); | ||
synchronized (this.queryResults) { | ||
for (Object queryKey : invalidations) { | ||
this.queryResults.remove(queryKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The queryResults is a ConcurrentHashMap. Could be rewritten to if (this.queryResults.keySet().removeAll(invalidations) invalidations.clear()
so that locking is avoided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem is modification of invalidations
while it's iterating.
The code can be rewritten according to your suggestion, but this will not eliminate the need of synchronization. Internally java.util.concurrent.ConcurrentHashMap.CollectionView#removeAll
can iterate invalidations
allso.
PS If invalidations.size() > queryResults.size()
the CollectionView#removeAll
will work faster then for (Object queryKey : invalidations) {}
.
…pManager.invalidateQueryCache
PROBLEM
ConcurrentModificationException raising while evicting shared caches.
CAUSE
Set 'invalidations' is changing in while we iterate over it.
SOLVING
Add thread synchronization
Signed-off-by: Vladimir Ivanov ivvlev@ivvlev.com