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

Bug 501508

Summary: GraphicalEditPart makes too strong assumption about semantic element's implementation class names
Product: [Modeling] GMF-Runtime Reporter: Guillaume Coutable <guillaume.coutable>
Component: GeneralAssignee: Project Inbox <gmf-runtime-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: pierre-charles.david, steve.monnier
Version: unspecifiedKeywords: triaged
Target Milestone: 1.12.0   
Hardware: PC   
OS: Windows 7   
See Also: https://git.eclipse.org/r/121137
https://git.eclipse.org/c/gmf-runtime/org.eclipse.gmf-runtime.git/commit/?id=26f3f7d57bd7e5bab18af5b239c0a93d2fc61922
Whiteboard:
Attachments:
Description Flags
Potential patch in GMF Runtime none

Description Guillaume Coutable CLA 2016-09-15 11:12:02 EDT
Hello,

Every time I perform an action like clicking on diagram elements, the error log become full of this stacktrace :

java.lang.StringIndexOutOfBoundsException: String index out of range: -61
	at java.lang.String.substring(Unknown Source)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart$4.getSemanticName(GraphicalEditPart.java:1157)
	at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart$4.getName(GraphicalEditPart.java:1174)
	at org.eclipse.gef.ui.parts.DomainEventDispatcher$EditPartAccessibilityDispatcher.getName(DomainEventDispatcher.java:174)
	at org.eclipse.draw2d.LightweightSystem$EventHandler.getName(LightweightSystem.java:450)
	at org.eclipse.swt.accessibility.Accessible.get_accName(Accessible.java:2518)
	at org.eclipse.swt.accessibility.Accessible$1.method10(Accessible.java:157)
	at org.eclipse.swt.internal.ole.win32.COMObject.callback10(COMObject.java:155)
	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 org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
	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)

After a deep search I find out this stacktrace is due to this piece of code located in GraphicalEditPart#getAccessibleEditPart() :
      if( semanticElement != null ) {
         String name = semanticElement.getClass().getName();
         int startIndex = name.lastIndexOf('.') + 1;
         int endIndex = name.lastIndexOf( "Impl" ); //$NON-NLS-1$
         return name.substring(startIndex, endIndex);
      }

In this context, the GraphicalEditPart is a org.eclipse.sirius.diagram.ui.internal.edit.parts.DDiagramEditPart which is one of the
sirius editpart that did not override getAccessibleEditPart() and execute the piece of code above.
Comment 1 Guillaume Coutable CLA 2016-09-15 11:41:33 EDT
This also happens in ConnectionEditPart which is in my context a org.eclipse.sirius.diagram.ui.internal.edit.parts.DEdgeEditPart
Comment 2 Pierre-Charles David CLA 2016-09-15 11:56:29 EDT
Created attachment 264177 [details]
Potential patch in GMF Runtime

The bug is in GMF Runtime. I can't find current information on how to propose a fix (there does not seem to be a gerrit setup for it). In the meantime I've attached a possible patch. I'll try to propose it in a GMF bugzilla later.
Comment 3 Eclipse Genie CLA 2018-04-13 07:59:56 EDT
New Gerrit change created: https://git.eclipse.org/r/121137
Comment 5 Pierre-Charles David CLA 2018-04-13 09:29:31 EDT
Fixed by 26f3f7d57bd7e5bab18af5b239c0a93d2fc61922.