Bug 237314 - NullPointerException when swtiching targets
Summary: NullPointerException when swtiching targets
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4.1   Edit
Assignee: Curtis Windatt CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 240376 (view as bug list)
Depends on:
Blocks: 237166
  Show dependency tree
 
Reported: 2008-06-16 13:34 EDT by Alex Fitzpatrick CLA
Modified: 2008-07-29 15:41 EDT (History)
3 users (show)

See Also:


Attachments
patch with synchronized keyword (848 bytes, patch)
2008-06-16 18:00 EDT, Alex Fitzpatrick CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Fitzpatrick CLA 2008-06-16 13:34:06 EDT
Build ID: 3.4RC4

Steps To Reproduce:
Repeatable with Sun and IBM 1.6 vms
IES target

1. Use workspace preferences to switch targets


More information:
An internal error occurred during: "Resetting Target Platform".

java.lang.NullPointerException
at org.eclipse.pde.internal.core.JavadocLocationManager.getEntry(JavadocLocationManager.java:52)
at org.eclipse.pde.internal.core.JavadocLocationManager.getJavadocLocation(JavadocLocationManager.java:39)
at org.eclipse.pde.internal.core.PDEClasspathContainer.getClasspathAttributes(PDEClasspathContainer.java:123)
at org.eclipse.pde.internal.core.PDEClasspathContainer.addExternalPlugin(PDEClasspathContainer.java:69)
at org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.addPlugin(RequiredPluginsClasspathContainer.java:255)
at org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.addDependency(RequiredPluginsClasspathContainer.java:229)
at org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.addDependency(RequiredPluginsClasspathContainer.java:213)
at org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.computePluginEntries(RequiredPluginsClasspathContainer.java:129)
at org.eclipse.pde.internal.core.RequiredPluginsClasspathContainer.getClasspathEntries(RequiredPluginsClasspathContainer.java:88)
at org.eclipse.jdt.internal.core.ClasspathEntry.validateClasspathEntry(ClasspathEntry.java:1567)
at org.eclipse.jdt.internal.core.ClasspathValidation.validate(ClasspathValidation.java:69)
at org.eclipse.jdt.internal.core.ChangeClasspathOperation.classpathChanged(ChangeClasspathOperation.java:51)
at org.eclipse.jdt.internal.core.SetContainerOperation.executeOperation(SetContainerOperation.java:112)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:709)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:775)
at org.eclipse.jdt.core.JavaCore.setClasspathContainer(JavaCore.java:4703)
at org.eclipse.pde.internal.core.PluginModelManager.updateAffectedEntries(PluginModelManager.java:239)
at org.eclipse.pde.internal.core.PluginModelManager.modelsChanged(PluginModelManager.java:164)
at org.eclipse.pde.internal.core.PluginModelManager.resetState(PluginModelManager.java:853)
at org.eclipse.pde.internal.core.TargetPlatformResetJob.run(TargetPlatformResetJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Comment 1 Alex Fitzpatrick CLA 2008-06-16 14:36:26 EDT
This only seems to happen the first time the target is set (or reset?).

Once the target has been set, and failed because of the error, it is possible to make the workspace "sane" by reloading and reapplying the target again.
Comment 2 Curtis Windatt CLA 2008-06-16 17:24:03 EDT
Race condition between the reset job and getting javadoc locations.  Almost identical to bug 228297.  Can be easily solved by synchronizing the getEntry method instead of the initialize method, so that the location map can't be reset in the middle of the lookup.  Only concern is that concurrent lookups would be slowed down as they would have to wait for each other. To avoid this, a read/write lock could be used (though Java didn't provide an implementation until 1.5).
Comment 3 Alex Fitzpatrick CLA 2008-06-16 17:52:07 EDT
That seems to do the trick.
Comment 4 Alex Fitzpatrick CLA 2008-06-16 18:00:27 EDT
Created attachment 105097 [details]
patch with synchronized keyword

for completeness... patch implementing simple synchronization
Comment 5 Curtis Windatt CLA 2008-07-10 15:15:56 EDT
*** Bug 240376 has been marked as a duplicate of this bug. ***
Comment 6 Curtis Windatt CLA 2008-07-10 15:17:16 EDT
Consider fixing in M1.
Comment 7 Curtis Windatt CLA 2008-07-15 15:07:11 EDT
Did some more testing/investigating and it's unlikely that entries will be requested from multiple threads at the same time (typically done sequentially in the same thread).  Even if there are multiple threads, the performance difference will be undetectable.  Rather than creating a custom implementation of a read/write lock, it's safer to go with the simple solution.

Fixed in HEAD by adding the synchronize.
Comment 8 Chris Aniszczyk CLA 2008-07-29 15:41:15 EDT
fixed in 3.4.1 too