Program: 130010
Project: 130010
Buggy source:
public static MetadataColumnsAndDbmsId<org.talend.core.model.metadata.builder.connection.MetadataColumn> loadMetadataColumnsAndDbmsIdFromFile(final File file) throws ParserConfigurationException, SAXException, IOException {
  final List<org.talend.core.model.metadata.builder.connection.MetadataColumn> listColumns=new ArrayList<org.talend.core.model.metadata.builder.connection.MetadataColumn>();
  String dbmsId=null;
  if (file != null) {
    final DocumentBuilderFactory fabrique=DocumentBuilderFactory.newInstance();
    final Bundle b=Platform.getBundle(CORE_RUNTIME_PLUGIN_ID);
    final URL url=FileLocator.toFileURL(FileLocator.find(b,new Path(SCHEMA_XSD),null));
    final File schema=new File(url.getPath());
    fabrique.setAttribute(SCHEMA_LANGUAGE,"String_Node_Str");
    fabrique.setAttribute(SCHEMA_VALIDATOR,schema);
    fabrique.setValidating(true);
    final DocumentBuilder analyseur=fabrique.newDocumentBuilder();
    analyseur.setErrorHandler(new ErrorHandler(){
      public void error(      final SAXParseException exception) throws SAXException {
        throw exception;
      }
      public void fatalError(      final SAXParseException exception) throws SAXException {
        throw exception;
      }
      public void warning(      final SAXParseException exception) throws SAXException {
        throw exception;
      }
    }
);
    final Document document=analyseur.parse(file);
    dbmsId=document.getDocumentElement().getAttribute("String_Node_Str");
    final NodeList nodes=document.getElementsByTagName("String_Node_Str");
    Set<String> columnsAlreadyAdded=new HashSet<String>();
    for (int i=0; i < nodes.getLength(); i++) {
      final org.talend.core.model.metadata.builder.connection.MetadataColumn metadataColumn=ConnectionFactory.eINSTANCE.createMetadataColumn();
      final Node nodetoParse=nodes.item(i);
      final NamedNodeMap nodeMap=nodetoParse.getAttributes();
      final Node label=nodeMap.getNamedItem("String_Node_Str");
      final Node key=nodeMap.getNamedItem("String_Node_Str");
      final Node type=nodeMap.getNamedItem("String_Node_Str");
      final Node sourceType=nodeMap.getNamedItem("String_Node_Str");
      final Node length=nodeMap.getNamedItem("String_Node_Str");
      final Node precision=nodeMap.getNamedItem("String_Node_Str");
      final Node nullable=nodeMap.getNamedItem("String_Node_Str");
      final Node defaultValue=nodeMap.getNamedItem("String_Node_Str");
      final Node comment=nodeMap.getNamedItem("String_Node_Str");
      final Node pattern=nodeMap.getNamedItem("String_Node_Str");
      final Node originalField=nodeMap.getNamedItem("String_Node_Str");
      String nodeValue=MetadataToolHelper.validateColumnName(label.getNodeValue(),0);
      metadataColumn.setLabel(nodeValue);
      UniqueStringGenerator<org.talend.core.model.metadata.builder.connection.MetadataColumn> uniqueLabelGenerator=new UniqueStringGenerator<org.talend.core.model.metadata.builder.connection.MetadataColumn>(metadataColumn.getLabel(),listColumns){
        @Override protected String getBeanString(        org.talend.core.model.metadata.builder.connection.MetadataColumn bean){
          return bean.getLabel();
        }
      }
;
      metadataColumn.setLabel(uniqueLabelGenerator.getUniqueString());
      metadataColumn.setKey(Boolean.parseBoolean(key.getNodeValue()));
      metadataColumn.setTalendType(getNewTalendType(type.getNodeValue()));
      if (sourceType != null) {
        metadataColumn.setSourceType(sourceType.getNodeValue());
      }
      if (length.getNodeValue() != null) {
        try {
          metadataColumn.setLength(Integer.parseInt(length.getNodeValue()));
        }
 catch (        final NumberFormatException e) {
          metadataColumn.setLength(0);
        }
      }
 else {
        metadataColumn.setLength(0);
      }
      if (precision.getNodeValue() != null) {
        try {
          metadataColumn.setPrecision(Integer.parseInt(precision.getNodeValue()));
        }
 catch (        final NumberFormatException e) {
          metadataColumn.setPrecision(0);
        }
      }
 else {
        metadataColumn.setPrecision(0);
      }
      metadataColumn.setNullable(Boolean.parseBoolean(nullable.getNodeValue()));
      metadataColumn.setDefaultValue(defaultValue.getNodeValue());
      metadataColumn.setComment(comment.getNodeValue());
      if (pattern.getNodeValue() != null) {
        metadataColumn.setPattern(pattern.getNodeValue());
      }
      if (originalField != null && originalField.getNodeValue() != null) {
        metadataColumn.setName(originalField.getNodeValue());
        UniqueStringGenerator<org.talend.core.model.metadata.builder.connection.MetadataColumn> uniqueStringGenerator=new UniqueStringGenerator<org.talend.core.model.metadata.builder.connection.MetadataColumn>(metadataColumn.getName(),listColumns){
          @Override protected String getBeanString(          org.talend.core.model.metadata.builder.connection.MetadataColumn bean){
            return bean.getName();
          }
        }
;
        metadataColumn.setName(uniqueStringGenerator.getUniqueString());
      }
 else {
        metadataColumn.setName(label.getNodeValue());
      }
      if (!columnsAlreadyAdded.contains(metadataColumn.getLabel())) {
        listColumns.add(metadataColumn);
        columnsAlreadyAdded.add(metadataColumn.getLabel());
      }
    }
  }
  return new MetadataColumnsAndDbmsId<org.talend.core.model.metadata.builder.connection.MetadataColumn>(listColumns,dbmsId);
}

