Program: 122002
Project: 122002
Buggy source:
@Override public void run(){
  TreeNode model=(TreeNode)nodePart.getModel();
  TreeNode docRoot=XmlMapUtil.getTreeNodeRoot(model);
  AbstractInOutTree abstractTree=(AbstractInOutTree)docRoot.eContainer();
  boolean isLookup=abstractTree != mapperManager.getMainInputTree() && !(abstractTree instanceof OutputXmlTree);
  if (model instanceof OutputTreeNode) {
    OutputTreeNode outputNode=(OutputTreeNode)model;
    if (docRoot != null) {
      XmlMapUtil.cleanSubGroup(outputNode);
      List<TreeNode> newLoopUpGroups=new ArrayList<TreeNode>();
      findUpGroupNode(newLoopUpGroups,outputNode);
      XmlMapUtil.cleanSubGroup(docRoot,newLoopUpGroups);
      if (!newLoopUpGroups.isEmpty()) {
        TreeNode rootGroup=newLoopUpGroups.get(newLoopUpGroups.size() - 1);
        upsetGroup(outputNode,rootGroup);
      }
    }
  }
  if (!isLookup) {
    boolean hasDocument=false;
    if (abstractTree != null) {
      hasDocument=XmlMapUtil.hasDocument(abstractTree);
    }
    List<TreeNode> loopNodes=new ArrayList<TreeNode>();
    checkSubElementIsLoop(model,loopNodes);
    checkParentElementIsLoop(model,loopNodes);
    if (!loopNodes.isEmpty()) {
      if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"))) {
      }
 else {
        return;
      }
    }
    for (    TreeNode treeNode : loopNodes) {
      treeNode.setLoop(false);
    }
    model.setLoop(true);
    XmlMapUtil.clearMainNode(model);
    XmlMapUtil.upsetMainNode(model);
    if (hasDocument) {
      List<TreeNode> loopNodeList=new ArrayList<TreeNode>();
      getLoopNode(docRoot,loopNodeList);
      if (loopNodeList != null && loopNodeList.size() > 1) {
        abstractTree.setMultiLoops(true);
      }
 else {
        abstractTree.setMultiLoops(false);
      }
    }
    if (input) {
      XmlMapUtil.removeloopInOutputTree(mapperManager,loopNodes);
    }
 else {
      for (      TreeNode treeNode : loopNodes) {
        InputLoopNodesTable inputLoopNodesTable=((OutputTreeNode)treeNode).getInputLoopNodesTable();
        if (inputLoopNodesTable != null && abstractTree != null) {
          ((OutputXmlTree)abstractTree).getInputLoopNodesTables().remove(inputLoopNodesTable);
          inputLoopNodesTable.getInputloopnodes().clear();
        }
        ((OutputTreeNode)treeNode).setInputLoopNodesTable(null);
      }
    }
  }
 else {
    if (docRoot != null) {
      cleanSubLoop(docRoot);
    }
    model.setLoop(true);
    XmlMapUtil.clearMainNode(docRoot);
    XmlMapUtil.upsetMainNode(model);
  }
  if (abstractTree != null) {
    mapperManager.getProblemsAnalyser().checkProblems(abstractTree);
    mapperManager.getMapperUI().updateStatusBar();
  }
}

Fixed version (ground truth):
@Override public void run(){
  TreeNode model=(TreeNode)nodePart.getModel();
  TreeNode docRoot=XmlMapUtil.getTreeNodeRoot(model);
  AbstractInOutTree abstractTree=(AbstractInOutTree)docRoot.eContainer();
  boolean isLookup=abstractTree != mapperManager.getMainInputTree() && !(abstractTree instanceof OutputXmlTree);
  if (model instanceof OutputTreeNode) {
    OutputTreeNode outputNode=(OutputTreeNode)model;
    if (docRoot != null) {
      XmlMapUtil.cleanSubGroup(outputNode);
      List<TreeNode> newLoopUpGroups=new ArrayList<TreeNode>();
      findUpGroupNode(newLoopUpGroups,outputNode);
      XmlMapUtil.cleanSubGroup(docRoot,newLoopUpGroups);
      if (!newLoopUpGroups.isEmpty()) {
        TreeNode rootGroup=newLoopUpGroups.get(newLoopUpGroups.size() - 1);
        upsetGroup(outputNode,rootGroup);
      }
    }
  }
  if (!isLookup) {
    List<TreeNode> loopNodes=new ArrayList<TreeNode>();
    checkSubElementIsLoop(model,loopNodes);
    checkParentElementIsLoop(model,loopNodes);
    if (!loopNodes.isEmpty()) {
      if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"))) {
      }
 else {
        return;
      }
    }
    for (    TreeNode treeNode : loopNodes) {
      treeNode.setLoop(false);
    }
    model.setLoop(true);
    XmlMapUtil.clearMainNode(model);
    XmlMapUtil.upsetMainNode(model);
    abstractTree.setMultiLoops(XmlMapUtil.checkMultiLoopsStatus(abstractTree));
    if (input) {
      XmlMapUtil.removeloopInOutputTree(mapperManager,loopNodes);
    }
 else {
      for (      TreeNode treeNode : loopNodes) {
        InputLoopNodesTable inputLoopNodesTable=((OutputTreeNode)treeNode).getInputLoopNodesTable();
        if (inputLoopNodesTable != null && abstractTree != null) {
          ((OutputXmlTree)abstractTree).getInputLoopNodesTables().remove(inputLoopNodesTable);
          inputLoopNodesTable.getInputloopnodes().clear();
        }
        ((OutputTreeNode)treeNode).setInputLoopNodesTable(null);
      }
    }
  }
 else {
    if (docRoot != null) {
      cleanSubLoop(docRoot);
    }
    model.setLoop(true);
    XmlMapUtil.clearMainNode(docRoot);
    XmlMapUtil.upsetMainNode(model);
  }
  if (abstractTree != null) {
    mapperManager.getProblemsAnalyser().checkProblems(abstractTree);
    mapperManager.getMapperUI().updateStatusBar();
  }
}