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

Bug 330349

Summary: [All diagrams]Applying a profile with a Property of an undefined Type corrupts the model and makes save action crash
Product: [Modeling] Papyrus Reporter: Vincent Hémery <vincent.hemery>
Component: CoreAssignee: Patrick Tessier <Patrick.Tessier>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P3    
Version: 0.7.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Vincent Hémery CLA 2010-11-16 08:49:55 EST
If a user applies a stereotype with a Property of undefined type, the model can not be save and is corrupted.

This applies to any diagram.

Steps to reproduce :

Create a profile diagram.
Create a stereotype extending Class (for example).
Add inside a property with no type defined.
 (label of the property is "")
Save the profile.
Create a Class diagram.
Apply the profile on the model.
Create a Class.
Save the model.
Apply the stereotype on the created Class.
Try to save the model : an error occurs.
At this moment, if you close the diagram, the model is corrupted at the next opening.
On the other hand, if you first remove the applied stereotype, the diagram works correctly again.


The following stack trace is available in the error log when trying to save :

java.lang.NullPointerException
    at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl$Lookup.featureKind(XMLSaveImpl.java:2998)
    at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl$Lookup.listKinds(XMLSaveImpl.java:2903)
    at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl$Lookup.getFeatures(XMLSaveImpl.java:2790)
    at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1237)
    at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2685)
    at org.eclipse.emf.ecore.xmi.impl.XMISaveImpl.writeTopObjects(XMISaveImpl.java:90)
    at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveImpl.java:592)
    at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl.java:256)
    at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLResourceImpl.java:206)
    at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1406)
    at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:993)
    at org.eclipse.papyrus.resource.AbstractBaseModel.saveModel(AbstractBaseModel.java:180)
    at org.eclipse.papyrus.resource.ModelSet.save(ModelSet.java:369)
    at org.eclipse.papyrus.core.lifecycleevents.SaveAndDirtyService.doSave(SaveAndDirtyService.java:240)
    at org.eclipse.papyrus.core.editor.CoreMultiDiagramEditor.doSave(CoreMultiDiagramEditor.java:635)
    at org.eclipse.ui.internal.SaveableHelper$2.run(SaveableHelper.java:151)
    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:2600)
    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.savePart(SaveableHelper.java:156)
    at org.eclipse.ui.internal.EditorManager.savePart(EditorManager.java:1369)
    at org.eclipse.ui.internal.WorkbenchPage.savePart(WorkbenchPage.java:3334)
    at org.eclipse.ui.internal.SaveAction.run(SaveAction.java:68)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
    at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:119)
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
    at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
    at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:468)
    at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:786)
    at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:885)
    at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:567)
    at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:508)
    at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:123)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1253)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1103)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1099)
    at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1508)
    at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4268)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4160)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4873)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2459)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3655)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Comment 1 Patrick Tessier CLA 2011-07-28 09:00:52 EDT
Normally Papyrus contains rules to test elements of profile before defining it.

this mechanism has to be reconnected  with  the validation system before trying to define the profile
Comment 2 Patrick Tessier CLA 2012-07-31 13:32:17 EDT
now validation rules runs before defining profile.
Remains to test the a profile before to apply it.
Comment 3 Patrick Tessier CLA 2012-07-31 13:37:15 EDT
revision 8681-8684 fix bug about profiles.
if a profiles contains a error done by validation rules: it cannot be defined.
if you try to apply a bad profile (error level of validation) an error is shown to users.

Registered profile do not launch validation rules before applying profiles.
	if we do that Ecore and SysML profile can not be applied, because there are not validated by Ecore validation error (extension link are badly crossed referenced).