Program: 130014
Project: 130014
Buggy source:
/** 
 * DOC amaumont Comment method "addLinks".
 * @param relativeXpath
 * @param tableItemTarget
 * @param progressMonitor
 * @throws XPathExpressionException
 */
private void createFieldLinks(final String relativeXpathPrm,final TableItem tableItemTarget,IProgressMonitor progressMonitor,SchemaTarget schemaTarget){
  if (relativeXpathPrm == null || relativeXpathPrm.trim().length() == 0) {
    return;
  }
  boolean expressionIsAbsolute=false;
  if (relativeXpathPrm.trim().startsWith("String_Node_Str")) {
    expressionIsAbsolute=true;
  }
  String relativeXpath=relativeXpathPrm;
  Set<String> alreadyProcessedXPath=new HashSet<String>();
  if (!isXSDFile) {
    List<Node> nodeList=null;
    if (expressionIsAbsolute) {
      String expression=null;
      if (relativeXpath == null) {
        relativeXpath="String_Node_Str";
      }
      expression=relativeXpath;
      try {
        nodeList=this.nodeRetriever.retrieveNodeList(expression);
      }
 catch (      XPathExpressionException e) {
        ExceptionHandler.process(e);
      }
    }
 else {
      if (allLoopNodes.size() > 0) {
        Node loopNode=allLoopNodes.get(0);
        try {
          if (relativeXpath == null) {
            relativeXpath="String_Node_Str";
          }
          final String resault=relativeXpath;
          nodeList=this.nodeRetriever.retrieveNodeListFromNode(relativeXpath,loopNode);
          if (nodeList == null) {
            Display.getDefault().asyncExec(new Runnable(){
              public void run(){
                MessageDialog.openError(null,"String_Node_Str","String_Node_Str" + resault + "String_Node_Str");
              }
            }
);
            progressMonitor.setCanceled(true);
            XmlExtractorFieldModel schemaModel=this.fieldsTableEditorView.getModel();
            schemaModel.remove(schemaTarget);
            fieldsTableEditorView.getTable().redraw();
          }
 else           if (nodeList.size() == 0) {
            String currentLoopXPath=getCurrentLoopXPath();
            String expression=currentLoopXPath + "String_Node_Str" + relativeXpath;
            nodeList=this.nodeRetriever.retrieveNodeList(expression);
          }
        }
 catch (        XPathExpressionException e) {
          e.printStackTrace();
        }
      }
    }
    if (nodeList != null) {
      int length=nodeList.size();
      for (int i=0; i < length; i++) {
        if (progressMonitor != null && progressMonitor.isCanceled()) {
          break;
        }
        Node loopNode=nodeList.get(i);
        if (loopNode != null) {
          String absoluteXPathFromNode=nodeRetriever.getAbsoluteXPathFromNode(loopNode);
          if (!alreadyProcessedXPath.contains(absoluteXPathFromNode)) {
            TreeItem treeItemFromAbsoluteXPath=treePopulator.getTreeItem(absoluteXPathFromNode);
            if (treeItemFromAbsoluteXPath != null) {
              addFieldLink(treeItemFromAbsoluteXPath,treeItemFromAbsoluteXPath.getData(),tableItemTarget.getParent(),(SchemaTarget)tableItemTarget.getData());
              alreadyProcessedXPath.add(absoluteXPathFromNode);
            }
          }
        }
      }
    }
  }
 else {
    String fullPath="String_Node_Str";
    if (!expressionIsAbsolute) {
      if (loopXpathNodes.size() > 0) {
        fullPath=loopXpathNodes.get(0) + "String_Node_Str";
      }
      String[] relatedSplitedPaths=relativeXpath.split("String_Node_Str");
      if (relatedSplitedPaths.length > 1) {
        int pathsToRemove=relatedSplitedPaths.length - 1;
        String[] fullPathSplited=fullPath.split("String_Node_Str");
        fullPath="String_Node_Str";
        for (int i=1; i < (fullPathSplited.length - pathsToRemove); i++) {
          fullPath+="String_Node_Str" + fullPathSplited[i];
        }
        fullPath+="String_Node_Str" + relatedSplitedPaths[pathsToRemove];
      }
 else {
        fullPath+=relativeXpath;
      }
    }
 else {
      fullPath=relativeXpath;
    }
    TreeItem treeItemFromAbsoluteXPath=treePopulator.getTreeItem(fullPath);
    if (treeItemFromAbsoluteXPath != null && !alreadyProcessedXPath.contains(fullPath)) {
      addFieldLink(treeItemFromAbsoluteXPath,treeItemFromAbsoluteXPath.getData(),tableItemTarget.getParent(),(SchemaTarget)tableItemTarget.getData());
      alreadyProcessedXPath.add(fullPath);
    }
  }
}

