Bug 508248 - Potential NPE in WorkspaceAndPluginsResourceDialog if no target platform is set
Summary: Potential NPE in WorkspaceAndPluginsResourceDialog if no target platform is set
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 4.1.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 5.0.0M6   Edit
Assignee: Pierre-Charles David CLA
QA Contact: Laurent Redor CLA
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2016-11-27 08:58 EST by Pierre-Charles David CLA
Modified: 2017-06-29 03:32 EDT (History)
3 users (show)

See Also:


Attachments
Sample file to reproduce the bug (1.34 KB, application/zip)
2016-11-27 08:58 EST, Pierre-Charles David CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre-Charles David CLA 2016-11-27 08:58:09 EST
Created attachment 265602 [details]
Sample file to reproduce the bug

Steps to reproduce:
1. Import the projects in the attached zip.
2. Go to "Window > Preferences > Plug-in Development > Target Platforms", select the "sample" target from the workspace and validate ("OK").
3. Close the "tp" project (where the "sample.target" is defined).
4. Restart Eclipse.
5. Go to "Window > Preferences > Plug-in Development > Target Platforms". No target is set; click "Apply" and "OK".
6. Open the VSM in vsm/sample.odesign and go to single node mapping's workspace image style
7. In the style description tab of the properties view, select the "..." button to browse the images => NPE in the error log.

java.lang.NullPointerException
	at org.eclipse.sirius.editor.tools.internal.presentation.WorkspaceAndPluginsResourceDialog$WorkbenchProxyObject.getChildren(WorkspaceAndPluginsResourceDialog.java:256)
	at org.eclipse.sirius.editor.tools.internal.presentation.WorkspaceAndPluginsResourceDialog$CustomWorkbenchAdapter.getChildren(WorkspaceAndPluginsResourceDialog.java:396)
	at org.eclipse.ui.model.BaseWorkbenchContentProvider.getChildren(BaseWorkbenchContentProvider.java:60)
	at org.eclipse.sirius.editor.tools.internal.presentation.WorkspaceAndPluginsResourceDialog$DeferredWorkbenchContentProvider.getChildren(WorkspaceAndPluginsResourceDialog.java:375)
	at org.eclipse.ui.model.BaseWorkbenchContentProvider.getElements(BaseWorkbenchContentProvider.java:67)
	at org.eclipse.ui.dialogs.ElementTreeSelectionDialog.evaluateIfTreeEmpty(ElementTreeSelectionDialog.java:384)
	at org.eclipse.ui.dialogs.ElementTreeSelectionDialog.open(ElementTreeSelectionDialog.java:235)
	at org.eclipse.sirius.editor.tools.internal.presentation.WorkspaceAndPluginsResourceDialog.openDialogForImages(WorkspaceAndPluginsResourceDialog.java:139)
	at org.eclipse.sirius.diagram.editor.properties.sections.style.workspaceimagedescription.WorkspaceImageDescriptionWorkspacePathPropertySection$1.widgetSelected(WorkspaceImageDescriptionWorkspacePathPropertySection.java:119)

Sometimes, some or all of steps 2 to 5 are not needed, and simply opening the VSM and trying to browse the image triggers the NPE. I'm not sure what are the exact underlying conditions needed, but anyway, the code in WorkspaceAndPluginsResourceDialog is not robust to the case where ITargetPlatformService.getWorkspaceTargetHandle() returns null (which is a valid return value as described in its Javadoc).
Comment 1 Eclipse Genie CLA 2016-11-27 08:59:28 EST
New Gerrit change created: https://git.eclipse.org/r/85835
Comment 3 Pierre-Charles David CLA 2017-03-08 08:49:12 EST
Fixed by 6048c9303ed9e23a1bc3be1f8cf85657d4b72fb9. The reproduction scenario involves restarting Eclipse, to we can not include a test in our suites. It will have to be tested manually.
Comment 4 Jessy Mallet CLA 2017-05-19 06:25:05 EDT
For now, the correction of this bug can not be homologate. Indeed, the Reproduction scenario is not possible to use because the "..." button to browse the images is not accessible.
Comment 5 Laurent Redor CLA 2017-05-22 10:42:42 EDT
The problem that blocks the validation will be fixed with https://git.eclipse.org/r/#/c/97634
Comment 6 Laurent Redor CLA 2017-05-24 11:58:38 EDT
Validated with Sirius 5.0 RC1 (In the step 5., I deselected the "Running Platform" that is selected by default).
Comment 7 Pierre-Charles David CLA 2017-06-29 03:32:06 EDT
Available in Sirius 5.0.0, see https://wiki.eclipse.org/Sirius/5.0.0 for details.