Bug 411838 - ConcurrentModificationException with BatchFetchType.IN and Cursored Stream
Summary: ConcurrentModificationException with BatchFetchType.IN and Cursored Stream
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P2 normal with 11 votes (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard: concurrency
Keywords:
Depends on:
Blocks: 455043
  Show dependency tree
 
Reported: 2013-06-27 18:10 EDT by Michael Nielson CLA
Modified: 2022-06-09 10:36 EDT (History)
2 users (show)

See Also:


Attachments
Modified employees example that duplicates the bug. (10.72 MB, application/zip)
2013-06-27 18:10 EDT, Michael Nielson CLA
no flags Details
The complete stack trace for the bad query and ConcurrentModificationException (9.40 KB, text/plain)
2013-06-27 18:11 EDT, Michael Nielson CLA
no flags Details
synchronize when modifying dataResults (10.63 KB, patch)
2013-07-08 18:40 EDT, Michael Nielson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Nielson CLA 2013-06-27 18:10:25 EDT
Created attachment 232868 [details]
Modified employees example that duplicates the bug.

The attached test will often start to throw this exception:

java.util.ConcurrentModificationException
	at java.util.SubList.checkForComodification(AbstractList.java:752)
	at java.util.SubList.listIterator(AbstractList.java:682)
	at java.util.AbstractList.listIterator(AbstractList.java:284)
	at java.util.SubList.iterator(AbstractList.java:678)
	at java.util.AbstractCollection.toArray(AbstractCollection.java:120)
	at java.util.ArrayList.<init>(ArrayList.java:131)
	at org.eclipse.persistence.mappings.ForeignReferenceMapping.extractResultFromBatchQuery(ForeignReferenceMapping.java:630)
	at org.eclipse.persistence.mappings.CollectionMapping.extractResultFromBatchQuery(CollectionMapping.java:898)
	at org.eclipse.persistence.internal.indirection.BatchValueHolder.instantiate(BatchValueHolder.java:58)

This can also manifest as this invalid query:

Error Code: 1064
Call: SELECT ID, CORE_ID FROM DIRECTMEMBER WHERE (ID IN ())
Query: ReadAllQuery(name="directMember" referenceClass=DirectMember sql="SELECT ID, CORE_ID FROM DIRECTMEMBER WHERE (ID IN ?)")

And as an ArrayIndexOutOfBounds, and through a NullPointerException (These are less common so I don't have a stack trace for these)

The attached test is a modified version of the EclipseLink employee's example, from ant run the batch-concurrency target. To run the bug example you'll need to change the jdbc connection settings in persistence.xml. 

The most common error is the invalid query (just a symptom of concurrent access to originalPolicy.getDataResults(this) in ForeignReferenceMapping I believe)

Once in a while I get lucky/unlucky and the test runs successfully, just give it another try :)
Comment 1 Michael Nielson CLA 2013-06-27 18:11:42 EDT
Created attachment 232869 [details]
The complete stack trace for the bad query and ConcurrentModificationException
Comment 2 Michael Nielson CLA 2013-07-08 18:40:12 EDT
Created attachment 233248 [details]
synchronize when modifying dataResults
Comment 3 Tom Ware CLA 2013-07-11 15:12:28 EDT
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:17:12 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:36:02 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink