eclipse-sirius / sirius-web

Sirius Web: open-source low-code platform to define custom web applications supporting your specific visual languages
https://eclipse.dev/sirius/sirius-web.html
Eclipse Public License 2.0
82 stars 53 forks source link

View Edge Reconnect Tool allows to reconnect to incompatible source/target #2587

Open AxelRICHARD opened 1 year ago

AxelRICHARD commented 1 year ago

Steps to reproduce

Create a ReconnectSourceTool or ReconnectTargetTool on a View. Try to apply this on an incompatible Node.

Caused by: java.lang.ClassCastException: class org.eclipse.syson.sysml.impl.PortUsageImpl cannot be cast to class org.eclipse.syson.sysml.Classifier (org.eclipse.syson.sysml.impl.PortUsageImpl and org.eclipse.syson.sysml.Classifier are in unnamed module of loader org.springframework.boot.devtools.restart.classloader.RestartClassLoader @570badb8)
    at org.eclipse.syson.sysml.impl.SubclassificationImpl.eSet(SubclassificationImpl.java:208) ~[classes/:na]
    at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1110) ~[org.eclipse.emf.ecore-2.23.0.jar:na]
    at org.eclipse.sirius.ecore.extender.business.internal.accessor.ecore.EcoreIntrinsicExtender.eSet(EcoreIntrinsicExtender.java:322) ~[org.eclipse.sirius.ecore.extender-7.2.0-SNAPSHOT.jar:na]
    at org.eclipse.sirius.ecore.extender.business.internal.accessor.ecore.EcoreIntrinsicExtender.eAdd(EcoreIntrinsicExtender.java:104) ~[org.eclipse.sirius.ecore.extender-7.2.0-SNAPSHOT.jar:na]
    at org.eclipse.sirius.components.view.emf.OperationInterpreterViewSwitch.caseSetValue(OperationInterpreterViewSwitch.java:117) ~[sirius-components-view-emf-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.view.emf.OperationInterpreterViewSwitch.caseSetValue(OperationInterpreterViewSwitch.java:47) ~[sirius-components-view-emf-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.view.util.ViewSwitch.doSwitch(ViewSwitch.java:155) ~[sirius-components-view-2023.10.7.jar:2023.10.7]
    at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53) ~[org.eclipse.emf.ecore-2.23.0.jar:na]
    at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69) ~[org.eclipse.emf.ecore-2.23.0.jar:na]
    at org.eclipse.sirius.components.view.emf.diagram.DiagramOperationInterpreterViewSwitch.defaultCase(DiagramOperationInterpreterViewSwitch.java:137) ~[sirius-components-view-emf-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.view.emf.diagram.DiagramOperationInterpreterViewSwitch.defaultCase(DiagramOperationInterpreterViewSwitch.java:56) ~[sirius-components-view-emf-2023.10.7.jar:2023.10.7]
    at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:58) ~[org.eclipse.emf.ecore-2.23.0.jar:na]
    at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:58) ~[org.eclipse.emf.ecore-2.23.0.jar:na]
    at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69) ~[org.eclipse.emf.ecore-2.23.0.jar:na]
    at org.eclipse.sirius.components.view.emf.diagram.DiagramOperationInterpreter.executeOperation(DiagramOperationInterpreter.java:97) ~[sirius-components-view-emf-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.view.emf.diagram.DiagramOperationInterpreter.executeOperations(DiagramOperationInterpreter.java:83) ~[sirius-components-view-emf-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.view.emf.OperationInterpreterViewSwitch.caseChangeContext(OperationInterpreterViewSwitch.java:86) ~[sirius-components-view-emf-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.view.emf.OperationInterpreterViewSwitch.caseChangeContext(OperationInterpreterViewSwitch.java:47) ~[sirius-components-view-emf-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.view.util.ViewSwitch.doSwitch(ViewSwitch.java:137) ~[sirius-components-view-2023.10.7.jar:2023.10.7]
    at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:53) ~[org.eclipse.emf.ecore-2.23.0.jar:na]
    at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69) ~[org.eclipse.emf.ecore-2.23.0.jar:na]
    at org.eclipse.sirius.components.view.emf.diagram.DiagramOperationInterpreterViewSwitch.defaultCase(DiagramOperationInterpreterViewSwitch.java:137) ~[sirius-components-view-emf-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.view.emf.diagram.DiagramOperationInterpreterViewSwitch.defaultCase(DiagramOperationInterpreterViewSwitch.java:56) ~[sirius-components-view-emf-2023.10.7.jar:2023.10.7]
    at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:58) ~[org.eclipse.emf.ecore-2.23.0.jar:na]
    at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:58) ~[org.eclipse.emf.ecore-2.23.0.jar:na]
    at org.eclipse.emf.ecore.util.Switch.doSwitch(Switch.java:69) ~[org.eclipse.emf.ecore-2.23.0.jar:na]
    at org.eclipse.sirius.components.view.emf.diagram.DiagramOperationInterpreter.executeOperation(DiagramOperationInterpreter.java:97) ~[sirius-components-view-emf-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.view.emf.diagram.DiagramOperationInterpreter.executeOperations(DiagramOperationInterpreter.java:83) ~[sirius-components-view-emf-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.view.emf.diagram.ViewReconnectionToolsExecutor.execute(ViewReconnectionToolsExecutor.java:111) ~[sirius-components-view-emf-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.collaborative.diagrams.handlers.ReconnectEdgeEventHandler.invokeReconnectEdgeTool(ReconnectEdgeEventHandler.java:209) ~[sirius-components-collaborative-diagrams-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.collaborative.diagrams.handlers.ReconnectEdgeEventHandler.handleReconnect(ReconnectEdgeEventHandler.java:122) ~[sirius-components-collaborative-diagrams-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.collaborative.diagrams.handlers.ReconnectEdgeEventHandler.handle(ReconnectEdgeEventHandler.java:105) ~[sirius-components-collaborative-diagrams-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.collaborative.diagrams.DiagramEventProcessor.handle(DiagramEventProcessor.java:121) ~[sirius-components-collaborative-diagrams-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.collaborative.editingcontext.EditingContextEventProcessor.handleRepresentationInput(EditingContextEventProcessor.java:320) ~[sirius-components-collaborative-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.collaborative.editingcontext.EditingContextEventProcessor.doHandle(EditingContextEventProcessor.java:245) ~[sirius-components-collaborative-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.collaborative.editingcontext.EditingContextEventProcessor.lambda$handle$2(EditingContextEventProcessor.java:214) ~[sirius-components-collaborative-2023.10.7.jar:2023.10.7]
    at org.eclipse.sirius.components.web.concurrent.DelegatingRequestContextRunnable.run(DelegatingRequestContextRunnable.java:40) ~[sirius-components-web-2023.10.7.jar:2023.10.7]
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[na:na]
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]

Expected behavior

The reconnection of an Edge on an incompatible source/target mapping is forbidden.

Actual behavior

The reconnection of an Edge on an incompatible source/target mapping is allowed. The backend raises an exception.

The fix should probably be done in ReconnectEdgeEventHandler or ViewReconnectionToolsExecutor.

flatombe commented 2 days ago

The Precondition Expression of Reconnect tools are also not invoked. Sort-of-a-workaround is to add an If in the behavior of the tool.