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

Bug 380140

Summary: [GEF] thread safety issue
Product: [RT] RAP Reporter: Arnaud MERGEY <a_mergey>
Component: IncubatorAssignee: Arnaud MERGEY <a_mergey>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: austin.riddle
Version: 1.5   
Target Milestone: 2.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
A patch proposal
none
Fixed patch
none
Git patch none

Description Arnaud MERGEY CLA 2012-05-21 09:32:23 EDT
It happens very rarely, but it occurs sometimes so I decided to fill this bug.

It seems there can be some issues by using GEF in multi-user environment 
The following exception occured:

java.lang.ArrayIndexOutOfBoundsException: 1
at java.util.ArrayList.add(ArrayList.java:352)
at
org.eclipse.draw2d.ConnectionAnchorBase.addAnchorListener(ConnectionAnchorBase.java:33)
at
org.eclipse.draw2d.PolylineConnection.hookTargetAnchor(PolylineConnection.java:166)
at
org.eclipse.draw2d.PolylineConnection.setTargetAnchor(PolylineConnection.java:313)
at
org.eclipse.gef.editparts.AbstractConnectionEditPart.refreshTargetAnchor(AbstractConnectionEditPart.java:242)
at
org.eclipse.gef.editparts.AbstractConnectionEditPart.refresh(AbstractConnectionEditPart.java:225)
at
org.eclipse.gef.editparts.AbstractEditPart.addNotify(AbstractEditPart.java:253)
at
org.eclipse.gef.editparts.AbstractGraphicalEditPart.addNotify(AbstractGraphicalEditPart.java:223)
at
org.eclipse.gef.editparts.AbstractConnectionEditPart.addNotify(AbstractConnectionEditPart.java:100)
at
org.eclipse.gef.editparts.AbstractConnectionEditPart.setParent(AbstractConnectionEditPart.java:268)
at
org.eclipse.gef.editparts.AbstractConnectionEditPart.setSource(AbstractConnectionEditPart.java:282)
at
org.eclipse.gef.editparts.AbstractGraphicalEditPart.addSourceConnection(AbstractGraphicalEditPart.java:260)
at
org.eclipse.gef.editparts.AbstractGraphicalEditPart.refreshSourceConnections(AbstractGraphicalEditPart.java:697)
at
org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh(AbstractGraphicalEditPart.java:645)
at
org.eclipse.gef.editparts.AbstractEditPart.addNotify(AbstractEditPart.java:253)
at
org.eclipse.gef.editparts.AbstractGraphicalEditPart.addNotify(AbstractGraphicalEditPart.java:223)
at
org.eclipse.gef.editparts.AbstractEditPart.addChild(AbstractEditPart.java:212)

It is not really possible to write a reproducible snippet as it requires multiple user at the same time. But reading the source code I understand there are some static instance that should become session singleton. I attach a patch allowing to fix this particular issue I was facing.
Comment 1 Arnaud MERGEY CLA 2012-05-21 09:33:24 EDT
Created attachment 215959 [details]
A patch proposal
Comment 2 Arnaud MERGEY CLA 2012-05-21 10:56:28 EDT
Created attachment 215970 [details]
Fixed patch

Sorry, I am not used to Egit yet, so previous patch was incomplete
Comment 3 Austin Riddle CLA 2012-05-21 11:49:02 EDT
(In reply to comment #0)

Hi Arnaud, this is a nasty practice on the part of GEF. These static final anchors should not be created anyway because they can end up having lots of listeners registered on them. What I would prefer, instead of having a session singleton, is to make the default anchors instance members instead of session singleton members.
Comment 4 Arnaud MERGEY CLA 2012-05-22 04:52:06 EDT
Yes it makes sense for me, so in this case I should probably also create a bug on GEF side also. If they fix that, it will be easier later for RAP port
Comment 5 Arnaud MERGEY CLA 2013-03-13 14:27:57 EDT
Created attachment 228375 [details]
Git patch

I submit this patch because as i already have a pull request opened in github, I cannot create a new one
Comment 6 Arnaud MERGEY CLA 2013-03-17 18:00:42 EDT
A commit with this patch has been added to an open pull request against rap gef port project in github
Comment 7 Arnaud MERGEY CLA 2013-12-05 14:05:22 EST
Fixed in master with commit f1d78ae07735b82647dc149c380fe66706e22bbf