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

Bug 455589

Summary: NPE during save
Product: [Modeling] Sirius Reporter: Laurent Redor <laurent.redor>
Component: CoreAssignee: Laurent Redor <laurent.redor>
Status: CLOSED FIXED QA Contact: Pierre-Charles David <pierre-charles.david>
Severity: major    
Priority: P3 CC: florian.barbin, pierre-charles.david
Version: 2.0.0Keywords: triaged
Target Milestone: 3.0.0M5   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
SampleProject.zip
none
SimpleSampleProject.zip none

Description Laurent Redor CLA 2014-12-18 05:06:18 EST
Steps to reproduce:
* Import the project Sample from SampleProject.zip
* Unfold reverse.ecore
* Create new representation "package entities" on "full-sirius-code" package (it's long)
* The save of the Session failed with a NPE

Corresponding stack:
!MESSAGE Save Failed
!STACK 0
java.lang.NullPointerException
	at org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.doSave(DAnalysisSessionImpl.java:1044)
	at org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl$Saver.saveNow(DAnalysisSessionImpl.java:250)
	at org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl$Saver.save(DAnalysisSessionImpl.java:231)
	at org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.save(DAnalysisSessionImpl.java:987)
	at org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.save(DAnalysisSessionImpl.java:982)
	at org.eclipse.sirius.diagram.ui.tools.internal.resource.CustomSiriusDocumentProvider.doSaveDocument(CustomSiriusDocumentProvider.java:284)
	at org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider$1SaveOperation.execute(AbstractDocumentProvider.java:596)
	at org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider$DocumentProviderOperation.run(AbstractDocumentProvider.java:66)
	at org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider.executeOperation(AbstractDocumentProvider.java:530)
	at org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider.saveDocument(AbstractDocumentProvider.java:579)
	at org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.performSave(DiagramDocumentEditor.java:860)
	at org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.doSave(DiagramDocumentEditor.java:680)
	at org.eclipse.sirius.ui.business.internal.session.SessionSaveable.doSave(SessionSaveable.java:64)
	at org.eclipse.ui.Saveable.doSave(Saveable.java:214)
	at org.eclipse.ui.internal.SaveableHelper.doSaveModel(SaveableHelper.java:349)
	at org.eclipse.ui.internal.SaveableHelper$3.run(SaveableHelper.java:195)
	at org.eclipse.ui.internal.SaveableHelper$5.run(SaveableHelper.java:277)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
	at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:759)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:756)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2649)
	at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(SaveableHelper.java:285)
	at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(SaveableHelper.java:264)
	at org.eclipse.ui.internal.SaveableHelper.saveModels(SaveableHelper.java:207)
	at org.eclipse.ui.internal.SaveableHelper.savePart(SaveableHelper.java:144)
	at org.eclipse.ui.internal.EditorManager.savePart(EditorManager.java:1399)
	at org.eclipse.ui.internal.WorkbenchPage.savePart(WorkbenchPage.java:3429)
	at org.eclipse.ui.internal.WorkbenchPage.saveEditor(WorkbenchPage.java:3442)
	at org.eclipse.gmf.runtime.diagram.ui.providers.DiagramGlobalActionHandler.getCommand(DiagramGlobalActionHandler.java:146)
	at org.eclipse.gmf.runtime.common.ui.action.global.GlobalAction.doRun(GlobalAction.java:109)
Comment 1 Laurent Redor CLA 2014-12-18 05:08:28 EST
Short analysis:
* A Throwable is catch during getSavingPolicy().save(). The status of the the "save" RunnableWithResult is set to KO and its result is Null.
* This runnable is run with getTransactionalEditingDomain().runExclusive(save). At l.336 of TransactionalEditingDomainImpl, the status is set to OK_STATUS (this overrides the previous KO).
* So after, the status.isOK() check has not the expected result and we try to iterate on the Null result without check.

This problem is here since the changed made for the bug 445603 with commit [1].

[1] http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=a2085a7c78ef11663a44fa9ebfddfbee0366736a
Comment 2 Laurent Redor CLA 2014-12-18 05:13:16 EST
Created attachment 249517 [details]
SampleProject.zip
Comment 3 Laurent Redor CLA 2014-12-18 05:14:53 EST
in comment 0, the step "Save the session" misses (at second to last step)
Comment 4 Laurent Redor CLA 2014-12-18 08:18:33 EST
Created attachment 249524 [details]
SimpleSampleProject.zip

Another steps to reproduce more quickly:
* Import the project SimpleSample from SimpleSampleProject.zip
* Unfold My.ecore
* Create new representation "package entities" on "root" package
* Save the session
* The save of the Session failed with a NPE
Comment 5 Laurent Redor CLA 2014-12-19 06:26:34 EST
A fix is proposed here: https://git.eclipse.org/r/38551
Comment 6 Pierre-Charles David CLA 2014-12-31 10:53:13 EST
Fixed by bc0d257923c241a5539398dd742760e2dc93522f.
Comment 7 Pierre-Charles David CLA 2015-05-21 09:30:23 EDT
Verified on Sirius 3.0.0rc1a.
Comment 8 Pierre-Charles David CLA 2015-06-24 11:14:11 EDT
Available in Sirius 3.0.0. See https://wiki.eclipse.org/Sirius/3.0.0.