Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 315976 - NPE pressing Ctrl-Alt-p on an RPM project
Summary: NPE pressing Ctrl-Alt-p on an RPM project
Status: RESOLVED FIXED
Alias: None
Product: Linux Tools
Classification: Tools
Component: ChangeLog (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 0.6   Edit
Assignee: Jeff Johnston CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-07 09:06 EDT by Andrew Overholt CLA
Modified: 2010-06-09 10:22 EDT (History)
2 users (show)

See Also:


Attachments
Patch to fix RPM Prepare ChangeLog bug (913 bytes, patch)
2010-06-07 18:17 EDT, Jeff Johnston CLA
jjohnstn: review?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Overholt CLA 2010-06-07 09:06:56 EDT
If I press Ctrl-Alt-p on an RPM project that's checked out from CVS, I get the following stack trace in my console log:

java.lang.NullPointerException
        at org.eclipse.linuxtools.rpm.ui.editor.actions.SpecfileChangelogFormatter.formatDateLine(SpecfileChangelogFormatter.java:49)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction.outputMultipleEntryChangeLog(PrepareChangeLogAction.java:474)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction.prepareChangeLog(PrepareChangeLogAction.java:389)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction.access$0(PrepareChangeLogAction.java:269)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction$1.run(PrepareChangeLogAction.java:145)
        at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
        at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
        at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction.doRun(PrepareChangeLogAction.java:154)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangelogKeyHandler$1.run(PrepareChangelogKeyHandler.java:138)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangelogKeyHandler.execute(PrepareChangelogKeyHandler.java:142)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangelogKeyHandler.run(PrepareChangelogKeyHandler.java:182)
        at org.eclipse.ui.internal.handlers.ActionDelegateHandlerProxy.execute(ActionDelegateHandlerProxy.java:289)
        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:468)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:786)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:885)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:567)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:508)
        at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:123)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
        at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1525)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1257)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1267)
        at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1294)
        at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:730)
        at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:2839)
        at org.eclipse.swt.widgets.Composite.gtk_key_press_event(Composite.java:734)
        at org.eclipse.swt.widgets.Tree.gtk_key_press_event(Tree.java:1977)
        at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1743)
        at org.eclipse.swt.widgets.Control.windowProc(Control.java:4794)
        at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:3485)
        at org.eclipse.swt.widgets.Display.windowProc(Display.java:4372)
        at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
        at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:8163)
        at org.eclipse.swt.widgets.Display.eventProc(Display.java:1239)
        at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
        at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2224)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3169)
        at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
        at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
        at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        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:369)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Comment 1 Andrew Overholt CLA 2010-06-07 09:08:35 EDT
I would like to see a patch for this before it is committed as it is so close to our Helios release.
Comment 2 Andrew Overholt CLA 2010-06-07 17:29:06 EDT
Ignore the stack trace above (that was caused by an earlier snapshot being installed).  This is now what I'm getting if I press Ctrl-Alt-p on a changed CVS project with _the project node selected_ (not from within the .spec editor):

!ENTRY org.eclipse.linuxtools.changelog.core 4 4 2010-06-07 17:26:28.200
!MESSAGE
!STACK 0
java.lang.reflect.InvocationTargetException
        at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:477)
        at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
        at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction.doRun(PrepareChangeLogAction.java:154)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangelogKeyHandler$1.run(PrepareChangelogKeyHandler.java:138)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangelogKeyHandler.execute(PrepareChangelogKeyHandler.java:142)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangelogKeyHandler.run(PrepareChangelogKeyHandler.java:182)
        at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
        at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
        at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
        at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
        at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3552)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3171)
        at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
        at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
        at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        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:369)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Caused by: java.lang.NullPointerException
        at org.eclipse.linuxtools.changelog.core.actions.ChangeLogAction.getDocumentIFile(ChangeLogAction.java:280)
        at org.eclipse.linuxtools.changelog.core.actions.ChangeLogAction.getDocumentLocation(ChangeLogAction.java:291)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction.outputMultipleEntryChangeLog(PrepareChangeLogAction.java:477)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction.prepareChangeLog(PrepareChangeLogAction.java:389)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction.access$0(PrepareChangeLogAction.java:269)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction$1.run(PrepareChangeLogAction.java:145)
        at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
        ... 36 more
Root exception:
java.lang.NullPointerException
        at org.eclipse.linuxtools.changelog.core.actions.ChangeLogAction.getDocumentIFile(ChangeLogAction.java:280)
        at org.eclipse.linuxtools.changelog.core.actions.ChangeLogAction.getDocumentLocation(ChangeLogAction.java:291)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction.outputMultipleEntryChangeLog(PrepareChangeLogAction.java:477)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction.prepareChangeLog(PrepareChangeLogAction.java:389)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction.access$0(PrepareChangeLogAction.java:269)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction$1.run(PrepareChangeLogAction.java:145)
        at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
        at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
        at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangeLogAction.doRun(PrepareChangeLogAction.java:154)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangelogKeyHandler$1.run(PrepareChangelogKeyHandler.java:138)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangelogKeyHandler.execute(PrepareChangelogKeyHandler.java:142)
        at org.eclipse.linuxtools.changelog.core.actions.PrepareChangelogKeyHandler.run(PrepareChangelogKeyHandler.java:182)
        at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
        at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229)
        at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
        at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
        at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3552)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3171)
        at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
        at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
        at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        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:369)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Comment 3 Jeff Johnston CLA 2010-06-07 18:16:27 EDT
Problem occurs because the PrepareChangeLogAction for "infile" changelog files is trying to get the active workbench part and is doing nothing if it isn't an editor part.

If the project is selected and CTRL+ALT+P is pressed, the active part is likely the Project Explorer and so the changelog is left as null.  This later causes the NPE which causes the InvocationTargetException seen in the console log.

The fix is to make the PrepareChangeLogAction try to open the editor for the file that has changed and has an "infile" changelog entry.  This is done via the openEditor() method.  It will open a new editor if a Specfile editor with the file is not currently open or will activate the editor if a Specfile editor with the given file is found.

Since we need to modify the file, opening the editor makes perfect sense.

I am attaching a patch for review.
Comment 4 Jeff Johnston CLA 2010-06-07 18:17:22 EDT
Created attachment 171345 [details]
Patch to fix RPM Prepare ChangeLog bug
Comment 5 Andrew Overholt CLA 2010-06-08 10:46:44 EDT
This patch seems okay to me and it fixes the error I was seeing.  I've tried Ctrl-Alt-p with multiple project explorer nodes selected and I can't make it generate a stack trace.  It also functions correctly and doesn't seem to adversely affect other ChangeLog functionality (Ctrl-Alt-c, etc.).

The openEditor method in ChangeLogAction seems like it could be calling something cleaner than org.eclipse.ui.ide.IDE.openEditor() but that's for another bug :)
Comment 6 Jeff Johnston CLA 2010-06-08 14:07:53 EDT
(In reply to comment #5)
> This patch seems okay to me and it fixes the error I was seeing.  I've tried
> Ctrl-Alt-p with multiple project explorer nodes selected and I can't make it
> generate a stack trace.  It also functions correctly and doesn't seem to
> adversely affect other ChangeLog functionality (Ctrl-Alt-c, etc.).
> 
> The openEditor method in ChangeLogAction seems like it could be calling
> something cleaner than org.eclipse.ui.ide.IDE.openEditor() but that's for
> another bug :)

Patch checked in, thanks for reviewing.
Comment 7 Andrew Overholt CLA 2010-06-09 10:22:19 EDT
Fix verified with build #236 (201006081801).