Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 333856 - DefautProvider#buildEdges may throw a NPE
Summary: DefautProvider#buildEdges may throw a NPE
Status: RESOLVED FIXED
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal
Target Milestone: 1.5.0   Edit
Assignee: Aurelien Pupier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-10 06:54 EST by Esteban DUGUEPEROUX CLA
Modified: 2011-02-28 08:57 EST (History)
1 user (show)

See Also:


Attachments
fix which prevents a possible NPE. (1.39 KB, patch)
2011-01-10 06:59 EST, Esteban DUGUEPEROUX CLA
mariot.chauvin: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Esteban DUGUEPEROUX CLA 2011-01-10 06:54:12 EST
Build Identifier: I20101208-1300

DefautProvider#buildEdges contains currently the following code :

 EditPart from = poly.getSource();
 EditPart to = poly.getTarget();
 if (from instanceof IBorderItemEditPart && !editPartToNodeDict.containsKey(from))
     from = from.getParent();
 else if (shouldHandleListItems && from instanceof ListItemEditPart)
     from = getFirstAnscestorinNodesMap(from, editPartToNodeDict);
 if (to instanceof IBorderItemEditPart && !editPartToNodeDict.containsKey(to))
     to = to.getParent();
 else if (shouldHandleListItems && to instanceof ListItemEditPart)
     to = getFirstAnscestorinNodesMap(to, editPartToNodeDict);
 Node fromNode = (Node) editPartToNodeDict.get(from);
 Node toNode = (Node) editPartToNodeDict.get(to);


If fromNode or toNode is null, HashTable#get will throw a NullPointerException
We get a case where it occured.

Reproducible: Always
Comment 1 Esteban DUGUEPEROUX CLA 2011-01-10 06:59:56 EST
Created attachment 186379 [details]
fix which prevents a possible NPE.
Comment 2 Aurelien Pupier CLA 2011-02-16 18:25:25 EST
Hi,

Can you be more precise in which case it can occured?

From my understanding of the code, it is that your ConnectionEditpart have no source or no target. Can you confirm that in order to be sure that it doesn't hide another issue?
This use case seems plausible for me.

I applied your patch and do the same modifications some lines above.

Thanks for the report and the patch
Comment 3 Aurelien Pupier CLA 2011-02-16 18:29:39 EST
fix applied for 1.5.0