Bug 520438 - NullPointerException in EdgeLabelQuery when moving node
Summary: NullPointerException in EdgeLabelQuery when moving node
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 4.1.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2017-08-02 03:40 EDT by Martin Jedlicka CLA
Modified: 2018-01-03 04:09 EST (History)
2 users (show)

See Also:


Attachments
Project created to try to reproduce the problem (3.41 KB, application/x-zip-compressed)
2017-08-02 11:51 EDT, Laurent Redor CLA
no flags Details
Images to reproduce the problem (229.51 KB, application/x-zip-compressed)
2017-09-13 03:17 EDT, Martin Jedlicka CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Jedlicka CLA 2017-08-02 03:40:15 EDT
If I move the node using the arrows (or the mouse) and the node is too close to the next node (and there is an edge between the nodes), an exception (see below) is displayed and the node can not be moved anymore.

Perhaps related to the Bug 504738 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=504738).

!ENTRY org.eclipse.gmf.runtime.diagram.ui 4 4 2017-08-01 12:57:11.803
!MESSAGE execute
!STACK 0
org.eclipse.core.commands.ExecutionException: While executing the operation, an exception occurred
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:524)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramCommandStack.execute(DDiagramCommandStack.java:71)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramCommandStack.execute(DDiagramCommandStack.java:52)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack.execute(DiagramCommandStack.java:156)
	at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTool.java:425)
	at org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(AbstractTool.java:438)
	at org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.executeCurrentCommand(DragEditPartsTrackerEx.java:151)
	at org.eclipse.gef.tools.DragEditPartsTracker.performDrag(DragEditPartsTracker.java:496)
	at org.eclipse.gef.tools.DragEditPartsTracker.commitDrag(DragEditPartsTracker.java:135)
	at org.eclipse.gmf.runtime.diagram.ui.services.palette.SelectionToolEx.handleKeyUp(SelectionToolEx.java:122)
	at org.eclipse.gef.tools.AbstractTool.keyUp(AbstractTool.java:1051)
	at org.eclipse.gef.tools.SelectionTool.keyUp(SelectionTool.java:502)
	at org.eclipse.gef.EditDomain.keyUp(EditDomain.java:198)
	at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchKeyReleased(DomainEventDispatcher.java:278)
	at org.eclipse.draw2d.LightweightSystem$EventHandler.keyReleased(LightweightSystem.java:502)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:174)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1137)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1122)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1164)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1160)
	at org.eclipse.swt.widgets.Widget.wmKeyUp(Widget.java:1983)
	at org.eclipse.swt.widgets.Control.WM_KEYUP(Control.java:5053)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4709)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:339)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5050)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2549)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3767)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:694)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at com.ness.eufo.starter.intro.Application.start(Application.java:251)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
Caused by: java.lang.NullPointerException
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.locator.EdgeLabelQuery.getStandardLabelCenterLocation(EdgeLabelQuery.java:750)
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.locator.EdgeLabelQuery.calculateGMFLabelOffset(EdgeLabelQuery.java:243)
	at org.eclipse.sirius.diagram.ui.internal.edit.commands.SetLabelsOffsetOperation.computeGMFLabelOffset(SetLabelsOffsetOperation.java:150)
	at org.eclipse.sirius.diagram.ui.internal.edit.commands.SetLabelsOffsetOperation.computeGMFLabelsOffset(SetLabelsOffsetOperation.java:124)
	at org.eclipse.sirius.diagram.ui.internal.edit.commands.SetLabelsOffsetOperation.setLabelsToUpdate(SetLabelsOffsetOperation.java:109)
	at org.eclipse.sirius.diagram.ui.graphical.edit.policies.SetConnectionBendpointsAndLabelCommmand.setLabelsToUpdate(SetConnectionBendpointsAndLabelCommmand.java:66)
	at org.eclipse.sirius.diagram.ui.graphical.edit.policies.SetConnectionBendpointsAccordingToExtremityMoveCommmand.setLabelsToUpdate(SetConnectionBendpointsAccordingToExtremityMoveCommmand.java:73)
	at org.eclipse.sirius.diagram.ui.internal.edit.commands.ChangeBendpointsOfEdgesCommand.getBendpointsChangedCommand(ChangeBendpointsOfEdgesCommand.java:298)
	at org.eclipse.sirius.diagram.ui.internal.edit.commands.ChangeBendpointsOfEdgesCommand.completeCommandWithBendpointsChangedCommand(ChangeBendpointsOfEdgesCommand.java:188)
	at org.eclipse.sirius.diagram.ui.internal.edit.commands.ChangeBendpointsOfEdgesCommand.doExecuteWithResult(ChangeBendpointsOfEdgesCommand.java:142)
	at org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand.doExecute(AbstractTransactionalCommand.java:247)
	at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
	at org.eclipse.emf.workspace.CompositeEMFOperation.doExecute(CompositeEMFOperation.java:217)
	at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
	at org.eclipse.sirius.diagram.ui.tools.internal.commands.WrappingCommandIgnoringAffectedFiles.execute(WrappingCommandIgnoringAffectedFiles.java:124)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:516)
Comment 1 Laurent Redor CLA 2017-08-02 11:51:26 EDT
Created attachment 269658 [details]
Project created to try to reproduce the problem

I not reproduce the problem. Could you join a project with steps to reproduce? I've attached my project used to try to reproduce.
Comment 2 Martin Jedlicka CLA 2017-09-13 03:17:48 EDT
Created attachment 270172 [details]
Images to reproduce the problem

