Community
Participate
Working Groups
+++ This bug was initially created as a clone of Bug #313209 +++ An adopter product has observed the following NPE which blows up the stack. In theory, a NPE such as this should never occur because a StructureEdit should never be null for a VirtualContainer. However, considering the complexities of eclipse resource notification firings, and the fact that this can not be reliably reproduced, it would be better to guard against this NPE than letting it blow up the stack. !ENTRY org.eclipse.core.resources 4 2 2010-02-22 13:50:32.289 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.resources". !STACK 0 java.lang.NullPointerException at org.eclipse.wst.common.componentcore.internal.resources.VirtualContainer.findMember(VirtualContainer.java:80) at org.eclipse.wst.common.componentcore.internal.resources.VirtualContainer.findMember(VirtualContainer.java:71) at org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities.findFile(ComponentUtilities.java:121) at org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities.getManifestFile(J2EEProjectUtilities.java:246) at org.eclipse.jst.j2ee.internal.common.J2EEDependencyListener.visit(J2EEDependencyListener.java:122) at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:68) at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:79) at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:79) at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:79) at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:79) at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:48) at org.eclipse.jst.j2ee.internal.common.J2EEDependencyListener.resourceChanged(J2EEDependencyListener.java:72) at org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:288) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37) at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:272) at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:148) at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:313) at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1022) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1809) at org.eclipse.core.internal.events.NotificationManager$NotifyJob.run(NotificationManager.java:39) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Created attachment 168786 [details] patch
I approve of this fix.
should probably be put up for PMC ;)
Am I reading the patch correctly, that the null structureEdit is ignored? Should it be logged? Since it is an error?
Yes, the null StructureEdit should be ignored, and no it should not be logged. While it is rare that such a condition should exist, if it does it implies that the project is no longer a valid VirtualComponent project at all, e.g. the user deleted it or is in the process of deleting it. Because of the multithreaded nature of WTP and adopter products built on top of it, this sort of scenario can occur. By simply returning null, the code behaves as if the resource does not exist. Code further up the chain is then expected to null check the returned resource, because null is an expected return value documented in the API.
ok, sounds good. Thanks for the extra explanation.
code checked into head for wtp 3.2 rc2