Community
Participate
Working Groups
Build Identifier: 3.6.0.N20100512-2000 When synchronizing artifact repository (triggered by adding a bundle in dropins folder), ConcurrentModificationException is produced because of modifying underlying structure after the iterator is obtained. Here is the code that cause the exception (synchronizeArtifactRepository method): ... if (removedFiles.contains(artifactFile)) artifactRepository.removeDescriptor(descriptor); ... Reproducible: Always Steps to Reproduce: 1.Download and unzip Equinox (http://download.eclipse.org/equinox/drops/N20100512-2000/index.php) 2.Start it in root folder (equinox) using java -jar plugins/org.eclipse.osgi_3.6.0.N20100512-2000.jar -configuration configuration –console 3.Setup dropins folder in config.ini: org.eclipse.equinox.p2.reconciler.dropins.directory=dropins 4.Describe all plugins (and start them) in Equinox/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info 5.Add some plugins in dropins folder 6.When dropins reconciler is started, observe the ConcurrentModificationException in logs: !ENTRY org.eclipse.equinox.p2.reconciler.dropins 4 0 2010-05-14 16:11:44.463 !MESSAGE !STACK 0 org.osgi.framework.BundleException: Exception in org.eclipse.equinox.internal.p2.reconciler.dropins.Activator.start() of bundle org.eclipse.equinox.p2.reconciler.dropins. at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:806) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:755) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:370) at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:374) at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1067) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:561) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:546) at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:459) at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:440) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227) at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:337) Caused by: java.util.ConcurrentModificationException at java.util.AbstractList$Itr.checkForComodification(Unknown Source) at java.util.AbstractList$Itr.next(Unknown Source) at org.eclipse.equinox.internal.p2.metadata.expression.RepeatableIterator.next(RepeatableIterator.java:82) at org.eclipse.equinox.internal.p2.metadata.expression.CompoundIterator.positionNext(CompoundIterator.java:76) at org.eclipse.equinox.internal.p2.metadata.expression.CompoundIterator.hasNext(CompoundIterator.java:43) at org.eclipse.equinox.internal.p2.metadata.expression.CompoundIterator.positionNext(CompoundIterator.java:69) at org.eclipse.equinox.internal.p2.metadata.expression.CompoundIterator.hasNext(CompoundIterator.java:43) at org.eclipse.equinox.internal.p2.metadata.expression.RepeatableIterator$IndexProviderIterator.hasNext(RepeatableIterator.java:142) at org.eclipse.equinox.internal.provisional.p2.directorywatcher.RepositoryListener.synchronizeArtifactRepository(RepositoryListener.java:241) at org.eclipse.equinox.internal.provisional.p2.directorywatcher.RepositoryListener.stopPoll(RepositoryListener.java:199) at org.eclipse.equinox.internal.p2.reconciler.dropins.DropinsRepositoryListener.stopPoll(DropinsRepositoryListener.java:236) at org.eclipse.equinox.internal.provisional.p2.directorywatcher.DirectoryWatcher.stopPoll(DirectoryWatcher.java:171) at org.eclipse.equinox.internal.provisional.p2.directorywatcher.DirectoryWatcher.poll(DirectoryWatcher.java:109) at org.eclipse.equinox.internal.p2.reconciler.dropins.Activator.watchDropins(Activator.java:476) at org.eclipse.equinox.internal.p2.reconciler.dropins.Activator.start(Activator.java:160) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:783) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:774) ... 11 more Root exception: java.util.ConcurrentModificationException at java.util.AbstractList$Itr.checkForComodification(Unknown Source) at java.util.AbstractList$Itr.next(Unknown Source) at org.eclipse.equinox.internal.p2.metadata.expression.RepeatableIterator.next(RepeatableIterator.java:82) at org.eclipse.equinox.internal.p2.metadata.expression.CompoundIterator.positionNext(CompoundIterator.java:76) at org.eclipse.equinox.internal.p2.metadata.expression.CompoundIterator.hasNext(CompoundIterator.java:43) at org.eclipse.equinox.internal.p2.metadata.expression.CompoundIterator.positionNext(CompoundIterator.java:69) at org.eclipse.equinox.internal.p2.metadata.expression.CompoundIterator.hasNext(CompoundIterator.java:43) at org.eclipse.equinox.internal.p2.metadata.expression.RepeatableIterator$IndexProviderIterator.hasNext(RepeatableIterator.java:142) at org.eclipse.equinox.internal.provisional.p2.directorywatcher.RepositoryListener.synchronizeArtifactRepository(RepositoryListener.java:241) at org.eclipse.equinox.internal.provisional.p2.directorywatcher.RepositoryListener.stopPoll(RepositoryListener.java:199) at org.eclipse.equinox.internal.p2.reconciler.dropins.DropinsRepositoryListener.stopPoll(DropinsRepositoryListener.java:236) at org.eclipse.equinox.internal.provisional.p2.directorywatcher.DirectoryWatcher.stopPoll(DirectoryWatcher.java:171) at org.eclipse.equinox.internal.provisional.p2.directorywatcher.DirectoryWatcher.poll(DirectoryWatcher.java:109) at org.eclipse.equinox.internal.p2.reconciler.dropins.Activator.watchDropins(Activator.java:476) at org.eclipse.equinox.internal.p2.reconciler.dropins.Activator.start(Activator.java:160) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:783) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:774) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:755) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:370) at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:374) at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1067) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:561) at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:546) at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:459) at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243) at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:440) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227) at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:337)
Created attachment 169075 [details] structure traversal with iterator is replaced with iterating array copy of the structure May result in slight increasing memory consumption due to array copy
I'm surprised that we have not yet run into this. I've looked at the patch and it looks good.
Thanks for the patch! Fix released.