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

Bug 337636

Summary: NPE with extensibleSpashHandler extension
Product: [Eclipse Project] Platform Reporter: Thomas Kratz <eiswind>
Component: UIAssignee: Paul Webster <pwebster>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ChrisAustin, pinnamur, pwebster
Version: 4.1   
Target Milestone: 4.2.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Patch to create sharedImages on demand none

Description Thomas Kratz CLA 2011-02-19 10:23:58 EST
Build Identifier: 4.1 M5

I have an extensible splash handler that fails and stays on screen with a NPE where it looks like the e4context is not initialized at that point. the splashhandler is nearly almost equal to the template

java.lang.NullPointerException
	at org.eclipse.ui.internal.WorkbenchPlugin.getSharedImages(WorkbenchPlugin.java:643)
	at org.eclipse.ui.internal.Workbench.getSharedImages(Workbench.java:1235)
	at org.eclipse.ui.plugin.AbstractUIPlugin.imageDescriptorFromPlugin(AbstractUIPlugin.java:670)
	at de.eiswind.mango.client.core.splashHandlers.ExtensibleSplashHandler.processSplashElementIcon(ExtensibleSplashHandler.java:240)
	at de.eiswind.mango.client.core.splashHandlers.ExtensibleSplashHandler.processSplashElements(ExtensibleSplashHandler.java:210)
	at de.eiswind.mango.client.core.splashHandlers.ExtensibleSplashHandler.processSplashExtension(ExtensibleSplashHandler.java:201)
	at de.eiswind.mango.client.core.splashHandlers.ExtensibleSplashHandler.loadSplashExtensions(ExtensibleSplashHandler.java:189)
	at de.eiswind.mango.client.core.splashHandlers.ExtensibleSplashHandler.init(ExtensibleSplashHandler.java:68)
	at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:694)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.Workbench.createSplashWrapper(Workbench.java:715)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2330)
	at org.eclipse.ui.internal.Workbench.access$3(Workbench.java:2303)
	at org.eclipse.ui.internal.Workbench$3.run(Workbench.java:538)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:522)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at de.eiswind.paris.client.core.Application.start(Application.java:33)
	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:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	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:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

Reproducible: Always

Steps to Reproduce:
1. create an extensible splash handler
2. add some images
3. start up
Comment 1 Praveen CLA 2011-03-25 10:05:34 EDT
I will try to look into this.
Comment 2 Chris Austin CLA 2012-12-12 13:10:11 EST
Rational is also running into this problem.  We use a common splash screen for nearly all of our products, and calling AbstractUIPlugin.imageDescriptorFromPlugin() throws an NPE because e4context is null.
Comment 3 Paul Webster CLA 2012-12-12 13:38:31 EST
It's possible to add a null check and probably replicated the same code for ISharedImages that's in the org.eclipse.ui.internal.WorkbenchPlugin.initializeContext(IEclipseContext) method called later.

I'd accept a patch.

PW
Comment 4 Chris Austin CLA 2012-12-12 14:35:00 EST
A check for null is a good idea, but I don't think I understand the rest of your comment.  Is there still a way we can retrieve an image during the splash screen load?
Comment 5 Paul Webster CLA 2012-12-12 14:50:48 EST
I think we could have the code try e4Context first, but if it's null and the local var is null, fall back to:

if (sharedImages == null) {
	sharedImages = new SharedImages();
}
return sharedImages;

PW
Comment 6 Jens Kuebler CLA 2012-12-14 09:10:03 EST
Created attachment 224736 [details]
Patch to create sharedImages on demand
Comment 7 Eric Moffatt CLA 2012-12-17 14:09:08 EST
Paul, is this going to result in two copies of the shared images since we're going to eventually add another instance when we set up the context ?

Is there any way to delay the ExtensibleSplashHandler until after the e4Context has been initialized, this would be the 'correct' fix IMO.
Comment 8 Paul Webster CLA 2012-12-17 14:10:22 EST
(In reply to comment #7)
> Paul, is this going to result in two copies of the shared images since we're
> going to eventually add another instance when we set up the context ?

No, our context setup is done in such a way that there will only be on SharedImages registry.

PW
Comment 9 Chris Austin CLA 2012-12-17 14:25:41 EST
To be honest, I was still a little confused by the potential fix, because the images we need at splash screen time are not SharedImages, they are icons we ship in our product plugins.

I was planning to actually avoid the call by using  ImageDescriptor.createFromURL(), which doesn't throw an NPE.  
The only question about this approach is whether ImageDescriptor.createFromURL() handles nl images (but I understand that is a little off-topic).
Comment 10 Paul Webster CLA 2012-12-17 14:40:18 EST
(In reply to comment #9)
> To be honest, I was still a little confused by the potential fix, because
> the images we need at splash screen time are not SharedImages, they are
> icons we ship in our product plugins.

The problem you're seeing is that AbstractUIPlugin.imageDescriptorFromPlugin(*) is checking ISharedImages.  It's one of the locations we can load images from, but it's not relevant for your call.  You're just hitting it to early in the startup cycle and our slightly re-configured loading wasn't ready yet.

The fix will make it the ISharedImages check a no-op as far as you're concerned, which is what you get in 3.x.

> 
> I was planning to actually avoid the call by using 
> ImageDescriptor.createFromURL(), which doesn't throw an NPE.  
> The only question about this approach is whether
> ImageDescriptor.createFromURL() handles nl images (but I understand that is
> a little off-topic).

I'm not sure this'll handle the $nl$, but it might for platform:/plugin URLs (support for that was added a while ago).

PW
Comment 11 Paul Webster CLA 2012-12-17 14:48:33 EST
(In reply to comment #6)
> Created attachment 224736 [details]
> Patch to create sharedImages on demand

Released as http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?h=R4_2_maintenance&id=c4c9b9c6cd031d5bd96a5b85a44fb8e498725184


Thanx Jens.

PW
Comment 12 Paul Webster CLA 2013-01-17 13:00:18 EST
In M20130116-1800

PW
Comment 13 Paul Webster CLA 2013-01-17 13:08:14 EST
.