Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » ArrayIndexOutOfBoundsException when calling BasicEList.toArray
ArrayIndexOutOfBoundsException when calling BasicEList.toArray [message #1783498] Tue, 13 March 2018 16:32 Go to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member


I noticed several bugs having this top-level stack:

	at java.lang.System.arraycopy(Native Method)
	at org.eclipse.emf.common.util.BasicEList.toArray(


I'm wondering what can cause this issue?

my initial thought was that 2 threads are accessing the same list but for instance in this case, a synchronized block has been used:

	at org.eclipse.emf.common.util.BasicEList.toArray(
	at java.util.ArrayList.<init>(
	at org.eclipse.wst.common.internal.emf.utilities.ResourceIsLoadingAdapter.findAdapter(
	at org.eclipse.wst.common.internal.emf.resource.CompatibilityXMIResourceImpl.waitForResourceToLoadIfNecessary(
	at org.eclipse.wst.common.internal.emf.resource.CompatibilityXMIResourceImpl.isLoaded(
	at org.eclipse.wst.common.componentcore.internal.ModuleStructuralModel.getAndLoadLocalResource(
	at org.eclipse.wst.common.internal.emfworkbench.integration.EditModel.getResource(
	at org.eclipse.wst.common.componentcore.internal.ModuleStructuralModel.getPrimaryResource(
	at org.eclipse.wst.common.componentcore.internal.ModuleStructuralModel.prepareProjectModulesIfNecessary(
	at org.eclipse.wst.common.componentcore.internal.ModuleStructuralModel.getPrimaryRootObject(
	at org.eclipse.wst.common.componentcore.internal.StructureEdit.getComponentModelRoot(
	at org.eclipse.wst.common.componentcore.internal.StructureEdit.getWorkbenchModules(
	at org.eclipse.wst.common.componentcore.internal.StructureEdit.getComponent(
	at org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater$FindNodeJob.findNode(
	at org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater$FindNodeJob.findNode(
	at org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater$FindNodeJob.findNode(
	at org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater$FindNodeJob.access$0(
	at org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater$FindNodeJob$
	at org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater$


EList<Adapter> resourceAdapters = aResource.eAdapters();
synchronized(resourceAdapters) {
ArrayList<Adapter> resourceAdaptersCopy = new ArrayList<Adapter>(resourceAdapters);
adapter = (ResourceIsLoadingAdapter) getAdapter(resourceAdaptersCopy, ResourceIsLoadingAdapter.class);

So what are the possibilities that can cause this error? How to investigate?/fix it? Any ideas?


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: ArrayIndexOutOfBoundsException when calling BasicEList.toArray [message #1783550 is a reply to message #1783498] Wed, 14 March 2018 05:58 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30687
Registered: July 2009
Senior Member
It must be a threading issue or it would be easy to reproduce everywhere, all the time. Sure you can have a synchronization guard, but unless all threads have such a guard, the guard won't do much good. So if, for example, you have a background thread that does the above, but you're using item providers in the display thread to display the model, the display thread will also attach adapters and it will do so without a guard. Note also that org.eclipse.emf.ecore.impl.MinimalEObjectImpl.eAdapters() creates a new list on each call so the same pattern as above would be useless because each caller sees a different list instance. One brute force fix would be to syncExec to the display thread but that might lead to deadlock.
Previous Topic:[jet] Controlling the template path
Next Topic:[CDO] Permission check for QueryHandler
Goto Forum:

Current Time: Mon Dec 09 18:24:59 GMT 2019

Powered by FUDForum. Page generated in 0.01583 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top