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

Bug 361294

Summary: NPE in XYLayoutEditPolicy#getConstraintFor
Product: [Modeling] GMF-Runtime Reporter: Svyatoslav Kovalsky <kovalsky>
Component: GeneralAssignee: Aurelien Pupier <apupier>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: an.mayer, apupier, markusb
Version: unspecifiedFlags: apupier: juno+
Target Milestone: 1.6.0   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
trivial - fixes NPE none

Description Svyatoslav Kovalsky CLA 2011-10-18 14:42:20 EDT
From news group message here:
http://www.eclipse.org/forums/index.php/r/reply_to/738986/
[21:33:04] Michael Golubev: 

java.lang.NullPointerException
 at org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy.getConstraintFor(XYLayoutEditPolicy.java:229)
 at org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy.getAddCommand(ConstrainedLayoutEditPolicy.java:184)
 at org.eclipse.gef.editpolicies.LayoutEditPolicy.getCommand(LayoutEditPolicy.java:216)
 at org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy.getCommand(ConstrainedLayoutEditPolicy.java:214)
 at org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy.getCommand(XYLayoutEditPolicy.java:325)
 at org.eclipse.gef.editparts.AbstractEditPart.getCommand(AbstractEditPart.java:500)
 at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$1(GraphicalEditPart.java:1)
 at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart$1.run(GraphicalEditPart.java:482)
 at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
 at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.getCommand(GraphicalEditPart.java:477)
 at org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy.getDropCommand(DragDropEditPolicy.java:112)
 at org.eclipse.gmf.runtime.diagram.ui.editpolicies.DiagramDragDropEditPolicy.getDropCommand(DiagramDragDropEditPolicy.java:151)
 at org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy.getCommand(DragDropEditPolicy.java:75)
 at org.eclipse.gef.editparts.AbstractEditPart.getCommand(AbstractEditPart.java:502)
 at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$1(GraphicalEditPart.java:1)
 at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart$1.run(GraphicalEditPart.java:482)
 at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
 at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.getCommand(GraphicalEditPart.java:477)
 at org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.getCommand(DragEditPartsTrackerEx.java:63)
 at org.eclipse.gef.tools.DragEditPartsTracker.handleDragInProgress(DragEditPartsTracker.java:370)
 at org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.handleDragInProgress(DragEditPartsTrackerEx.java:177)
 at org.eclipse.gef.tools.AbstractTool.mouseDrag(AbstractTool.java:1114)
 at org.eclipse.gef.tools.SelectionTool.mouseDrag(SelectionTool.java:538)
 at org.eclipse.gef.EditDomain.mouseDrag(EditDomain.java:259)
 at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouseMoved(DomainEventDispatcher.java:363)
Comment 1 Svyatoslav Kovalsky CLA 2011-10-18 14:50:47 EDT
Rectangle rect = (Rectangle) super.getConstraintFor(request, child);
Rectangle cons = getCurrentConstraintFor(child);
if (request.getSizeDelta().width == 0)
   rect.width = cons.width;

its reasonable to expect that rect != null 
However there are reasonable usecases when getCurrentConstraintFor(child) == null, causing NPE here
Comment 2 Svyatoslav Kovalsky CLA 2011-10-18 14:55:21 EDT
Created attachment 205453 [details]
trivial - fixes NPE
Comment 3 Markus Brakweh CLA 2012-03-13 06:26:10 EDT
Is there an ETA when this fix will be available? Which GMF/Eclipse version can we expect this fix to be in?

Thanks
Markus
Comment 4 Aurelien Pupier CLA 2012-03-13 09:47:12 EDT
Hi,

I just commited the fix.

If the tests are running well also on server it will be part of Eclipse Juno.

regards,
Comment 5 Aurelien Pupier CLA 2012-03-13 10:05:54 EDT
tests passed
Comment 6 Markus Brakweh CLA 2012-03-13 10:50:23 EDT
Thanks, Aurelien