Program: 118379
Project: 118379
Buggy source:
private boolean createComponentOnLink(Node node,Point originalPoint){
  boolean executed=false;
  RootEditPart rep=editor.getViewer().getRootEditPart().getRoot();
  Point viewOriginalPosition=new Point();
  if (rep instanceof ScalableFreeformRootEditPart) {
    ScalableFreeformRootEditPart root=(ScalableFreeformRootEditPart)rep;
    Viewport viewport=(Viewport)root.getFigure();
    viewOriginalPosition=viewport.getViewLocation();
  }
  Point point=new Point(originalPoint.x + viewOriginalPosition.x,originalPoint.y + viewOriginalPosition.y);
  org.talend.designer.core.ui.editor.connections.Connection targetConnection=null;
  if (selectedConnectionPart != null) {
    targetConnection=(org.talend.designer.core.ui.editor.connections.Connection)selectedConnectionPart.getModel();
  }
  if (targetConnection != null) {
    NodeContainer nodeContainer=null;
    if (node.isMapReduce()) {
      nodeContainer=new JobletContainer(node);
    }
 else {
      nodeContainer=new NodeContainer(node);
    }
    IProcess2 p=editor.getProcess();
    if (p instanceof Process) {
      CreateNodeContainerCommand createCmd=new CreateNodeContainerCommand((Process)p,nodeContainer,point);
      execCommandStack(createCmd);
      Node originalTarget=(Node)targetConnection.getTarget();
      EConnectionType connectionType=EConnectionType.FLOW_MAIN;
      if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
        ICamelDesignerCoreService camelService=(ICamelDesignerCoreService)GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
        if (camelService.isRouteBuilderNode(node)) {
          connectionType=camelService.getTargetConnectionType(node);
        }
      }
      INodeConnector targetConnector=node.getConnectorFromType(connectionType);
      for (      INodeConnector connector : node.getConnectorsFromType(connectionType)) {
        if (connector.getMaxLinkOutput() != 0) {
          targetConnector=connector;
          break;
        }
      }
      ConnectionCreateCommand.setCreatingConnection(true);
      if (PluginChecker.isJobLetPluginLoaded()) {
        IJobletProviderService service=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
        if (service != null && service.isJobletComponent(targetConnection.getTarget())) {
          if (targetConnection.getTarget() instanceof Node) {
            NodeContainer jobletContainer=((Node)targetConnection.getTarget()).getNodeContainer();
            jobletContainer.getInputs().remove(targetConnection);
          }
        }
      }
      ConnectionReconnectCommand cmd2=new ConnectionReconnectCommand(targetConnection);
      cmd2.setNewTarget(node);
      execCommandStack(cmd2);
      List<Object> nodeArgs=CreateComponentOnLinkHelper.getTargetArgs(targetConnection,node);
      ConnectionCreateCommand nodeCmd=new ConnectionCreateCommand(node,targetConnector.getName(),nodeArgs,false);
      nodeCmd.setTarget(originalTarget);
      execCommandStack(nodeCmd);
      if (node.getOutgoingConnections().size() > 0) {
        if (node.getExternalNode() instanceof MapperExternalNode) {
          CreateComponentOnLinkHelper.setupTMap(node);
        }
        if (originalTarget.getExternalNode() instanceof MapperExternalNode) {
          CreateComponentOnLinkHelper.updateTMap(originalTarget,targetConnection,node.getOutgoingConnections().get(0));
        }
        originalTarget.renameData(targetConnection.getName(),node.getOutgoingConnections().get(0).getName());
      }
      if (!ConnectionCreateCommand.isCreatingConnection()) {
        return true;
      }
      executed=true;
    }
  }
  return executed;
}

Fixed version (ground truth):
private boolean createComponentOnLink(Node node,Point originalPoint){
  boolean executed=false;
  RootEditPart rep=editor.getViewer().getRootEditPart().getRoot();
  Point viewOriginalPosition=new Point();
  if (rep instanceof ScalableFreeformRootEditPart) {
    ScalableFreeformRootEditPart root=(ScalableFreeformRootEditPart)rep;
    Viewport viewport=(Viewport)root.getFigure();
    viewOriginalPosition=viewport.getViewLocation();
  }
  Point point=new Point(originalPoint.x + viewOriginalPosition.x,originalPoint.y + viewOriginalPosition.y);
  point.x=(int)(point.x / AnimatableZoomManager.currentZoom);
  point.y=(int)(point.y / AnimatableZoomManager.currentZoom);
  org.talend.designer.core.ui.editor.connections.Connection targetConnection=null;
  if (selectedConnectionPart != null) {
    targetConnection=(org.talend.designer.core.ui.editor.connections.Connection)selectedConnectionPart.getModel();
  }
  if (targetConnection != null) {
    NodeContainer nodeContainer=null;
    if (node.isMapReduce()) {
      nodeContainer=new JobletContainer(node);
    }
 else {
      nodeContainer=new NodeContainer(node);
    }
    IProcess2 p=editor.getProcess();
    if (p instanceof Process) {
      CreateNodeContainerCommand createCmd=new CreateNodeContainerCommand((Process)p,nodeContainer,point);
      execCommandStack(createCmd);
      Node originalTarget=(Node)targetConnection.getTarget();
      EConnectionType connectionType=EConnectionType.FLOW_MAIN;
      if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
        ICamelDesignerCoreService camelService=(ICamelDesignerCoreService)GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
        if (camelService.isRouteBuilderNode(node)) {
          connectionType=camelService.getTargetConnectionType(node);
        }
      }
      INodeConnector targetConnector=node.getConnectorFromType(connectionType);
      for (      INodeConnector connector : node.getConnectorsFromType(connectionType)) {
        if (connector.getMaxLinkOutput() != 0) {
          targetConnector=connector;
          break;
        }
      }
      ConnectionCreateCommand.setCreatingConnection(true);
      if (PluginChecker.isJobLetPluginLoaded()) {
        IJobletProviderService service=(IJobletProviderService)GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
        if (service != null && service.isJobletComponent(targetConnection.getTarget())) {
          if (targetConnection.getTarget() instanceof Node) {
            NodeContainer jobletContainer=((Node)targetConnection.getTarget()).getNodeContainer();
            jobletContainer.getInputs().remove(targetConnection);
          }
        }
      }
      ConnectionReconnectCommand cmd2=new ConnectionReconnectCommand(targetConnection);
      cmd2.setNewTarget(node);
      execCommandStack(cmd2);
      List<Object> nodeArgs=CreateComponentOnLinkHelper.getTargetArgs(targetConnection,node);
      ConnectionCreateCommand nodeCmd=new ConnectionCreateCommand(node,targetConnector.getName(),nodeArgs,false);
      nodeCmd.setTarget(originalTarget);
      execCommandStack(nodeCmd);
      if (node.getOutgoingConnections().size() > 0) {
        if (node.getExternalNode() instanceof MapperExternalNode) {
          CreateComponentOnLinkHelper.setupTMap(node);
        }
        if (originalTarget.getExternalNode() instanceof MapperExternalNode) {
          CreateComponentOnLinkHelper.updateTMap(originalTarget,targetConnection,node.getOutgoingConnections().get(0));
        }
        originalTarget.renameData(targetConnection.getName(),node.getOutgoingConnections().get(0).getName());
      }
      if (!ConnectionCreateCommand.isCreatingConnection()) {
        return true;
      }
      executed=true;
    }
  }
  return executed;
}