Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 522635

Summary: ConcurrentModificationException when triggering lazy load from conforming query
Product: z_Archived Reporter: thorsten kruse <ruebe356>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: ruebe356, tomas.kraus
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 321041    
Bug Blocks:    
Attachments:
Description Flags
Entities and testcode
none
Fix for master and 2.7 none

Description thorsten kruse CLA 2017-09-22 06:46:20 EDT
Same bug as posted in #321041, but in different method:

IdentityMapManager.getAllFromIdentityMap(Expression selectionCriteria, Class theClass, Record translationRow, int valueHolderPolicy, boolean shouldReturnInvalidatedObjects)

The fix of #321041 should work here, too. All methods get*FromIdentityMap(.) should be checked.


java.util.ConcurrentModificationException
	at java.util.HashMap$HashIterator.nextNode(HashMap.java:1437)
	at java.util.HashMap$ValueIterator.next(HashMap.java:1466)
	at org.eclipse.persistence.internal.identitymaps.IdentityMapKeyEnumeration.getNextCacheKey(IdentityMapKeyEnumeration.java:58)
	at org.eclipse.persistence.internal.identitymaps.IdentityMapKeyEnumeration.hasMoreElements(IdentityMapKeyEnumeration.java:38)
	at org.eclipse.persistence.internal.identitymaps.IdentityMapManager.getAllFromIdentityMap(IdentityMapManager.java:523)
	at org.eclipse.persistence.internal.sessions.IdentityMapAccessor.getAllFromIdentityMap(IdentityMapAccessor.java:312)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkIdentityMapAccessor.getAllFromIdentityMap(UnitOfWorkIdentityMapAccessor.java:104)
	at org.eclipse.persistence.internal.sessions.IdentityMapAccessor.getAllFromIdentityMap(IdentityMapAccessor.java:288)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.scanForConformingInstances(UnitOfWorkImpl.java:4717)
	at org.eclipse.persistence.queries.ReadAllQuery.conformResult(ReadAllQuery.java:272)
	at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:843)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:509)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1168)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1127)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:403)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1215)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1786)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1737)
Comment 1 thorsten kruse CLA 2017-11-03 08:56:13 EDT
Test-case is similar to bug 526546, in addition the entities are inherited:

There are three entities EmployeePO(name), CustomerPO(name) and ContactPO(Emp, daysVisited, Cus).
Employee: Bob, Paul
Customer: CompA, CompB
Contacts: Con1 (Bob, 5 days, CompA), Con2 (Paul, 10 days, CompA), Con3 (Paul, 5 days, CompB)

Read all contatcs to customer CompA two times:
ReadAllQuery raqCon = getNewReadAllQuery(ContactPO.class);
ExpressionBuilder ebCon = new ExpressionBuilder();	        raqCon.setSelectionCriteria(ebCon.get("customer").get("name").equal("CompA"));
uow.executeQuery(raqCon);
//execute query again
uow.executeQuery(raqCon); //NoSuchElementException

Commented code is attached.
Comment 2 thorsten kruse CLA 2017-11-03 09:00:06 EDT
Created attachment 271316 [details]
Entities and testcode
Comment 3 thorsten kruse CLA 2017-11-03 09:48:07 EDT
workaround would be to catch the ConcurrentModificationException an execute the query again.
Comment 4 Tomas Kraus CLA 2017-12-18 10:45:15 EST
Created attachment 271946 [details]
Fix for master and 2.7

Pushed into master:
-------------------
http://git.eclipse.org/c/eclipselink/eclipselink.runtime.git/commit/?id=0d06164409eeb7f3b55ee85343a58ee81e4ce998
Comment 6 thorsten kruse CLA 2018-11-30 03:29:25 EST
Will the fix be part of the next eclipselink release?
Comment 7 thorsten kruse CLA 2018-12-20 05:12:16 EST
(In reply to thorsten kruse from comment #6)
> Will the fix be part of the next eclipselink release?

Sure, it is already part of release 2.7.1
Comment 8 Eclipse Webmaster CLA 2022-06-09 10:17:12 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 9 Eclipse Webmaster CLA 2022-06-09 10:34:14 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink