Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 362501 - [Compatibility] NPE when showing view with non-existant part class
Summary: [Compatibility] NPE when showing view with non-existant part class
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.2 M4   Edit
Assignee: Remy Suen CLA
QA Contact: Remy Suen CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-31 11:17 EDT by Brian de Alwis CLA
Modified: 2012-01-24 13:23 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian de Alwis CLA 2011-10-31 11:17:14 EDT
BuildId: I20111028-1100

I'm getting an NPE when my code tries to open a view whose part class does not exist.  The process seems to be:

1. CompatibilityPart#create() attempts to instantiate the part class (line 227)
2. The instantiation fails causing PartInitException to be thrown
3. The PartInitException exception is caught and the handling eventually calls at line 240 into CompatibilityView#disposeSite().  
4. #disposeSite assumes the site has been created — but it has not as ViewReference#initialize() hadn't yet been been called in CompatibilityPart#create()

I wondered if #disposeSite() should simply return if getReference().getSite() == null?

Ful stack trace:

Daemon Thread [Thread-1] (Suspended (exception NullPointerException))	
	CompatibilityView.disposeSite() line: 151	
	CompatibilityView(CompatibilityPart).create() line: 240	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object...) line: 597	
	MethodRequestor.execute() line: 56	
	InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>) line: 838	
	InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>) line: 818	
	InjectorImpl.inject(Object, PrimaryObjectSupplier, PrimaryObjectSupplier) line: 110	
	InjectorImpl.internalMake(Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier) line: 317	
	InjectorImpl.make(Class<T>, PrimaryObjectSupplier) line: 239	
	ContextInjectionFactory.make(Class<T>, IEclipseContext) line: 153	
	ReflectionContributionFactory.createFromBundle(Bundle, IEclipseContext, IEclipseContext, URI) line: 90	
	ReflectionContributionFactory.doCreate(String, IEclipseContext, IEclipseContext) line: 64	
	ReflectionContributionFactory.create(String, IEclipseContext) line: 53	
	ContributedPartRenderer.createWidget(MUIElement, Object) line: 141	
	PartRenderingEngine.createWidget(MUIElement, Object) line: 861	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 615	
	PartRenderingEngine$6.run() line: 504	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement, Object, IEclipseContext) line: 489	
	ElementReferenceRenderer.createWidget(MUIElement, Object) line: 74	
	PartRenderingEngine.createWidget(MUIElement, Object) line: 861	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 615	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 717	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688	
	PartRenderingEngine$7.run() line: 682	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 667	
	StackRenderer.showTab(MUIElement) line: 723	
	StackRenderer(LazyStackRenderer).postProcess(MUIElement) line: 98	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 631	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 717	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688	
	PartRenderingEngine$7.run() line: 682	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 667	
	SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 59	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 627	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 717	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688	
	PartRenderingEngine$7.run() line: 682	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 667	
	SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 59	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 627	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 717	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688	
	PartRenderingEngine$7.run() line: 682	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 667	
	PerspectiveRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 59	
	PerspectiveRenderer.processContents(MElementContainer<MUIElement>) line: 59	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 627	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 717	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688	
	PartRenderingEngine$7.run() line: 682	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 667	
	PerspectiveStackRenderer.showTab(MUIElement) line: 103	
	PerspectiveStackRenderer(LazyStackRenderer).postProcess(MUIElement) line: 98	
	PerspectiveStackRenderer.postProcess(MUIElement) line: 77	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 631	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 717	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688	
	PartRenderingEngine$7.run() line: 682	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 667	
	SashRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 59	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 627	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 717	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688	
	PartRenderingEngine$7.run() line: 682	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 667	
	WBWRenderer(SWTPartRenderer).processContents(MElementContainer<MUIElement>) line: 59	
	WBWRenderer.processContents(MElementContainer<MUIElement>) line: 581	
	PartRenderingEngine.safeCreateGui(MUIElement, Object, IEclipseContext) line: 627	
	PartRenderingEngine.safeCreateGui(MUIElement) line: 717	
	PartRenderingEngine.access$2(PartRenderingEngine, MUIElement) line: 688	
	PartRenderingEngine$7.run() line: 682	
	SafeRunner.run(ISafeRunnable) line: 42	
	PartRenderingEngine.createGui(MUIElement) line: 667	
	PartRenderingEngine$9.run() line: 933	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 888	
	E4Workbench.createAndRunUI(MApplicationElement) line: 90	
	Workbench$3.run() line: 565	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 520	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	ProjectExplorerApplication.start(IApplicationContext) line: 14	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 352	
	EclipseStarter.run(String[], Runnable) line: 179	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object...) line: 597	
	Main.invokeFramework(String[], URL[]) line: 624	
	Main.basicRun(String[]) line: 579	
	Main.run(String[]) line: 1431	
	Main.main(String[]) line: 1407
Comment 1 Remy Suen CLA 2011-10-31 13:59:15 EDT
(In reply to comment #0)
> I wondered if #disposeSite() should simply return if getReference().getSite()
> == null?

Both CompatibilityPart and CompatibilityEditor does seem to guard against this.
Comment 2 Remy Suen CLA 2011-11-02 14:00:40 EDT
Fix pushed to master. Thanks for the bug report, Brian.
http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=69bf99a1d131cd5d8240e9ff416f4c3ae5081fed
Comment 3 Brian de Alwis CLA 2012-01-24 13:23:03 EST
Verified in I20120123-2200