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

Bug 507064

Summary: CCE or NPE during some diagram opening without "refresh at opening"
Product: [Modeling] Sirius Reporter: Laurent Redor <laurent.redor>
Component: DiagramAssignee: Florian Barbin <florian.barbin>
Status: CLOSED FIXED QA Contact: Laurent Redor <laurent.redor>
Severity: major    
Priority: P3 CC: florian.barbin, laurent.fasani, steve.monnier
Version: 4.1.0Keywords: triaged
Target Milestone: 5.1.4   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/132682
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=7f8dfd96be7ce7449b2a19357d84a6a4f7e2fe8f
https://git.eclipse.org/r/133172
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=f177417cd2a5f7429a5128ae53b777754f2c14c0
Whiteboard:
Bug Depends on:    
Bug Blocks: 541555    
Attachments:
Description Flags
ModelingProjectB_after.zip
none
ModelingProjectB_before.zip
none
fullStackOfClassCastException.txt
none
ModelingProjectA_after.zip
none
ModelingProjectA_before.zip
none
fullStackOfNullPointerException.txt
none
ModelingProjectA_after.zip none

Description Laurent Redor CLA 2016-11-04 11:57:39 EDT
Created attachment 265198 [details]
ModelingProjectB_after.zip

In some circumstance, the diagram can have GMF nodes without element. The Sirius code does not expect these cases and there is some ClassCastException or NullPointerException during the EditParts initialization.
If the refresh at opening is enabled, there is no problem because the refresh cleans the orphan nodes before the EditParts initialization.

Steps to reproduce:
* Open the project ModelingProjectB_after from ModelingProjectB_after.zip
* Disable the automatic refresh preferences ("Preferences/Sirius/Do refresh on representation opening"=false and "Preferences/Sirius/Automatic Refresh"=false)
* Open the diagram "new Diag"
* KO: A message is display in the diagram "Failed to create the part's controls". And as details, we can see this log:
java.lang.ClassCastException: org.eclipse.sirius.diagram.business.internal.metamodel.spec.DNodeContainerSpec cannot be cast to org.eclipse.sirius.diagram.WorkspaceImage
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.WorkspaceImageEditPart.createNodeShape(WorkspaceImageEditPart.java:127)
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.WorkspaceImageEditPart.createNodeFigure(WorkspaceImageEditPart.java:186)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart.createFigure(ShapeNodeEditPart.java:90)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.getFigure(AbstractGraphicalEditPart.java:494)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart.addChildVisual(BorderedBorderItemEditPart.java:88)
	
The full stack is available in fullStackOfClassCastException.txt.

The project ModelingProjectB_after has been "build" from ModelingProjectB_before. The modifications have been made manually in the aird file as we don't know currently how the customer got in this situation.

The problem can be slightly different if a label is displayed for border node.

Steps to reproduce:
* Open the project ModelingProjectA_after from ModelingProjectA_after.zip
* Disable the automatic refresh preferences ("Preferences/Sirius/Do refresh on representation opening"=false and "Preferences/Sirius/Automatic Refresh"=false)
* Open the diagram "new Diag"
* KO: A message is display in the diagram "Failed to create the part's controls". And as details, we can see this log:
java.lang.NullPointerException
	at org.eclipse.sirius.diagram.ui.edit.api.part.DiagramNameEditPartOperation.refreshFont(DiagramNameEditPartOperation.java:123)
	at org.eclipse.sirius.diagram.ui.edit.api.part.DiagramNameEditPartOperation.refreshFont(DiagramNameEditPartOperation.java:92)
	at org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramNameEditPart.refreshFont(AbstractDiagramNameEditPart.java:111)
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.AbstractGeneratedDiagramNameEditPart.refreshVisuals(AbstractGeneratedDiagramNameEditPart.java:358)
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeNameEditPart.refreshVisuals(DNodeNameEditPart.java:115)
	at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractEditPart.java:725)
	at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:644)

	The full stack is available in fullStackOfNullPointerException.txt.

The project ModelingProjectB_after has been "build" from ModelingProjectB_before.
Comment 1 Laurent Redor CLA 2016-11-04 11:57:59 EDT
Created attachment 265199 [details]
ModelingProjectB_before.zip
Comment 2 Laurent Redor CLA 2016-11-04 11:58:22 EDT
Created attachment 265200 [details]
fullStackOfClassCastException.txt
Comment 3 Laurent Redor CLA 2016-11-04 11:58:38 EDT
Created attachment 265201 [details]
ModelingProjectA_after.zip
Comment 4 Laurent Redor CLA 2016-11-04 11:58:51 EDT
Created attachment 265202 [details]
ModelingProjectA_before.zip
Comment 5 Laurent Redor CLA 2016-11-04 11:59:15 EDT
Created attachment 265203 [details]
fullStackOfNullPointerException.txt
Comment 6 Laurent Redor CLA 2016-11-04 12:00:32 EDT
Created attachment 265204 [details]
ModelingProjectA_after.zip
Comment 7 Steve Monnier CLA 2016-11-08 04:53:19 EST
I reproduced both issue with the samples. These issues will be fixed in a next version.
Comment 8 Laurent Redor CLA 2016-11-16 05:02:06 EST
Finally, this issue will not be fixed. The model is corrupted with a customer action and it is not in an expected state. Even if the detected exceptions would be fixed, there are probably other similar exceptions in Sirius code as it does not expect a model in this state.
Comment 9 Florian Barbin CLA 2018-11-16 10:29:35 EST
I reopen it since we will finally make a fix in case of CCE or NPE.
If this kind of issue occurs during the diagram opening, we will invite the user to perform a refresh and reopen the diagram.
Comment 10 Eclipse Genie CLA 2018-11-19 08:25:04 EST
New Gerrit change created: https://git.eclipse.org/r/132682
Comment 12 Eclipse Genie CLA 2018-11-28 04:52:08 EST
New Gerrit change created: https://git.eclipse.org/r/133172
Comment 14 Laurent Fasani CLA 2018-12-06 05:37:06 EST
validated with T4C1.2.2
Comment 15 Pierre-Charles David CLA 2019-01-24 04:53:50 EST
Available in Sirius 5.1.4, see https://wiki.eclipse.org/Sirius/5.1.4 for details.