Bug 444802 - NPE on SiriusValidationDecoratorProvider when ask for a validation
Summary: NPE on SiriusValidationDecoratorProvider when ask for a validation
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 1.0.1   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Maxime Porhel CLA
QA Contact:
URL:
Whiteboard: backport
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2014-09-23 04:29 EDT by Etienne Juliot CLA
Modified: 2015-03-06 03:38 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Etienne Juliot CLA 2014-09-23 04:29:17 EDT
I found this NPE.
It occurs only one time. I restarted my eclipse and now, I didn't success to reproduce it and everything works well. Strange, and I don't know how to explain you which steps I used to find this error.
I had a semantic based validator and I launched "validate diagram". Nothing occurs except this exception.

!ENTRY org.eclipse.sirius.diagram 4 0 2014-09-22 11:57:22.483
!MESSAGE Decorator refresh failure
!STACK 0
java.lang.NullPointerException
	at org.eclipse.sirius.diagram.ui.internal.providers.SiriusValidationDecoratorProvider$1.run(SiriusValidationDecoratorProvider.java:136)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4147)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3764)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:384)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:239)
	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:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Comment 1 Pierre-Charles David CLA 2014-10-13 05:28:31 EDT
The line in question does:

  TransactionUtil.getEditingDomain(fdiagram).runExclusive(...)

but it does it inside a Runnable wich is executed asynchronously. If the runnable is deferred and executed only after the session is closed or the diagram removed (basically anything that detaches the diagram from the editing domain), TransactionUtil.getEditingDomain(fdiagram) can return null.

We should probably simply add a guard in the runnable, and do nothing if the diagram for which we were asked to refresh the decorators is not in the editing domain anymore.
Comment 2 Maxime Porhel CLA 2015-03-05 10:50:04 EST
The issue is(In reply to Pierre-Charles David from comment #1)
> The line in question does:
> 
>   TransactionUtil.getEditingDomain(fdiagram).runExclusive(...)
> 
>...
> 
> We should probably simply add a guard in the runnable, and do nothing if the
> diagram for which we were asked to refresh the decorators is not in the
> editing domain anymore.

This will not be sufficient: the decorator are deactivated when their editpart is deactivated/removed. 

The real issue is the fileOberserver is static and created on the first activation of a StatusDecorator. If a change is detected on a IMarker (add/delete), this will trigger the refresh of the decorator with a same viewId, but there will be no check that the decorator's view is in the same editing domain than the diagram referenced by the MarkerObserver. 

Steps to reproduce: 
 . Open a session on an ecore file
 . Create a package entities diagram 
 . Create an EPackage with no uri and no prefix
 . Use the validate diagram action > you will have error decorators on the diagram
 .
 . Open a second session on another ecore model
 . Create a package entities diagram 
 . Create an EPackage with no uri and no prefix
 . Use the validate diagram action > you will have error decorators on the diagram
 .
 . Close the first session
 . Put a prefix and an uri to the invalid package of the second session
 . Validate
 . You should get the NPE