Bug 211884 - IAE thrown when creating a new .product file using File > New > File
Summary: IAE thrown when creating a new .product file using File > New > File
Status: VERIFIED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 trivial (vote)
Target Milestone: 3.4 M5   Edit
Assignee: Curtis Windatt CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday, contributed
Depends on:
Blocks:
 
Reported: 2007-12-04 10:11 EST by Simon Archer CLA
Modified: 2008-02-05 15:00 EST (History)
3 users (show)

See Also:
baumanbr: review+


Attachments
mylyn/context/zip (758 bytes, application/octet-stream)
2007-12-07 13:19 EST, Chris Aniszczyk CLA
no flags Details
Patch (1.21 KB, patch)
2007-12-21 12:18 EST, Curtis Windatt CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Archer CLA 2007-12-04 10:11:01 EST
While working on an RCP application I wanted to create another .product file using the File > New menu options, but this resulted in an IAE thrown from the ProductInfoSection class' refresh method.

Steps:

1.  Select the RCP project.
2.  Choose File > New > File.
3   Enter foo.product as the new filename.
4.  Click Finish.

The editor fails to open and the following exception is written to the .log file.

!ENTRY org.eclipse.ui 4 0 2007-12-04 10:00:05.859
!MESSAGE Unable to create editor ID org.eclipse.pde.ui.productEditor: Argument cannot be null
!STACK 0
java.lang.IllegalArgumentException: Argument cannot be null
	at org.eclipse.swt.SWT.error(SWT.java:3547)
	at org.eclipse.swt.SWT.error(SWT.java:3481)
	at org.eclipse.swt.SWT.error(SWT.java:3452)
	at org.eclipse.swt.custom.CCombo.setText(CCombo.java:1397)
	at org.eclipse.pde.internal.ui.parts.ComboPart.setText(ComboPart.java:109)
	at org.eclipse.pde.internal.ui.editor.product.ProductInfoSection.refresh(ProductInfoSection.java:264)
	at org.eclipse.ui.forms.ManagedForm.doRefresh(ManagedForm.java:207)
	at org.eclipse.ui.forms.ManagedForm.refresh(ManagedForm.java:192)
	at org.eclipse.ui.forms.editor.FormPage.setActive(FormPage.java:124)
	at org.eclipse.ui.forms.editor.FormEditor.pageChange(FormEditor.java:503)
	at org.eclipse.pde.internal.ui.editor.PDEFormEditor.pageChange(PDEFormEditor.java:290)
	at org.eclipse.ui.forms.editor.FormEditor.setActivePage(FormEditor.java:623)
	at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:287)
	at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:661)
	at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:426)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:592)
	at org.eclipse.ui.internal.EditorReference.getEditor(EditorReference.java:263)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2739)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2651)
	at org.eclipse.ui.internal.WorkbenchPage.access$13(WorkbenchPage.java:2643)
	at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2595)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2590)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2574)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2565)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:644)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:603)
	at org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard.performFinish(BasicNewFileResourceWizard.java:101)
	at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:742)
	at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:373)
	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:616)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
	at org.eclipse.jface.window.Window.open(Window.java:796)
	at org.eclipse.ui.internal.actions.NewWizardShortcutAction.run(NewWizardShortcutAction.java:135)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:546)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2219)
	at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:466)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:289)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:461)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:169)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:363)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:615)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:508)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:447)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1173)


While this is not the preferred way to create a .product file, it is certainly a reasonable one.  The same exception gets thrown if you try and open an empty .product file with the Product Configuration Editor; the editor needs to be more tolerant.

I saw this in Eclipse 3.3.0, but I would imagine that it would fails equally well in Eclipse 3.4.
Comment 1 Brian Bauman CLA 2007-12-04 16:12:45 EST
We should be checking to make sure none of the values we get in ProductInfoSection.refresh().  By using the New File wizard, the file is empty and therefore is causing problems with null values being returned.  
Comment 2 Chris Aniszczyk CLA 2007-12-05 16:17:13 EST
I'm very tempted to close this, but since it's Simon, I won't.

Only a smart user like Simon would try to create a product file and edit it by hand. We don't offer a source editor for product files so users would never run into this problem.
Comment 3 Simon Archer CLA 2007-12-07 13:14:44 EST
Chris, "never" is a little strong!  Looking at the "steps" above they seem to be to be within the scope of something reasonable that someone might try.

My case was fairly pedestrian: I needed a second .product file that contained a subset of an existing .product file, so I just used File > New.  My goal was to be able to build my RCP app based on one of two .product files, which does not sound that unreasonable for OSGi-based technology.

But I would hate to add requirements/work to PDE if it is not going to be generally beneficial.  Thanks for considering this, but I understand if you decide to pass on it.
Comment 4 Chris Aniszczyk CLA 2007-12-07 13:18:32 EST
Ok, I agree, never is a strong word.

