Bug 119532 - [implementation] NPE in DocumentAdapter when setting the contents
Summary: [implementation] NPE in DocumentAdapter when setting the contents
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.2   Edit
Assignee: JDT-Text-Inbox CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-06 19:31 EST by Jess Garms CLA Friend
Modified: 2006-01-10 12:04 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jess Garms CLA Friend 2005-12-06 19:31:42 EST
I have a plugin that modifies buffers programmatically via IBuffer.setContents(). If this is called during a clean operation operation with the file open (so that the file itself gets deleted), I get the following exception:

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
	at org.eclipse.swt.SWT.error(SWT.java:2942)
	at org.eclipse.swt.SWT.error(SWT.java:2865)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:126)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3057)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2716)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
	at org.eclipse.core.launcher.Main.run(Main.java:973)
	at org.eclipse.core.launcher.Main.main(Main.java:948)
Caused by: java.lang.NullPointerException
	at org.eclipse.jdt.internal.ui.javaeditor.DocumentAdapter$DocumentSetCommand.run(DocumentAdapter.java:98)
	at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:150)
	at org.eclipse.ui.internal.UISynchronizer$1.run(UISynchronizer.java:36)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
	... 18 more
Comment 1 Dani Megert CLA Friend 2005-12-07 06:46:53 EST
Fixed in HEAD.
Please try it out. I guess you might run into other troubles with this scenario.

Why is the file removed by 'Clean'? Normally *.java files aren't deleted by this operation.
Comment 2 Jess Garms CLA Friend 2005-12-08 14:59:47 EST
Thanks, Dani. That does indeed fix the NPE. Could this fix be back-ported to 3.1.2?

The reason this file is removed by clean is that it was generated by a CompilationParticipant during a prior build. Let me know if you need more info.
Comment 3 Dani Megert CLA Friend 2005-12-09 03:07:30 EST
Approving for 3.1.2. The fix is trivial and safe.
Comment 4 Dani Megert CLA Friend 2005-12-09 04:55:41 EST
Fix released into R3_1_maintenance.
Comment 5 Tom Hofmann CLA Friend 2006-01-10 12:04:55 EST
Verified in code that the NPE guards are in place in the two spots where code gets executed asynchronously.