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

Bug 464958

Summary: Illegal State Exception: Workbench has not been created yet when running in headless mode
Product: [Modeling] Sirius Reporter: Alain Picard <picard>
Component: CoreAssignee: Cedric Brun <cedric.brun>
Status: CLOSED FIXED QA Contact: Belqassim Djafer <belqassim.djafer>
Severity: normal    
Priority: P3 CC: cedric.brun, maxime.porhel, pierre-charles.david
Version: unspecifiedKeywords: triaged
Target Milestone: 3.0.0   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/47018
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=ced42b0e68fae6b6eea898136ca8cdafb9d75d13
Whiteboard:
Bug Depends on:    
Bug Blocks: 462490    

Description Alain Picard CLA 2015-04-19 15:36:48 EDT
When running in headless mode, we sometimes get an Illegal State Exception: Workbench has not been created yet.

This happens in the LogThroughActiveDialectEditorLogListener method logging.

The test should be changed to:
if (!hasBeenLoggedThroughDialect && PlatformUI.isWorkbenchRunning() && !PlatformUI.getWorkbench().isStarting()) {

adding the isWorkenchRunning before checking the isStarting.
Comment 1 Pierre-Charles David CLA 2015-04-22 11:47:51 EDT
I've pushed the proposed change as a Gerrit review, at https://git.eclipse.org/r/#/c/46265/. Currently just to see if this causes any regression (I don't see why it would).

Note that the whole logging logic in that class is conditioned by a preference: SiriusUIPreferencesKeys.PREF_REACT_TO_PERMISSION_ISSUES_BY_GRAPHICAL_DISPLAY. It is not a preference accessible in the Eclipse UI, but if you set it explicitly to false in your code, it should fix the issue without waiting for a new release of Sirius.

Maybe Sirius should set the initial value of that preference to false by itself when running in headless mode.
Comment 2 Cedric Brun CLA 2015-05-04 11:53:06 EDT
I stumbled on the same issue when launching the EcoreTools tests.
I proposed a patch without even knowing about the one you provided Pierre Charles, it is slightly different as it will check for the relevance of the exception first.


https://git.eclipse.org/r/#/c/47018/
Comment 5 Cedric Brun CLA 2015-05-07 10:53:50 EDT
It's been merged, built and I checked through the EcoreTool tests :

https://hudson.eclipse.org/sirius/view/ecoretools/job/ecoretools-master/158/
Comment 6 Belqassim Djafer CLA 2015-05-26 04:08:07 EDT
Validated as technical change
Comment 7 Maxime Porhel CLA 2015-05-26 10:50:59 EDT
Validated on Sirius 3.0.0 RC1
(ecore tools builds/tests are also ok)
Comment 8 Pierre-Charles David CLA 2015-06-24 11:16:55 EDT
Available in Sirius 3.0.0. See https://wiki.eclipse.org/Sirius/3.0.0.