Fixed version (ground truth):
/** 
 * DOC amaumont Comment method "addLinks".
 * @param relativeXpath
 * @param tableItemTarget
 * @param progressMonitor
 * @throws XPathExpressionException
 */
private void createFieldLinks(final String relativeXpathPrm,final TableItem tableItemTarget,IProgressMonitor progressMonitor,SchemaTarget schemaTarget){
  if (relativeXpathPrm == null || relativeXpathPrm.trim().length() == 0) {
    return;
  }
  boolean expressionIsAbsolute=false;
  if (relativeXpathPrm.trim().startsWith("String_Node_Str")) {
    expressionIsAbsolute=true;
  }
  String relativeXpath=relativeXpathPrm;
  Set<String> alreadyProcessedXPath=new HashSet<String>();
  if (!isXSDFile) {
    List<Node> nodeList=null;
    if (expressionIsAbsolute) {
      String expression=null;
      if (relativeXpath == null) {
        relativeXpath="String_Node_Str";
      }
      expression=relativeXpath;
      try {
        nodeList=this.nodeRetriever.retrieveNodeList(expression);
      }
 catch (      XPathExpressionException e) {
        ExceptionHandler.process(e);
      }
    }
 else {
      if (allLoopNodes.size() > 0) {
        Node loopNode=allLoopNodes.get(0);
        try {
          if (relativeXpath == null) {
            relativeXpath="String_Node_Str";
          }
          final String resault=relativeXpath;
          nodeList=this.nodeRetriever.retrieveNodeListFromNode(relativeXpath,loopNode);
          if (nodeList == null) {
            Display.getDefault().asyncExec(new Runnable(){
              public void run(){
                MessageDialog.openError(null,"String_Node_Str","String_Node_Str" + resault + "String_Node_Str");
              }
            }
);
            progressMonitor.setCanceled(true);
            XmlExtractorFieldModel schemaModel=this.fieldsTableEditorView.getModel();
            schemaModel.remove(schemaTarget);
            fieldsTableEditorView.getTable().redraw();
          }
 else           if (nodeList.size() == 0) {
            String currentLoopXPath=getCurrentLoopXPath();
            String expression=currentLoopXPath + "String_Node_Str" + relativeXpath;
            nodeList=this.nodeRetriever.retrieveNodeList(expression);
          }
        }
 catch (        XPathExpressionException e) {
          e.printStackTrace();
        }
      }
    }
    if (nodeList != null) {
      int length=nodeList.size();
      for (int i=0; i < length; i++) {
        if (progressMonitor != null && progressMonitor.isCanceled()) {
          break;
        }
        Node loopNode=nodeList.get(i);
        if (loopNode != null) {
          String absoluteXPathFromNode=nodeRetriever.getAbsoluteXPathFromNode(loopNode);
          if (!alreadyProcessedXPath.contains(absoluteXPathFromNode)) {
            TreeItem treeItemFromAbsoluteXPath=treePopulator.getTreeItem(absoluteXPathFromNode);
            if (treeItemFromAbsoluteXPath != null) {
              addFieldLink(treeItemFromAbsoluteXPath,treeItemFromAbsoluteXPath.getData(),tableItemTarget.getParent(),(SchemaTarget)tableItemTarget.getData());
              alreadyProcessedXPath.add(absoluteXPathFromNode);
            }
          }
        }
      }
    }
  }
 else {
    String fullPath="String_Node_Str";
    if (!expressionIsAbsolute) {
      if (loopXpathNodes.size() > 0) {
        fullPath=loopXpathNodes.get(0) + "String_Node_Str";
      }
      if (relativeXpath != null && relativeXpath.endsWith("String_Node_Str")) {
        relativeXpath=relativeXpath.substring(0,relativeXpath.lastIndexOf("String_Node_Str"));
      }
      String[] relatedSplitedPaths=relativeXpath.split("String_Node_Str");
      if (relatedSplitedPaths.length > 1) {
        int pathsToRemove=relatedSplitedPaths.length - 1;
        String[] fullPathSplited=fullPath.split("String_Node_Str");
        fullPath="String_Node_Str";
        for (int i=1; i < (fullPathSplited.length - pathsToRemove); i++) {
          fullPath+="String_Node_Str" + fullPathSplited[i];
        }
        fullPath+="String_Node_Str" + relatedSplitedPaths[pathsToRemove];
      }
 else {
        fullPath+=relativeXpath;
      }
    }
 else {
      fullPath=relativeXpath;
    }
    TreeItem treeItemFromAbsoluteXPath=treePopulator.getTreeItem(fullPath);
    if (treeItemFromAbsoluteXPath != null && !alreadyProcessedXPath.contains(fullPath)) {
      addFieldLink(treeItemFromAbsoluteXPath,treeItemFromAbsoluteXPath.getData(),tableItemTarget.getParent(),(SchemaTarget)tableItemTarget.getData());
      alreadyProcessedXPath.add(fullPath);
    }
  }
}