Community
Participate
Working Groups
In org.eclipse.sirius.ui.business.internal.session.EditingSession.closeEditor(DialectEditor, boolean) there is a fallback to close an editor that uses the code: PlatformUI.getWorkbench().getActiveWorkbenchWindow() However the java doc of getActiveWorkbenchWindow state that it can return null if called from non UI Thread. In our case it leads to an NPE. Maybe this code should be guard against being called from a non UI thread. !ENTRY org.eclipse.core.jobs 4 2 2016-06-23 17:54:34.690 !MESSAGE An internal error occurred during: "Chargement de la session de modélisation Equinoxe". !STACK 0 java.lang.NullPointerException at org.eclipse.sirius.ui.business.internal.session.EditingSession.closeEditor(EditingSession.java:228) at org.eclipse.sirius.ui.business.internal.session.EditingSession.closeEditors(EditingSession.java:208) at org.eclipse.sirius.ui.business.internal.session.EditingSession.close(EditingSession.java:278) at org.eclipse.sirius.ui.business.internal.session.SessionUIManagerImpl.notify(SessionUIManagerImpl.java:139) at org.eclipse.sirius.business.internal.session.SessionManagerImpl.notifyUpdatedSession(SessionManagerImpl.java:142) at org.eclipse.sirius.business.internal.session.SessionManagerImpl.access$1(SessionManagerImpl.java:140) at org.eclipse.sirius.business.internal.session.SessionManagerImpl$1.notify(SessionManagerImpl.java:120) at org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.notifyListeners(DAnalysisSessionImpl.java:1019) at org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.close(DAnalysisSessionImpl.java:1201) at x.x.x.x.x.createHeaderAird(EqxSessionManager.java:147)
I could effectively add a guard condition to avoid the NPE but it would be interesting to understand the what is done i the context of your scenario to check that everything is handled correctly. It seems to be the a use case close to the one in Bug 496667 and here too I would be grateful if you could provide the elements (scenario or/and data) to reproduce this bug so that I can check the fix and create a junit test.
(In reply to Laurent Fasani from comment #1) > I could effectively add a guard condition to avoid the NPE We don't want as simple guard, at least not in the sense "if (inUIthread()) {...}". We would avoid the NPE, but if it means not doing what the method is expected to do and returning silently as if everything was fine, its worse than the NPE. Depending on the calling context, either the client code should be in the UI thread or (more probably given the stack visible above), actually make sure what needs to be called in the UI thread is called in the UI thread. In the standard (non-fallback) case, we do DialectUIManager.INSTANCE.closeEditor(editor, save), which ends up calling org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.close(boolean), which ensures the final getSite().getPage().closeEditor() call is done in the UI thread. We should do something similar in our fallback case.
See https://git.eclipse.org/r/#/c/76617/ for a completly untested draft.
New Gerrit change created: https://git.eclipse.org/r/76617