directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Richardson (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DIRSTUDIO-1046) EntryEditorManager constructor can throw NPE
Date Sun, 24 May 2015 15:38:17 GMT

    [ https://issues.apache.org/jira/browse/DIRSTUDIO-1046?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14557760#comment-14557760
] 

Paul Richardson commented on DIRSTUDIO-1046:
--------------------------------------------

[~elecharny]

Apologies. Have been on holiday last couple of days.

Look at this again, your changes above are not going to work as an instance of EntryEditorManager
would be created but that instance would not be initialised. My suggestion was actually to
null-check ActiveWorkbenchWindow in BrowserUiPlugin and only instantiate the singleton EntryEditorManager.
However, this leaves the possibility that BrowserUiPlugin.getEntryEditorManager() could return
null and there are about 17 examples of calling this method and expecting an instance rather
than null. Want to avoid introducing NPEs.

Therefore, I think my original thought is probably the only option, ie. use PlatformUI.getWorkbench().getWorkbenchWindows().
For each window, call getPartService().addPartListener(...) as originally defined. This will
ensure that the EntryEditorManager is correctly initialsed regardless of the thread calling
it. What do you think?

> EntryEditorManager constructor can throw NPE
> --------------------------------------------
>
>                 Key: DIRSTUDIO-1046
>                 URL: https://issues.apache.org/jira/browse/DIRSTUDIO-1046
>             Project: Directory Studio
>          Issue Type: Bug
>          Components: studio-ldapbrowser
>    Affects Versions: 2.0.0-M8 (2.0.0.v20130628)
>            Reporter: Paul Richardson
>
> Using the BrowserWidget in a wizard rather than the BrowserView can result in a NullPointerException
being thrown.
> The BrowseWidget is embedded in a WizardPage so the org.apache.directory.ldapbrowser.ui
plugin has not necessarily been activated. However, during a refresh of the BrowserWidget's
tree view, a worker-runnable calls on resources of the ldapbrowser.ui plugin and it is activated.
> The activation of the ldapbrowser.ui plugin calls
> {code}
> entryEditorManager = new EntryEditorManager();
> {code}
> The constructor of the EntryEditorManager contains
> {code}
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener(
partListener );
> {code}
> This code only works if called from the UI thread. Otherwise, getActiveWorkbenchWindow()
returns null hence the NPE.
> Since a runnable is responsible for the plugin activation in this use-case then this
behaviour occurs.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message