Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 260362

Summary: NPE when using content assist in compare
Product: [Eclipse Project] JDT Reporter: Dani Megert <daniel_megert>
Component: TextAssignee: Tomasz Zarna <tomasz.zarna>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: 3.5   
Target Milestone: 3.5 M5   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch v01
none
mylyn/context/zip none

Description Dani Megert CLA 2009-01-08 04:55:15 EST
HEAD.

I get an NPE when doing content assist in the Java compare viewer. It works if the input is the CU but if I narrow down to an element it breaks.

When I do Ctrl+Space at the beginning of the file (when the CU is the 

!ENTRY org.eclipse.ui 4 4 2009-01-08 10:50:41.420
!MESSAGE "Content Assist" did not complete normally.  Please see the log for more information.

!ENTRY org.eclipse.ui 4 0 2009-01-08 10:50:41.420
!MESSAGE java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:177)
	at org.eclipse.ui.texteditor.ContentAssistAction$1.run(ContentAssistAction.java:82)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185)
	at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:471)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:823)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:879)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:570)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:511)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:126)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1190)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1002)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1040)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1036)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1358)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4019)
	at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:346)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3912)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:342)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4584)
	at org.eclipse.swt.internal.win32.OS.CallWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.CallWindowProc(OS.java:2295)
	at org.eclipse.swt.internal.BidiUtil.windowProc(BidiUtil.java:639)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2392)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3468)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:333)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:366)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
	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:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:550)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:505)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1237)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1213)
Comment 1 Tomasz Zarna CLA 2009-01-08 07:56:44 EST
Created attachment 121942 [details]
Patch v01

There is an extra unconfigure()/configure() pair called for on each setInput (which happens when narrowing to an element). TextMergeViewer calls the "enhanced" configuration only once so we end up with a partly configured viewer(s) (configured without IEditorInput on setInput). This result in the situation when we do have editors adapters, actions and so on but on setInput we unconfigure the viewer and configure it old way (additional, enhanced configuration doesn't take place).

The patch removes the unconfigure()/configure() pair from setInput() and at the same time makes sure we do configure a viewer in old fashioned way when no IEditorInput is available for it (it's non-local resource etc).
Comment 2 Tomasz Zarna CLA 2009-01-08 07:56:47 EST
Created attachment 121943 [details]
mylyn/context/zip
Comment 3 Dani Megert CLA 2009-01-09 06:37:41 EST
Thanks for the patch.
Fixed in HEAD.
Available in builds > N20080108-2000.
Comment 4 Dani Megert CLA 2009-01-27 04:34:49 EST
Verified in I20090126-1800.