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

Bug 531758

Summary: NPE in workbench in equinox registry event processing
Product: [RT] RAP Reporter: Arnaud MERGEY <a_mergey>
Component: WorkbenchAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.4   
Target Milestone: 3.5 M2   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/118334
https://git.eclipse.org/c/rap/org.eclipse.rap.git/commit/?id=f49ba5040d4bfc24e79f28d280f1340796701192
Whiteboard:
Attachments:
Description Flags
Sample Application none

Description Arnaud MERGEY CLA 2018-02-27 15:30:50 EST
Created attachment 272922 [details]
Sample Application

I noticed a backround NPE in our application I managed to reproduce with a simple application 
(launch the attached sample and click the button, you will see the NPE in console)

It occurs when runnable used with jface progressmonitor dialog do something that fire an event in equinox registry. 
In ProgressInfoItem line 186, Display.getCurrent return null.

If I execute the same code inside an Eclipse Job, the NPE does not occurs, Display.getCurrent return the display, not null.

I do relly understand why it behaves differently between Job and ProgressDialog, 
but, according to comment above in the code (and bug 341816) it seems a fix could be to use Display.getDefault instead of Display.getCurrent
Comment 1 Ivan Furnadjiev CLA 2018-02-28 03:59:41 EST
The problem is that ProgressManagerProvider#getInstance() is called from non UI thread. As a result the the session display is available, but the thread is different - Display#getCurrent return null because of that.
Comment 2 Eclipse Genie CLA 2018-02-28 04:55:38 EST
New Gerrit change created: https://git.eclipse.org/r/118334