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

Bug 502053

Summary: Editor not in registry leads to NPE
Product: [Modeling] Sirius Reporter: Jens Li <skrap>
Component: CoreAssignee: Maxime Porhel <maxime.porhel>
Status: CLOSED FIXED QA Contact: Julien Dupont <julien.dupont>
Severity: normal    
Priority: P3 CC: julien.dupont, maxime.porhel, pierre-charles.david
Version: 4.0.0Keywords: triaged
Target Milestone: 4.1.0   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/81793
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=4d55ea1ff4fba5b01edcba33c4bfc16b78b05e91
https://git.eclipse.org/r/83116
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=6244b543d75102602fef55b36c3dc301caf04528
https://git.eclipse.org/r/83837
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=0f387e84a668ef1c376d17e380914e60d47e5dcb
Whiteboard:

Description Jens Li CLA 2016-09-23 06:48:51 EDT
If the diagram editor is not present in platform editor registry the leads to a null pointer dereference in the DDiagramEditorSessionListenerDelegate.getInitialImage method.

This is the case, for example, if the Sirius editor is part of a MultiPageEditor. In that case EditorSite.getId will always return the empty string.
Comment 1 Eclipse Genie CLA 2016-09-23 09:43:56 EDT
New Gerrit change created: https://git.eclipse.org/r/81793
Comment 2 Maxime Porhel CLA 2016-09-23 09:44:54 EDT
Hi Lii, thanks for your feedback.

I can see the cause of the NPE in the code. 
There is no support of the MultiPageEditor, so I am not sure we can find a scenario to reproduce this NPE with standard Sirius editors. 

The potential NPE can be corrected in DDiagramEditorSessionListenerDelegate.getInitialImage but this bugzilla will be validated as technical issue.
Comment 3 Pierre-Charles David CLA 2016-09-23 09:58:43 EDT
Hi.

Just to complete Maxime's answer: the use cases you mention ("diagram editor is not present in platform editor registry", "the Sirius editor is part of a MultiPageEditor") are not supported by Sirius. While we agree it would be a nice feature to have, it would probably require significant work, beyond fixing immediatly visible crashes like this one. This is not something we have planned for a future release at the moment (although if you wanted to work on this and/or sponsor the required development, we can probably discuss about it).

In the meantime, we'll fix this particular NPE because it is easy and low risk, but we can't give any guarantee about the behavior of Sirius in such a context, or that we'll fix other issues you could find (again, unless you want to contribute fixes and/or sponsor them).

Regards,
Pierre-Charles
Comment 5 Pierre-Charles David CLA 2016-09-29 09:09:33 EDT
Moving to 4.1.0 since the patch fixing the NPE was merged, but only this particular scenario will be treated here.
Comment 6 Jens Li CLA 2016-10-04 07:43:31 EDT
Great to have this fixed so promptly. Thank!

Before the fix this issue could be worked around by overriding to host editors createSite method and return an IEditorSite with an ID.

We are currently experimenting with a Sirius editor inside a multi page editor. So far we are able to more around entities, preform undo/redo and save. Undo/redo took some work to get working. The next step is to connect the toolbars.

If we manage to get this to work in a nice way maybe we'll do a writeup somewhere about our solution.
Comment 7 Pierre-Charles David CLA 2016-10-04 08:25:55 EDT
(In reply to Lii Woo from comment #6)
> Great to have this fixed so promptly. Thank!
> 
> Before the fix this issue could be worked around by overriding to host
> editors createSite method and return an IEditorSite with an ID.
> 
> We are currently experimenting with a Sirius editor inside a multi page
> editor. So far we are able to more around entities, preform undo/redo and
> save. Undo/redo took some work to get working. The next step is to connect
> the toolbars.
> 
> If we manage to get this to work in a nice way maybe we'll do a writeup
> somewhere about our solution.

Thanks for the information, that sounds promising!

Like I said, we recognize it would be a nice feature to have, but it's just not part of our priorities at the moment. If you pursue this effort, don't hesitate to keep us informed (you can contact me directly by email), and if you find isolated bugs like this one that we can fix quickly to help you moving forward, don't hesitate. We will probably not be able to invest significant time in complex bug fixes and refactorings (unless sponsored), but for small things like this one, don't hesistate and we'll do our best with available resources.
Comment 8 Eclipse Genie CLA 2016-10-13 09:44:15 EDT
New Gerrit change created: https://git.eclipse.org/r/83116
Comment 9 Pierre-Charles David CLA 2016-10-18 11:08:37 EDT
Available in Sirius 4.1.0, see https://wiki.eclipse.org/Sirius/4.1.0 for details.