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

Bug 510851

Summary: ArithmeticException when moving edge
Product: [Modeling] Sirius Reporter: Jessy Mallet <jessy.mallet>
Component: DiagramAssignee: Pierre-Charles David <pierre-charles.david>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: maxime.porhel, pierre-charles.david
Version: 4.1.1Keywords: triaged
Target Milestone: 5.0.0M7   
Hardware: PC   
OS: Windows NT   
See Also: https://git.eclipse.org/r/95364
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=da27e5da7495599e9766f487666a96369ee79684
Whiteboard: backport
Bug Depends on: 485010, 518437    
Bug Blocks: 515553, 518439    
Attachments:
Description Flags
test project
none
Steps to reproduce none

Description Jessy Mallet CLA 2017-01-23 05:39:36 EST
Created attachment 266403 [details]
test project

When user try to reconnect target edge and put the cursor on empty area (around 5sec) on diagram with click left always pressed, an exception  "Unhandled event loop exception" appears in errorLog (nothing in console).

You will get the following stack
>org.eclipse.swt.SWTException: Failed to execute >runnable(java.lang.ArithmeticException)
>	....
>Caused by: java.lang.ArithmeticException

Error amso noticed during homologation of 4.1.3


Steps to reproduce: 
> Import the attached project 
> Open the session and the (single) diagram in it. It should show two packages p1 and p2, two classes C1 and C2 and an edge from C1 to C2.
> Try to reconnect the edge from target end on package P1 and then always with click left pressed, put the cursor on empty area between P1 and P2. 

Another Scenario :
> Import the attached project 
> Open the session and the (single) diagram in it. It should show two packages p1 and p2, two classes C1 and C2 and an edge from C1 to C2.
> Try to reconnect the edge from target end on class C1 always with click pressed during 5sec on C1
Comment 1 Jessy Mallet CLA 2017-01-23 05:40:10 EST
Created attachment 266404 [details]
Steps to reproduce
Comment 2 Jessy Mallet CLA 2017-01-23 05:47:45 EST
This bug seems to be the linked to bogue 485010:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=485010
Comment 3 Maxime Porhel CLA 2017-04-20 04:59:37 EDT
Hi Jessy, 

Thank your for the detail bug report, I was able to reproduce the issue. 
Nevertheless, it's not yet in the scope of a future release.

Regards, 

Maxime
Comment 4 Maxime Porhel CLA 2017-04-20 05:05:48 EDT
Here is the stack: 

Caused by: java.lang.ArithmeticException: / by zero
	at java.math.BigDecimal.divideAndRound(BigDecimal.java:4106)
	at java.math.BigDecimal.divide(BigDecimal.java:5183)
	at java.math.BigDecimal.divide(BigDecimal.java:1561)
	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.parts.locator.EdgeLabelLocator.computeOffSet(EdgeLabelLocator.java:125)
	at org.eclipse.sirius.diagram.ui.internal.edit.parts.locator.EdgeLabelLocator.relocate(EdgeLabelLocator.java:111)
	at org.eclipse.gmf.runtime.draw2d.ui.internal.figures.DelegatingLayout.layout(DelegatingLayout.java:43)
	at org.eclipse.draw2d.Figure.layout(Figure.java:1096)
	at org.eclipse.draw2d.PolylineConnection.layout(PolylineConnection.java:179)
	at org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramEdgeEditPart$ViewEdgeFigure.layout(AbstractDiagramEdgeEditPart.java:619)
Comment 5 Eclipse Genie CLA 2017-04-20 07:33:15 EDT
New Gerrit change created: https://git.eclipse.org/r/95364
Comment 7 Pierre-Charles David CLA 2017-05-02 05:51:01 EDT
Fixed by da27e5da7495599e9766f487666a96369ee79684.

It does not seem possible/worthwile to develop an automated test for this, so it will be tested manually.
Comment 8 Jessy Mallet CLA 2017-05-15 12:29:57 EDT
Validated with Sirius 5.0.0.201705121003
Comment 9 Pierre-Charles David CLA 2017-05-17 03:24:30 EDT
Verified by Jessy.
Comment 10 Pierre-Charles David CLA 2017-06-29 03:32:22 EDT
Available in Sirius 5.0.0, see https://wiki.eclipse.org/Sirius/5.0.0 for details.