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

Bug 333856

Summary: DefautProvider#buildEdges may throw a NPE
Product: [Modeling] GMF-Runtime Reporter: Esteban DUGUEPEROUX <esteban.dugueperoux>
Component: GeneralAssignee: Aurelien Pupier <apupier>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: apupier
Version: unspecified   
Target Milestone: 1.5.0   
Hardware: PC   
OS: Linux   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=282380
Whiteboard:
Attachments:
Description Flags
fix which prevents a possible NPE. mariot.chauvin: iplog+

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