Step to reproduce the problem:
1. I have diagram, see "1.step - diagram_init.png"
2. I will move the first node (dark green) to the right using the arrow key, see "2.step - diagram_node_move.png"
3. At the same time, thow the exception, see "3.step - throw exception.png"
4. When I put breakpoint to the getStandardLabelCenterLocation method in the EdgeLabelQuery class, the newAnchorPoint variable is null, and therefore the NullPointerException exception occurs on line 750.
Comment 3 Pierre Guilet CLA 2017-09-18 12:08:08 EDT
I reproduced with Sirius 4.1.1 with Laurent's example with another exception in addition.

with the example, when moving C1 directly towards C2 key press after key press (right key) and not by pressing continuously the key, then I have the following exception:

org.eclipse.core.commands.ExecutionException: While executing the operation, an exception occurred
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:496)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramCommandStack.execute(DDiagramCommandStack.java:71)
	at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramCommandStack.execute(DDiagramCommandStack.java:52)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack.execute(DiagramCommandStack.java:156)
	at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTool.java:425)
	at org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(AbstractTool.java:438)
	at org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.executeCurrentCommand(DragEditPartsTrackerEx.java:151)
	at org.eclipse.gef.tools.DragEditPartsTracker.performDrag(DragEditPartsTracker.java:538)
	at org.eclipse.gef.tools.DragEditPartsTracker.commitDrag(DragEditPartsTracker.java:177)
	at org.eclipse.gmf.runtime.diagram.ui.services.palette.SelectionToolEx.handleKeyUp(SelectionToolEx.java:122)
	at org.eclipse.gef.tools.AbstractTool.keyUp(AbstractTool.java:1051)
	at org.eclipse.gef.tools.SelectionTool.keyUp(SelectionTool.java:502)
	at org.eclipse.gef.EditDomain.keyUp(EditDomain.java:198)
	at org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchKeyReleased(DomainEventDispatcher.java:278)
	at org.eclipse.draw2d.LightweightSystem$EventHandler.keyReleased(LightweightSystem.java:502)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:175)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4418)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1103)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1088)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1130)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1126)
	at org.eclipse.swt.widgets.Widget.wmKeyUp(Widget.java:1949)
	at org.eclipse.swt.widgets.Control.WM_KEYUP(Control.java:5176)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4832)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:359)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5110)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2552)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3822)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:693)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
Caused by: java.lang.ArithmeticException: / by zero
	at java.math.BigDecimal.divideAndRound(Unknown Source)
	at java.math.BigDecimal.divide(Unknown Source)
	at java.math.BigDecimal.divide(Unknown Source)
	at org.eclipse.draw2d.geometry.PrecisionGeometry.preciseDivide(PrecisionGeometry.java:48)
	at org.eclipse.draw2d.geometry.Vector.getAngle(Vector.java:168)
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.locator.EdgeLabelQuery.getVectorForSegmentMoveCase(EdgeLabelQuery.java:414)
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.locator.EdgeLabelQuery.calculateNewCenterLocation(EdgeLabelQuery.java:350)
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.locator.EdgeLabelQuery.calculateGMFLabelOffset(EdgeLabelQuery.java:243)
	at org.eclipse.sirius.diagram.ui.internal.edit.commands.SetLabelsOffsetOperation.computeGMFLabelOffset(SetLabelsOffsetOperation.java:150)
	at org.eclipse.sirius.diagram.ui.internal.edit.commands.SetLabelsOffsetOperation.computeGMFLabelsOffset(SetLabelsOffsetOperation.java:124)
	at org.eclipse.sirius.diagram.ui.internal.edit.commands.SetLabelsOffsetOperation.setLabelsToUpdate(SetLabelsOffsetOperation.java:109)
	at org.eclipse.sirius.diagram.ui.graphical.edit.policies.SetConnectionBendpointsAndLabelCommmand.setLabelsToUpdate(SetConnectionBendpointsAndLabelCommmand.java:66)
	at org.eclipse.sirius.diagram.ui.graphical.edit.policies.SetConnectionBendpointsAccordingToExtremityMoveCommmand.setLabelsToUpdate(SetConnectionBendpointsAccordingToExtremityMoveCommmand.java:73)
	at org.eclipse.sirius.diagram.ui.internal.edit.commands.ChangeBendpointsOfEdgesCommand.getBendpointsChangedCommand(ChangeBendpointsOfEdgesCommand.java:298)
	at org.eclipse.sirius.diagram.ui.internal.edit.commands.ChangeBendpointsOfEdgesCommand.completeCommandWithBendpointsChangedCommand(ChangeBendpointsOfEdgesCommand.java:188)
	at org.eclipse.sirius.diagram.ui.internal.edit.commands.ChangeBendpointsOfEdgesCommand.doExecuteWithResult(ChangeBendpointsOfEdgesCommand.java:142)
	at org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand.doExecute(AbstractTransactionalCommand.java:247)
	at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
	at org.eclipse.emf.workspace.CompositeEMFOperation.doExecute(CompositeEMFOperation.java:217)
	at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:150)
	at org.eclipse.sirius.diagram.ui.tools.internal.commands.WrappingCommandIgnoringAffectedFiles.execute(WrappingCommandIgnoringAffectedFiles.java:124)
	at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:488)
	... 52 more

When I activate the grid before doing the key press, then I have Martin exception.

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=485010# and https://bugs.eclipse.org/bugs/show_bug.cgi?id=518437# for similar problems
Comment 4 Martin Jedlicka CLA 2018-01-03 04:09:33 EST
The error is that in the EdgeLabelQuery.getStandardLabelCenterLocation method, the newAnchorPoint variable (obtained from EdgeLabelQuery.getAnchorPoint) may be null and null is not treated in the newAnchorPoint.getTranslated (snapBackPosition). 

Is it possible to fix this?