Program: 126352
Project: 126352
Buggy source:
private static void fillRootInfo(XmlFileConnection connection,ATreeNode node,String path,boolean inLoop){
  XMLFileNode xmlNode=ConnectionFactory.eINSTANCE.createXMLFileNode();
  xmlNode.setXMLPath(path + '/' + node.getValue());
  xmlNode.setOrder(orderId);
  orderId++;
  MappingTypeRetriever retriever;
  String nameWithoutPrefixForColumn;
  String curName=(String)node.getValue();
  if (curName.contains("String_Node_Str")) {
    nameWithoutPrefixForColumn=curName.split("String_Node_Str")[1];
  }
 else {
    nameWithoutPrefixForColumn=curName;
  }
  retriever=MetadataTalendType.getMappingTypeRetriever("String_Node_Str");
  xmlNode.setAttribute("String_Node_Str");
  xmlNode.setType(retriever.getDefaultSelectedTalendType(node.getDataType()));
  MetadataColumn column=null;
  MetadataTable metadataTable=ConnectionHelper.getTables(connection).toArray(new MetadataTable[0])[0];
switch (node.getType()) {
case ATreeNode.ATTRIBUTE_TYPE:
    xmlNode.setXMLPath("String_Node_Str" + node.getValue());
  column=ConnectionFactory.eINSTANCE.createMetadataColumn();
column.setTalendType(xmlNode.getType());
String uniqueName=extractColumnName(nameWithoutPrefixForColumn,metadataTable.getColumns());
column.setLabel(uniqueName);
xmlNode.setRelatedColumn(uniqueName);
metadataTable.getColumns().add(column);
break;
case ATreeNode.ELEMENT_TYPE:
boolean haveElementOrAttributes=false;
for (Object curNode : node.getChildren()) {
if (((ATreeNode)curNode).getType() != ATreeNode.NAMESPACE_TYPE) {
haveElementOrAttributes=true;
break;
}
}
if (!haveElementOrAttributes) {
xmlNode.setAttribute("String_Node_Str");
column=ConnectionFactory.eINSTANCE.createMetadataColumn();
column.setTalendType(xmlNode.getType());
uniqueName=extractColumnName(nameWithoutPrefixForColumn,metadataTable.getColumns());
column.setLabel(uniqueName);
xmlNode.setRelatedColumn(uniqueName);
metadataTable.getColumns().add(column);
}
 else {
xmlNode.setAttribute("String_Node_Str");
}
break;
case ATreeNode.NAMESPACE_TYPE:
xmlNode.setAttribute("String_Node_Str");
xmlNode.setXMLPath(node.getDataType());
xmlNode.setDefaultValue((String)node.getValue());
break;
case ATreeNode.OTHER_TYPE:
break;
}
boolean subElementsInLoop=inLoop;
if ((!loopElementFound && path.split("String_Node_Str").length == 2 && node.getType() == ATreeNode.ELEMENT_TYPE) || subElementsInLoop) {
connection.getLoop().add(xmlNode);
loopElementFound=true;
subElementsInLoop=true;
}
 else {
connection.getRoot().add(xmlNode);
}
if (node.getChildren().length > 0) {
for (Object curNode : node.getChildren()) {
if (!path.contains((String)node.getValue())) {
fillRootInfo(connection,(ATreeNode)curNode,path + '/' + node.getValue(),subElementsInLoop);
}
}
}
}

Fixed version (ground truth):
private static void fillRootInfo(XmlFileConnection connection,ATreeNode node,String path,boolean inLoop){
  XMLFileNode xmlNode=ConnectionFactory.eINSTANCE.createXMLFileNode();
  xmlNode.setXMLPath(path + '/' + node.getValue());
  xmlNode.setOrder(orderId);
  orderId++;
  MappingTypeRetriever retriever;
  String nameWithoutPrefixForColumn;
  String curName=(String)node.getValue();
  if (curName.contains("String_Node_Str")) {
    nameWithoutPrefixForColumn=curName.split("String_Node_Str")[1];
  }
 else {
    nameWithoutPrefixForColumn=curName;
  }
  retriever=MetadataTalendType.getMappingTypeRetriever("String_Node_Str");
  xmlNode.setAttribute("String_Node_Str");
  xmlNode.setType(retriever.getDefaultSelectedTalendType(node.getDataType()));
  MetadataColumn column=null;
  MetadataTable metadataTable=ConnectionHelper.getTables(connection).toArray(new MetadataTable[0])[0];
switch (node.getType()) {
case ATreeNode.ATTRIBUTE_TYPE:
    xmlNode.setXMLPath("String_Node_Str" + node.getValue());
  column=ConnectionFactory.eINSTANCE.createMetadataColumn();
column.setTalendType(xmlNode.getType());
String uniqueName=extractColumnName(nameWithoutPrefixForColumn,metadataTable.getColumns());
column.setLabel(uniqueName);
xmlNode.setRelatedColumn(uniqueName);
metadataTable.getColumns().add(column);
break;
case ATreeNode.ELEMENT_TYPE:
boolean haveElementOrAttributes=false;
for (Object curNode : node.getChildren()) {
if (((ATreeNode)curNode).getType() != ATreeNode.NAMESPACE_TYPE) {
haveElementOrAttributes=true;
break;
}
}
if (!haveElementOrAttributes) {
xmlNode.setAttribute("String_Node_Str");
column=ConnectionFactory.eINSTANCE.createMetadataColumn();
column.setTalendType(xmlNode.getType());
uniqueName=extractColumnName(nameWithoutPrefixForColumn,metadataTable.getColumns());
column.setLabel(uniqueName);
xmlNode.setRelatedColumn(uniqueName);
metadataTable.getColumns().add(column);
}
 else {
xmlNode.setAttribute("String_Node_Str");
}
break;
case ATreeNode.NAMESPACE_TYPE:
xmlNode.setAttribute("String_Node_Str");
xmlNode.setXMLPath(node.getDataType());
xmlNode.setDefaultValue((String)node.getValue());
break;
case ATreeNode.OTHER_TYPE:
break;
}
boolean subElementsInLoop=inLoop;
if ((!loopElementFound && path.split("String_Node_Str").length == 2 && node.getType() == ATreeNode.ELEMENT_TYPE) || subElementsInLoop) {
connection.getLoop().add(xmlNode);
loopElementFound=true;
subElementsInLoop=true;
}
 else {
connection.getRoot().add(xmlNode);
}
if (node.getChildren().length > 0) {
for (Object curNode : node.getChildren()) {
if (!path.contains("String_Node_Str" + (String)node.getValue() + "String_Node_Str")) {
fillRootInfo(connection,(ATreeNode)curNode,path + '/' + node.getValue(),subElementsInLoop);
}
}
}
}