Bug 431359 - NPE when only the core sub-set of Sirius is installed
Summary: NPE when only the core sub-set of Sirius is installed
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 1.0.0M6   Edit
Hardware: All All
: P3 critical (vote)
Target Milestone: 1.0.0M7   Edit
Assignee: Pierre-Charles David CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on: 427017
Blocks: 426687
  Show dependency tree
 
Reported: 2014-03-27 09:56 EDT by Pierre-Charles David CLA
Modified: 2014-05-12 03:46 EDT (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 Pierre-Charles David CLA 2014-03-27 09:56:04 EDT
When only the core parts of Sirius are installed because they are the only plug-ins required and the full feature is not explicitly installed, the following NPE can occur:

java.lang.NullPointerException at  org.eclipse.sirius.business.api.query.FileQuery.isSessionResourceFile(FileQuery.java:73)
	at  org.eclipse.sirius.ui.tools.internal.views.common.FileHandledBySessionTester.test(FileHandledBySessionTester.java:46)

This is because the aird extension is only declared to EMF in the diagram plug-ins, see http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/tree/plugins/org.eclipse.sirius.diagram/plugin.xml?id=c0961643b1874d65d2b1f304b3e42aa02af85424#n1715 (for the code in M6; it has moved into org.eclipse.sirius.diagram.ui since).

We should quickly push a workaround to avoid the NPE, but the real fix is related to bug 430676: the AirdResourc and AirdResourceFactory should be moved back into the core plug-ins, not in the diagram (or worse, diagram.ui) layers.

Currently, the end result is that the when a sub-set of Sirius is installed, it should at least contain the diagram plug-ins.
Comment 1 Pierre-Charles David CLA 2014-03-27 10:04:02 EDT
Also note two things:
* this NPE happened to a user who was not even using Sirius, in a workspace with no modeling project or aird file(s). The Sirius code was called by CNF while expanding projects/folders in the Project Explorer.
* there are probably other bad consequences to this situration, the NPE mentioned here is just the specific symptom which allowed us to become aware of the issue.
Comment 2 Pierre-Charles David CLA 2014-03-27 10:14:40 EDT
See https://git.eclipse.org/r/23997 for an emergency workaround until we tackle the real issue.
Comment 3 Pierre-Charles David CLA 2014-03-27 12:24:50 EDT
Emergency fix commited as 1f820607fd33180865a7a8065cbd446480acec8c.
Comment 4 Maxime Porhel CLA 2014-04-03 04:55:43 EDT
AirdResource and AirdResourceFactory should be in org.eclipse.sirius instead of org.eclipse.sirius.diagram.

These classes have been generated in the first version of the tool, dependencies and inheritance to GMF have to be removed for these classes.
Comment 5 Maxime Porhel CLA 2014-04-03 06:14:19 EDT
AirdResourceFactory: 
 . the inheritance to GMFResourceFactory has to be replaced by XMIResourceFactoryImpl
 . default load/save options inialization needs to be reported from GMFResourceFactory to AirdResourceFactory

AirdResourceImpl: 
 . Occurence of GMFResource(Factory) found in the source repo: AirdResourceFactory, AirdResourceImpl, CustomSiriusDocumentProvider, ResourcEMissingDocumentProvider.
 . GMFResource inheritance brings the support of the GMF pathmap extension point (See org.eclipse.gmf.runtime.emf.core.internal.resources.PathmapManager, extension point org.eclipse.gmf.runtime.emf.core.Pathmaps), I did not find any use of this, but it seems to be supported. 
 . GMFResource could be copied and adapted
   . to keep its management of useIdAttributes, getSavedID, basicSetResourceSet()
   . setUri, setRawURI have to be removed (See remark about Pathmaps)
   . createXMIHelper is overriden in AirdResourceImpl
   . createXMISave is the same than in XMIResourceImpk
   . createXMLLoad: see GMFLoad
 . GMFLoad 
   . changes the behavior of the default XMILoader so that UnresolvedReferenceExceptions are not thrown back.
   . handle the ABORT_ON_EXCEPTION load option
   . use a GMFHandler
 . GMFHandler
   . support of the option ABORT_ON_EXCEPTION
   . add specific behavior around proxies in endDocument() and validateCreateObjectFromFactory()

It seems that if we accept to loose the support of Pathmaps and to duplicate and adapt GMFLoad and GMFHandler, we can globally keep the same behavior and move AirdResourceImpl and AirdResourceFactory from org.eclipse.sirius.diagram(.ui) to org.eclipse.sirius
Comment 6 Maxime Porhel CLA 2014-04-03 08:11:10 EDT
It seems thaht if Sirius users used to define some pathmap, they could simply use org.eclipse.emf.ecore.uri_mapping instead. 

The sample from the pathmap extension point description illustrates the definition of a path map to locate libraries in the org.eclipse.uml2. 
   <extension
         id="UML2Libraries"
         name="UML2 Libraries"
         point="org.eclipse.gmf.runtime.emf.core.Pathmaps">
      <pathmap
            name="UML2_LIBRARIES"
            plugin="org.eclipse.uml2.resources"
            path="libraries">
      </pathmap>
   </extension>
Using this path map, URIs such as "pathmap://UML2_LIBRARIES/Ecore.library.uml2" can be used to reference UML2 library resources

A corresponding uri_mapping could be used: 
<extension
       point="org.eclipse.emf.ecore.uri_mapping">
    <mapping
          source="pathmap://UML2_LIBRARIES/Ecore.library.uml2"
 target="platform:/plugin/org.eclipse.uml2.resources/libraries/Ecore.library.uml2">
    </mapping>
 </extension>
Note that the scheme might have to be changed to avoid conflicts or misunderstanding in the PathmapManager.

The pathmap extension point does not allows to define a single mapping for a folder whereas with uri_mapping, all resource will require an explicit mapping declaration.

In Sirius, environment:/viewpoint is already defined with the uri_mapping extension point and referenced from each created VSM, it is defined in org.eclipse.sirius:
 <extension
       point="org.eclipse.emf.ecore.uri_mapping">
    <mapping
          source="environment:/viewpoint"
          target="platform:/plugin/org.eclipse.sirius/model/Environment.xmi">
    </mapping>
 </extension>
Comment 7 Maxime Porhel CLA 2014-04-03 12:01:13 EDT
Two first steps to remove inheritance to GMF classes:
 . https://git.eclipse.org/r/24403
 . https://git.eclipse.org/r/24404
Comment 8 Pierre-Charles David CLA 2014-04-30 09:06:23 EDT
It is too late for M7 to try to remove all the GMF dependencies on the *.aird resources' implementation given the risk for regressions of such changes. Instead, see https://git.eclipse.org/r/#/c/25799/ for an intermediate step which moves the classes into org.eclipse.sirius anyway, at the cost of adding a dependency towards parts of GMF Runtime for that core plug-in.
Comment 9 Pierre-Charles David CLA 2014-05-03 04:33:12 EDT
Commit 0d17e6b85defca2cd3a0410f0720c9585e4e0566 moves the definition of the aird resources into the core plug-in. However I have not re-tested the original scenario so the issue remains open for now.
Comment 10 Pierre-Charles David CLA 2014-05-06 09:47:10 EDT
Seems to work fine from my tests. Sirius features become available gradually as they are installed, and do not seem to cause trouble otherwise.
Comment 11 Pierre-Charles David CLA 2014-05-06 09:47:28 EDT
Verified on 1.0.0M7rc3 (1.0.0.201405061021).
Comment 12 Pierre-Charles David CLA 2014-05-12 03:46:08 EDT
Available in Sirius 1.0.0M7 (see https://wiki.eclipse.org/Sirius/1.0.0M7 & http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/tag/?id=v1.0.0M7).