This is a corner case and we happily accept patches from the community >:)
Comment 5 Chris Aniszczyk CLA 2007-12-07 13:19:19 EST
attaching context for bugday folks
Comment 6 Chris Aniszczyk CLA 2007-12-07 13:19:30 EST
here's the context :)
Comment 7 Chris Aniszczyk CLA 2007-12-07 13:19:33 EST
Created attachment 84760 [details]
mylyn/context/zip
Comment 8 Curtis Windatt CLA 2007-12-21 12:17:53 EST
I'll attach a patch that just does null checks.  Even if it isn't something the user should do, putting an IAE isn't a great thing to do.
Comment 9 Curtis Windatt CLA 2007-12-21 12:18:59 EST
Created attachment 85728 [details]
Patch

Adds null checks in case the product is empty.
Comment 10 Curtis Windatt CLA 2007-12-21 12:23:12 EST
Brian, please review.
Comment 11 Simon Archer CLA 2007-12-21 14:57:27 EST
Curtis is dead right in comment 8, an IAE is never acceptable.  Since this is such a rare case, the simple null checks sound appropriate.  Thanks Curtis.
Comment 12 Chris Aniszczyk CLA 2007-12-21 15:56:29 EST
This solves only half the battle Curtis. This patch opens the product editor, however, any modifications made won't be saved and errors will be thrown.

Check this stacktrace out:

eclipse.buildId=N20071203-0010
java.version=1.6.0_02
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.sdk.ide
Command-line arguments:  -product org.eclipse.sdk.ide -data C:\workspaces\pde/../runtime-New_configuration -dev file:C:/workspaces/pde/.metadata/.plugins/org.eclipse.pde.core/New_configuration/dev.properties -os win32 -ws win32 -arch x86


Error
Fri Dec 21 14:50:30 CST 2007
Premature end of file.

org.xml.sax.SAXParseException: Premature end of file.
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at javax.xml.parsers.SAXParser.parse(Unknown Source)
	at javax.xml.parsers.SAXParser.parse(Unknown Source)
	at org.eclipse.pde.internal.core.product.ProductModel.load(ProductModel.java:90)
	at org.eclipse.pde.internal.core.product.WorkspaceProductModel.load(WorkspaceProductModel.java:52)
	at org.eclipse.pde.internal.ui.editor.product.ProductInputContext.createModel(ProductInputContext.java:64)
	at org.eclipse.pde.internal.ui.editor.context.InputContext.create(InputContext.java:145)
	at org.eclipse.pde.internal.ui.editor.product.ProductInputContext.<init>(ProductInputContext.java:44)
	at org.eclipse.pde.internal.ui.editor.product.ProductEditor.createResourceContexts(ProductEditor.java:78)
	at org.eclipse.pde.internal.ui.editor.PDEFormEditor.createInputContexts(PDEFormEditor.java:227)
	at org.eclipse.pde.internal.ui.editor.PDEFormEditor.createPages(PDEFormEditor.java:278)
	at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:304)
	at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:661)
	at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:428)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:594)
	at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:300)
	at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
	at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
	at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
	at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1256)
	at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1209)
	at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1604)
	at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
	at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103)
	at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
	at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112)
	at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
	at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:217)
	at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:207)
	at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:779)
	at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:678)
	at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:639)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2719)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2633)
	at org.eclipse.ui.internal.WorkbenchPage.access$12(WorkbenchPage.java:2625)
	at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2577)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2572)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2556)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2547)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:644)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:603)
	at org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard.performFinish(BasicNewFileResourceWizard.java:101)
	at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:742)
	at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:373)
	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:623)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:227)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3750)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3361)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
	at org.eclipse.jface.window.Window.open(Window.java:801)
	at org.eclipse.ui.internal.actions.NewWizardShortcutAction.run(NewWizardShortcutAction.java:135)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:582)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:499)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:410)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:952)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3750)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3361)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2381)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2345)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2211)
	at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:473)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:468)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:106)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:362)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:175)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:516)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:456)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1194)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1170)
Comment 13 Brian Bauman CLA 2008-01-08 17:35:39 EST
Thanks Curtis for looking into this one.  I applied your patch as is.  I know you are busy with other more important work and I am trying to commit any outstanding patches so I figured I would take care of the problems Chris found.

I modified WorkspaceProductModel to try to parse/load the content if the content's length > 0.  Otherwise, we don't parse it (preventing the exception) and call setLoaded(true) so user's info can be saved.  I made the modification on in WorkspaceProductModel instead of ProductModel because I want to make sure we only allow blank files in the workspace and not from the target platform/file system.

While I was at it, I made the same change for CS, Update, and Feature models.  I did not verify their editors open (not enough time), but if users are as thorough (crazy :)) as Simon and find problems with the other file formats, we can fix them at that time.
Comment 14 Brian Bauman CLA 2008-02-05 14:48:16 EST
Verified on I20080204-0800
Comment 15 Simon Archer CLA 2008-02-05 15:00:39 EST
Thanks guys, very nicely done.