Bug 289826 - NPE in EMFTCSInjector.inject method if no "problems" model in the parameter map.
Summary: NPE in EMFTCSInjector.inject method if no "problems" model in the parameter map.
Status: CLOSED FIXED
Alias: None
Product: MMT.ATL
Classification: Modeling
Component: Engine (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: mmt-atl.toolkit-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2009-09-18 05:16 EDT by Guillaume Doux CLA
Modified: 2017-06-05 09:31 EDT (History)
1 user (show)

See Also:
william.piers: iplog+


Attachments
Path which solves the problem (844 bytes, patch)
2009-10-09 09:40 EDT, Guillaume Doux CLA
william.piers: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Guillaume Doux CLA 2009-09-18 05:16:18 EDT
Hello,

There is a bug in the org.eclipse.m2m.atl.dsls plug-in, in The EMFTCSInjector class:

A null pointer exception is thrown if there is no "problems" model in the parameter map.

public Object inject(EMFModel target, InputStream source, Map params) throws IOException {
     ModelAdapter targetModelAdapter = new EMFInjectorAdapter(target);

     EMFModel problems = (EMFModel)params.get("problems");
     if (problems != null) { // Here the "problems" model is adapted if it exists
	ModelAdapter problemsModelAdapter = new EMFInjectorAdapter(problems);
	params.put("problems", problemsModelAdapter);
     }

     EObject root = (EObject)new ParserLauncher().parse(targetModelAdapter, source, params);
     target.commitToResource();
     problems.commitToResource(); // Here the "problems" model is saved even
                                     if it does not exist -> NPE.
     return root;
}

Best regards,

Guillaume Doux.
Comment 1 Guillaume Doux CLA 2009-10-09 09:40:38 EDT
Created attachment 149234 [details]
Path which solves the problem 

Hello,

This is the patch which solves the bug.

B.R.

Guillaume Doux.
Comment 2 William Piers CLA 2009-10-13 10:02:37 EDT
The patch has been commited on both HEAD and 3_0 maintenance branches.
Thanks for reporting / solving the bug !
Comment 3 Dennis Wagelaar CLA 2017-06-05 09:31:05 EDT
Bug inactive - closing.