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

Bug 485399

Summary: NPE when loading Resources with errors
Product: [Modeling] Sirius Reporter: Dennis Huebner <dennis.huebner>
Component: CoreAssignee: Project inbox <sirius.core-inbox>
Status: CLOSED FIXED QA Contact: Florian Barbin <florian.barbin>
Severity: normal    
Priority: P3 CC: florian.barbin, laurent.fasani, laurent.redor, pierre-charles.david
Version: 3.1.0Keywords: triaged
Target Milestone: 4.0.0M6   
Hardware: PC   
OS: Mac OS X   
See Also: https://git.eclipse.org/r/63872
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=c1efa7982a432a2ee2d0047be7b70690c444a9fa
https://bugs.eclipse.org/bugs/show_bug.cgi?id=490904
Whiteboard:

Description Dennis Huebner CLA 2016-01-08 05:24:22 EST
I'm using Sirius 3.1.1

In org.eclipse.sirius.business.api.resource.LoadEMFResource.run() Line: 66

res = set.getResource(uri, true);
if (!res.getErrors().isEmpty()) {
   // The file was previously loaded with errors. It might have
   // changed, unload it before reload.
   unload();
}
res.load(getOptions());

unload() sets 'res' field to NULL (Line 101), in the next line res is accessed, that cause an NPE
Comment 1 Dennis Huebner CLA 2016-01-08 06:55:13 EST
java.lang.NullPointerException
at org.eclipse.sirius.business.api.resource.LoadEMFResource.run(LoadEMFResource.java:71)
at org.eclipse.sirius.ui.tools.api.views.modelexplorerview.resourcelistener.DefaultModelingProjectResourceListener.isLoadableModel(DefaultModelingProjectResourceListener.java:183)
at org.eclipse.sirius.ui.tools.api.views.modelexplorerview.resourcelistener.ResourceDeltaVisitor.visitFileWithOpenedRepresentationsFile(ResourceDeltaVisitor.java:229)
at org.eclipse.sirius.ui.tools.api.views.modelexplorerview.resourcelistener.ResourceDeltaVisitor.visitFile(ResourceDeltaVisitor.java:183)
at org.eclipse.sirius.ui.tools.api.views.modelexplorerview.resourcelistener.ResourceDeltaVisitor.visit(ResourceDeltaVisitor.java:88)
at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:63)
at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:74)
at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:74)
at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:47)
at org.eclipse.sirius.ui.tools.api.views.modelexplorerview.resourcelistener.DefaultModelingProjectResourceListener.resourceChanged(DefaultModelingProjectResourceListener.java:81)
at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:299)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:289)
at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:152)
at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:373)
at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1470)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2250)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:130)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)
Comment 2 Laurent Fasani CLA 2016-01-08 10:19:06 EST
Thanks for your detailed bug report.
We have reproduced this issue and we consider it as valid.
Nevertheless, we have currently not planned to work on it in the following releases.
Comment 3 Eclipse Genie CLA 2016-01-08 11:52:40 EST
New Gerrit change created: https://git.eclipse.org/r/63872
Comment 6 Pierre-Charles David CLA 2016-04-04 05:10:37 EDT
Dennis, note that the fix was also backported to the 3.1.x maintenance branch for the (not yet released) 3.1.5 version, as part of bug 490904 (which reported the same issue independently).
Comment 7 Dennis Huebner CLA 2016-04-04 05:28:04 EDT
(In reply to Pierre-Charles David from comment #6)
> Dennis, note that the fix was also backported to the 3.1.x maintenance
> branch for the (not yet released) 3.1.5 version, as part of bug 490904
> (which reported the same issue independently).

Cool, thanks
Comment 8 Florian Barbin CLA 2016-05-24 10:22:11 EDT
Verified on Sirius 4.0.0.RC1
Comment 9 Pierre-Charles David CLA 2016-06-24 08:04:01 EDT
Available in Sirius 4.0.0.