Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362681 - ConcurrentModificationException while generating JAXB classes
Summary: ConcurrentModificationException while generating JAXB classes
Status: VERIFIED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: General (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.1 RC1   Edit
Assignee: Karen Butzke CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-02 10:42 EDT by Neil Hauge CLA
Modified: 2011-12-05 12:11 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Neil Hauge CLA 2011-11-02 10:42:49 EDT
The following exception was encountered after generating JAXB classes from a large schema:

java.util.ConcurrentModificationException
	at java.util.HashMap$HashIterator.nextEntry(Unknown Source)
	at java.util.HashMap$ValueIterator.next(Unknown Source)
	at java.util.AbstractCollection.toArray(Unknown Source)
	at org.eclipse.jpt.common.utility.internal.iterators.CloneIterator.<init>(CloneIterator.java:72)
	at org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable.iterator(LiveCloneIterable.java:77)
	at org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable.iterator(FilteringIterable.java:66)
	at org.eclipse.jpt.common.utility.internal.model.value.AspectCollectionValueModelAdapter.iterator_(AspectCollectionValueModelAdapter.java:85)
	at org.eclipse.jpt.common.utility.internal.model.value.AspectCollectionValueModelAdapter.iterator(AspectCollectionValueModelAdapter.java:76)
	at org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider.childrenModel(AbstractTreeItemContentProvider.java:110)
	at org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider.hasChildren(AbstractTreeItemContentProvider.java:170)
	at org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider.hasChildren(DelegatingTreeContentAndLabelProvider.java:56)
	at org.eclipse.jpt.jaxb.ui.internal.navigator.JaxbNavigatorContentProvider.hasChildren(JaxbNavigatorContentProvider.java:122)
	at org.eclipse.ui.internal.navigator.extensions.SafeDelegateTreeContentProvider.hasChildren(SafeDelegateTreeContentProvider.java:110)
	at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.callNormalHasChildren(NavigatorContentServiceContentProvider.java:430)
	at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.access$4(NavigatorContentServiceContentProvider.java:425)
	at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider$3.run(NavigatorContentServiceContentProvider.java:395)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.hasChildren(NavigatorContentServiceContentProvider.java:381)
	at org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider.hasChildren(NavigatorContentServiceContentProvider.java:422)
...
Comment 1 Neil Hauge CLA 2011-11-02 10:45:39 EDT
This is a case where a Hashtable is needed as opposed to the HashMap that is being used.
Comment 2 Neil Hauge CLA 2011-11-02 11:35:26 EDT
(In reply to comment #1)
> This is a case where a Hashtable is needed as opposed to the HashMap that is
> being used.

This statement was a bit simplistic.  After saying this, I'm not sure that Hashtable's synchronized nature would actually prevent a concurrent mod exception in this case, depending on how the collection was modified.

ConcurrentHashMap would likely be a better option if we were moving the BREE to 1.6, but for now we wish to keep it at 1.5 for this plugin.
Comment 3 Neil Hauge CLA 2011-11-02 12:02:37 EDT
Brian reminded me that this issue is specifically related to the collection.toArray() that is being performed in the CloneIterator constructor, which is not a syncronized collection of values in the case of the HashMap, but would be in the case of a Hashtable, since Hashtable.values() would return a SyncronizedCollection.  As a result, the use of a Hashtable in this case should in fact prevent this particular problem from occurring.
Comment 4 Neil Hauge CLA 2011-11-02 12:40:06 EDT
See AbstractJaxbContextRoot 'packages' as the Map in question.
Comment 5 Karen Butzke CLA 2011-11-03 10:32:29 EDT
GenericJavaClassMapping 'includedAttributesContainers' is a HashMap as well
Comment 6 Karen Butzke CLA 2011-11-08 11:14:51 EST
fixed in HEAD
Comment 7 Jolene Moffitt CLA 2011-12-05 12:11:40 EST
Verified in Build S-3.1.0-20111117042513 

Verified when you import large schemas exceptions do not occur.  See the link to view test steps for verification. http://wiki.eclipse.org/Dali_3.1_RC1