Fixed version (ground truth):
public static MetadataColumnsAndDbmsId<org.talend.core.model.metadata.builder.connection.MetadataColumn> loadMetadataColumnsAndDbmsIdFromFile(final File file) throws ParserConfigurationException, SAXException, IOException {
  final List<org.talend.core.model.metadata.builder.connection.MetadataColumn> listColumns=new ArrayList<org.talend.core.model.metadata.builder.connection.MetadataColumn>();
  String dbmsId=null;
  if (file != null) {
    final DocumentBuilderFactory fabrique=DocumentBuilderFactory.newInstance();
    final Bundle b=Platform.getBundle(CORE_RUNTIME_PLUGIN_ID);
    final URL url=FileLocator.toFileURL(FileLocator.find(b,new Path(SCHEMA_XSD),null));
    final File schema=new File(url.getPath());
    fabrique.setAttribute(SCHEMA_LANGUAGE,"String_Node_Str");
    fabrique.setAttribute(SCHEMA_VALIDATOR,schema);
    fabrique.setValidating(true);
    final DocumentBuilder analyseur=fabrique.newDocumentBuilder();
    analyseur.setErrorHandler(new ErrorHandler(){
      public void error(      final SAXParseException exception) throws SAXException {
        throw exception;
      }
      public void fatalError(      final SAXParseException exception) throws SAXException {
        throw exception;
      }
      public void warning(      final SAXParseException exception) throws SAXException {
        throw exception;
      }
    }
);
    final Document document=analyseur.parse(file);
    dbmsId=document.getDocumentElement().getAttribute("String_Node_Str");
    final NodeList nodes=document.getElementsByTagName("String_Node_Str");
    Set<String> columnsAlreadyAdded=new HashSet<String>();
    for (int i=0; i < nodes.getLength(); i++) {
      final org.talend.core.model.metadata.builder.connection.MetadataColumn metadataColumn=ConnectionFactory.eINSTANCE.createMetadataColumn();
      final Node nodetoParse=nodes.item(i);
      final NamedNodeMap nodeMap=nodetoParse.getAttributes();
      final Node label=nodeMap.getNamedItem("String_Node_Str");
      final Node key=nodeMap.getNamedItem("String_Node_Str");
      final Node type=nodeMap.getNamedItem("String_Node_Str");
      final Node sourceType=nodeMap.getNamedItem("String_Node_Str");
      final Node length=nodeMap.getNamedItem("String_Node_Str");
      final Node precision=nodeMap.getNamedItem("String_Node_Str");
      final Node nullable=nodeMap.getNamedItem("String_Node_Str");
      final Node defaultValue=nodeMap.getNamedItem("String_Node_Str");
      final Node comment=nodeMap.getNamedItem("String_Node_Str");
      final Node pattern=nodeMap.getNamedItem("String_Node_Str");
      final Node originalField=nodeMap.getNamedItem("String_Node_Str");
      String nodeValue=MetadataToolHelper.validateColumnName(label.getNodeValue(),0);
      metadataColumn.setLabel(nodeValue);
      UniqueStringGenerator<org.talend.core.model.metadata.builder.connection.MetadataColumn> uniqueLabelGenerator=new UniqueStringGenerator<org.talend.core.model.metadata.builder.connection.MetadataColumn>(metadataColumn.getLabel(),listColumns){
        @Override protected String getBeanString(        org.talend.core.model.metadata.builder.connection.MetadataColumn bean){
          return bean.getLabel();
        }
      }
;
      metadataColumn.setLabel(uniqueLabelGenerator.getUniqueString());
      metadataColumn.setKey(Boolean.parseBoolean(key.getNodeValue()));
      metadataColumn.setTalendType(getNewTalendType(type.getNodeValue()));
      if (sourceType != null) {
        metadataColumn.setSourceType(sourceType.getNodeValue());
      }
      if (length.getNodeValue() != null) {
        try {
          metadataColumn.setLength(Integer.parseInt(length.getNodeValue()));
        }
 catch (        final NumberFormatException e) {
          metadataColumn.setLength(0);
        }
      }
 else {
        metadataColumn.setLength(0);
      }
      if (precision.getNodeValue() != null) {
        try {
          metadataColumn.setPrecision(Integer.parseInt(precision.getNodeValue()));
        }
 catch (        final NumberFormatException e) {
          metadataColumn.setPrecision(0);
        }
      }
 else {
        metadataColumn.setPrecision(0);
      }
      metadataColumn.setNullable(Boolean.parseBoolean(nullable.getNodeValue()));
      metadataColumn.setDefaultValue(defaultValue.getNodeValue());
      metadataColumn.setComment(comment.getNodeValue());
      if (pattern.getNodeValue() != null) {
        metadataColumn.setPattern(pattern.getNodeValue());
      }
      if (!columnsAlreadyAdded.contains(metadataColumn.getLabel())) {
        listColumns.add(metadataColumn);
        columnsAlreadyAdded.add(metadataColumn.getLabel());
      }
    }
  }
  return new MetadataColumnsAndDbmsId<org.talend.core.model.metadata.builder.connection.MetadataColumn>(listColumns,dbmsId);
}