Bug 182740 NPE when report library is missing
1) create library with embedded image 2) create report referencing library and image 3) close report and library 4) remove library from filesystem 5) open report in designer java.lang.IllegalArgumentException: Argument cannot be null at org.eclipse.swt.SWT.error(SWT.java:3358) at org.eclipse.swt.SWT.error(SWT.java:3297) at org.eclipse.swt.SWT.error(SWT.java:3268) at org.eclipse.swt.graphics.ImageLoader.load(ImageLoader.java:125) at org.eclipse.swt.graphics.ImageDataLoader.load(ImageDataLoader.java:22) at org.eclipse.swt.graphics.ImageData.<init>(ImageData.java:328) at org.eclipse.swt.graphics.Image.<init>(Image.java:505) at org.eclipse.birt.report.designer.util.ImageManager.getImage(ImageManager.java:209) at org.eclipse.birt.report.designer.core.model.schematic.ImageHandleAdapter.getImage(ImageHandleAdapter.java:54) at org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.ImageEditPart.refreshFigure(ImageEditPart.java:120) at org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.ReportElementEditPart.refreshVisuals(ReportElementEditPart.java:515) at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:676) at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:554) at org.eclipse.gef.editparts.AbstractEditPart.addNotify(AbstractEditPart.java:235) at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addNotify(AbstractGraphicalEditPart.java:212) at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:198) at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(AbstractEditPart.java:727) at org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.ReportElementEditPart.refreshChildren(ReportElementEditPart.java:526) at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:677) at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:554) at org.eclipse.gef.editparts.AbstractEditPart.addNotify(AbstractEditPart.java:235) at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addNotify(AbstractGraphicalEditPart.java:212) at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:198) at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(AbstractEditPart.java:727) at org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.ReportElementEditPart.refreshChildren(ReportElementEditPart.java:526) at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:677) at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:554) at org.eclipse.gef.editparts.AbstractEditPart.addNotify(AbstractEditPart.java:235) at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addNotify(AbstractGraphicalEditPart.java:212) at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:198) at org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(AbstractEditPart.java:727) at org.eclipse.birt.report.designer.internal.ui.editors.schematic.editparts.ReportElementEditPart.refreshChildren(ReportElementEditPart.java:526) at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:677) at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:554) at org.eclipse.gef.editparts.AbstractEditPart.addNotify(AbstractEditPart.java:235) at org.eclipse.gef.editparts.AbstractGraphicalEditPart.addNotify(AbstractGraphicalEditPart.java:212) at org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:198) at org.eclipse.gef.editparts.SimpleRootEditPart.setContents(SimpleRootEditPart.java:101) at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents(AbstractEditPartViewer.java:583) at org.eclipse.gef.ui.parts.AbstractEditPartViewer.setContents(AbstractEditPartViewer.java:592) at org.eclipse.birt.report.designer.internal.ui.editors.layout.ReportEditorWithPalette.setContents(ReportEditorWithPalette.java:509) at org.eclipse.birt.report.designer.internal.ui.editors.layout.ReportEditorWithPalette.initializeGraphicalViewer(ReportEditorWithPalette.java:498) at org.eclipse.birt.report.designer.internal.ui.editors.parts.GraphicalEditorWithFlyoutPalette.createGraphicalViewer(GraphicalEditorWithFlyoutPalette.java:541) at org.eclipse.birt.report.designer.internal.ui.editors.layout.ReportEditorWithRuler.createGraphicalViewer(ReportEditorWithRuler.java:60) at org.eclipse.gef.ui.parts.GraphicalEditor.createPartControl(GraphicalEditor.java:163) at org.eclipse.birt.report.designer.internal.ui.editors.parts.GraphicalEditorWithFlyoutPalette.createPartControl(GraphicalEditorWithFlyoutPalette.java:388) at org.eclipse.birt.report.designer.ui.editors.pages.ReportLayoutEditorFormPage.createPartControl(ReportLayoutEditorFormPage.java:211) at org.eclipse.ui.forms.editor.FormEditor.pageChange(FormEditor.java:462) at org.eclipse.birt.report.designer.ui.editors.MultiPageReportEditor.pageChange(MultiPageReportEditor.java:556) at org.eclipse.ui.forms.editor.FormEditor.setActivePage(FormEditor.java:596) at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:280) at org.eclipse.birt.report.designer.ui.editors.ReportEditorProxy.createPartControl(ReportEditorProxy.java:121) at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:596) at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:372) at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:566) at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:290) at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:140) at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:268) at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65) at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:394) at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1144) at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1097) at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1311) at org.eclipse.ui.internal.PartStack.add(PartStack.java:455) at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:102) at org.eclipse.ui.internal.PartStack.add(PartStack.java:441) at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:111) at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:60) 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:820) at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:719) at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:680) at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2593) at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2528) at org.eclipse.ui.internal.WorkbenchPage.access$10(WorkbenchPage.java:2520) at org.eclipse.ui.internal.WorkbenchPage$9.run(WorkbenchPage.java:2505) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67) at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2500) at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2477) at org.eclipse.ui.internal.editors.text.OpenExternalFileAction.run(OpenExternalFileAction.java:132) at org.eclipse.ui.internal.editors.text.OpenExternalFileAction.run(OpenExternalFileAction.java:100) at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:254) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent(WWinPluginAction.java:229) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:539) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:400) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3166) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2842) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400) 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:324) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336) at org.eclipse.core.launcher.Main.basicRun(Main.java:280) at org.eclipse.core.launcher.Main.run(Main.java:977) at org.eclipse.core.launcher.Main.main(Main.java:952)
UI/org.eclipse.birt.report.designer.core/src/org/eclipse/birt/report/designer/util/ImageManager.java
{
			return new URL( uri );
		}
		catch ( MalformedURLException e )
		{
			String path = URIUtil.getLocalPath( uri );
			if ( path != null )
			{
				ModuleHandle designHandle = SessionHandleAdapter.getInstance( )
						.getReportDesignHandle( );
				
				return designHandle.findResource( path, IResourceLocator.IMAGE );
			}
			return URI.create( uri ).toURL( );
		}
	}
	/**
	 * Generate hash key.
	 * 
	 * @param reportDesignHandle
	 *            Moudle handle
	 * @param name
	 *            Name
	 * @return key string
	 */
	public String generateKey( ModuleHandle reportDesignHandle, String name )
	{
		return reportDesignHandle.hashCode( ) + EMBEDDED_SUFFIX + name;
	}
}