Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 318601 - AIOOB while initializing J2EE classpath container
Summary: AIOOB while initializing J2EE classpath container
Status: RESOLVED FIXED
Alias: None
Product: WTP Java EE Tools
Classification: WebTools
Component: jst.j2ee (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2.1   Edit
Assignee: Hari Shankar CLA
QA Contact: Chuck Bridgham CLA
URL:
Whiteboard: PMC_approved
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-01 10:11 EDT by Hari Shankar CLA
Modified: 2010-07-08 15:34 EDT (History)
3 users (show)

See Also:
david_williams: pmc_approved+
hshanka: pmc_approved? (raghunathan.srinivasan)
hshanka: pmc_approved? (naci.dai)
hshanka: pmc_approved? (deboer)
hshanka: pmc_approved? (neil.hauge)
hshanka: pmc_approved? (kaloyan)
cbridgha: review+


Attachments
patch (1.63 KB, patch)
2010-07-01 10:17 EDT, Hari Shankar CLA
no flags Details | Diff
updated patch (1.07 KB, patch)
2010-07-01 14:01 EDT, Hari Shankar CLA
ccc: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hari Shankar CLA 2010-07-01 10:11:01 EDT
Build Identifier: 321

I know it is not much to go on, but I hit the attached errors, just starting one of my workspaces.

!ENTRY org.eclipse.ui.workbench 4 2 2010-06-28 10:45:06.093
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".
!STACK 0
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 3
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.data(BasicNotifierImpl.java:178)
	at org.eclipse.wst.common.internal.emf.utilities.ExtendedEcoreUtil.getAdapter(ExtendedEcoreUtil.java:254)
	at org.eclipse.wst.common.componentcore.internal.impl.ResourceTreeRoot.getDeployResourceTreeRoot(ResourceTreeRoot.java:124)
	at org.eclipse.wst.common.componentcore.internal.resources.VirtualResource.getProjectRelativePaths(VirtualResource.java:120)
	at org.eclipse.wst.common.componentcore.internal.resources.VirtualFile.getUnderlyingFiles(VirtualFile.java:104)
	at org.eclipse.wst.common.componentcore.internal.resources.VirtualFile.getUnderlyingResources(VirtualFile.java:93)
	at org.eclipse.wst.common.componentcore.internal.resources.VirtualResource.exists(VirtualResource.java:88)
	at org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities.getNonBinaryComponentManifest(ManifestUtilities.java:123)
	at org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities.getManifest(ManifestUtilities.java:80)
	at org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities.getManifestClasspath(ManifestUtilities.java:146)
	at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getManifestClasspath(J2EEModuleVirtualComponent.java:189)
	at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.calculateManifestReferences(J2EEModuleVirtualComponent.java:318)
	at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.cacheManifestReferences(J2EEModuleVirtualComponent.java:310)
	at org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent.getReferences(J2EEModuleVirtualComponent.java:153)
	at org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathContainer.update(J2EEComponentClasspathContainer.java:194)
	at org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathContainer.install(J2EEComponentClasspathContainer.java:414)
	at org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathInitializer.initialize(J2EEComponentClasspathInitializer.java:48)
	at org.eclipse.jdt.internal.core.JavaModelManager.initializeContainer(JavaModelManager.java:2707)
	at org.eclipse.jdt.internal.core.JavaModelManager$11.run(JavaModelManager.java:2613)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
	at org.eclipse.jdt.internal.core.JavaModelManager.initializeAllContainers(JavaModelManager.java:2653)
	at org.eclipse.jdt.internal.core.JavaModelManager.getClasspathContainer(JavaModelManager.java:1845)
	at org.eclipse.jdt.core.JavaCore.getClasspathContainer(JavaCore.java:2705)
	at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2645)
	at org.eclipse.jdt.internal.core.JavaProject.resolveClasspath(JavaProject.java:2783)
	at org.eclipse.jdt.internal.core.JavaProject.getResolvedClasspath(JavaProject.java:1915)
	at org.eclipse.jdt.internal.core.JavaProject.isOnClasspath(JavaProject.java:2193)
	at org.eclipse.jdt.internal.ui.BuildpathIndicatorLabelDecorator.getOverlay(BuildpathIndicatorLabelDecorator.java:47)
	at org.eclipse.jdt.internal.ui.BuildpathIndicatorLabelDecorator.decorate(BuildpathIndicatorLabelDecorator.java:34)
	at org.eclipse.ui.internal.decorators.LightweightDecoratorDefinition.decorate(LightweightDecoratorDefinition.java:269)
	at org.eclipse.ui.internal.decorators.LightweightDecoratorManager$LightweightRunnable.run(LightweightDecoratorManager.java:81)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.decorators.LightweightDecoratorManager.decorate(LightweightDecoratorManager.java:365)
	at org.eclipse.ui.internal.decorators.LightweightDecoratorManager.getDecorations(LightweightDecoratorManager.java:347)
	at org.eclipse.ui.internal.decorators.DecorationScheduler$1.ensureResultCached(DecorationScheduler.java:371)
	at org.eclipse.ui.internal.decorators.DecorationScheduler$1.run(DecorationScheduler.java:331)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


Reproducible: Always
Comment 1 Hari Shankar CLA 2010-07-01 10:17:55 EDT
Created attachment 173218 [details]
patch

Looking at the code, the issue seems to be that in org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.data() the size of the data array changes between the point where the size is accessed and an System.arraycopy is called. This patch addresses this situation by re-invoking the org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.data() call, should this occur, so that the second time, we get back a good array.

Patch attached for review.
Comment 2 Hari Shankar CLA 2010-07-01 14:01:19 EDT
Created attachment 173248 [details]
updated patch

Attaching a better fix that synchronizes the data() method instead.
Comment 3 Chuck Bridgham CLA 2010-07-02 10:32:57 EDT
approved
Comment 4 Hari Shankar CLA 2010-07-02 11:03:27 EDT
    * Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such. 

If a user hits this, exceptions may be surfaced to them, their workspaces will likely have compilation errors, and they may also need to restart the adopter product in order to continue.  

    * Is there a work-around? If so, why do you believe the work-around is insufficient? 

No known workaorunds.

    * How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added? 

This is an intermittant issue and was not reproducible. We have added defensive synchronization code that ensures that the potential race condition that led to the issue will not occur. Performed an end to end test (creation of artifacts, closing/opening projects, restarting the IDE) to ensure everything is working fine.

    * Give a brief technical overview. Who has reviewed this fix? 
This fix has been reviewed by Chuck Bridgham.

    * What is the risk associated with this fix? 
The fix is simple and risk is minimal.
Comment 5 Carl Anderson CLA 2010-07-07 11:39:28 EDT
Committed to HEAD for WTP 3.2.1 and WTP 3.3