Program: 141706
Project: 141706
Buggy source:
/** 
 * To optimize, right now it will write the xsd file many times. Since there is no clues if the parameters comes from the same xsd, generate it everytime right now.
 * @param operationName
 * @param hashMap
 * @throws IOException
 */
private void populateMessage2(QName parameter,String portTypeName,String operationName,File schemaFile,Collection<XmlFileConnectionItem> selectItems,File zip) throws IOException {
  String name=parameter.getLocalPart();
  XmlFileConnection connection=null;
  Property connectionProperty=null;
  XmlFileConnectionItem connectionItem=null;
  String oldConnectionId=null;
  String oldTableId=null;
  IMetadataTable oldMetadataTable=null;
  Map<String,String> oldTableMap=null;
  if (selectItems.size() > 0) {
    boolean needRewrite=false;
    for (    XmlFileConnectionItem item : selectItems) {
      connectionProperty=item.getProperty();
      if (connectionProperty.getLabel().equals(name)) {
        oldConnectionId=connectionProperty.getId();
        connectionItem=item;
        connection=(XmlFileConnection)connectionItem.getConnection();
        needRewrite=true;
        Set<MetadataTable> tables=ConnectionHelper.getTables(connection);
        MetadataTable oldTable=null;
        if (tables.size() > 0) {
          oldTable=tables.toArray(new MetadataTable[0])[0];
          oldTableId=oldTable.getId();
          oldMetadataTable=ConvertionHelper.convert(oldTable);
        }
        oldTableMap=RepositoryUpdateManager.getOldTableIdAndNameMap(connectionItem,oldTable,false);
        break;
      }
    }
    if (!needRewrite) {
      return;
    }
  }
  connection=ConnectionFactory.eINSTANCE.createXmlFileConnection();
  connection.setName(ERepositoryObjectType.METADATA_FILE_XML.getKey());
  connectionItem=PropertiesFactory.eINSTANCE.createXmlFileConnectionItem();
  connectionProperty=PropertiesFactory.eINSTANCE.createProperty();
  connectionProperty.setAuthor(((RepositoryContext)CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
  connectionProperty.setLabel(name);
  connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
  connectionProperty.setStatusCode("String_Node_Str");
  connectionItem.setProperty(connectionProperty);
  connectionItem.setConnection(connection);
  connection.setInputModel(false);
  ByteArray byteArray=PropertiesFactory.eINSTANCE.createByteArray();
  byteArray.setInnerContentFromFile(zip);
  connection.setFileContent(byteArray.getInnerContent());
  String schemaFileName=schemaFile.getName();
  schemaFileName=schemaFileName.substring(0,schemaFileName.lastIndexOf("String_Node_Str"));
  connection.setXmlFilePath(schemaFileName.concat("String_Node_Str").concat(zip.getName()));
  try {
    String filePath=schemaFile.getPath();
    XSDSchema xsdSchema=populationUtil.getXSDSchema(filePath);
    List<ATreeNode> rootNodes=populationUtil.getAllRootNodes(xsdSchema);
    ATreeNode node=null;
    for (    ATreeNode curNode : rootNodes) {
      String curName=(String)curNode.getValue();
      if (curName.contains("String_Node_Str")) {
        if (curName.split("String_Node_Str")[1].equals(name)) {
          node=curNode;
          break;
        }
      }
 else       if (curName.equals(name)) {
        node=curNode;
        break;
      }
    }
    node=populationUtil.getSchemaTree(xsdSchema,node);
    orderId=1;
    loopElementFound=false;
    if (ConnectionHelper.getTables(connection).isEmpty()) {
      MetadataTable table=ConnectionFactory.eINSTANCE.createMetadataTable();
      if (oldTableId != null) {
        table.setId(oldTableId);
      }
 else {
        table.setId(ProxyRepositoryFactory.getInstance().getNextId());
      }
      RecordFile record=(RecordFile)ConnectionHelper.getPackage(connection.getName(),connection,RecordFile.class);
      if (record != null) {
        PackageHelper.addMetadataTable(table,record);
      }
 else {
        RecordFile newrecord=RecordFactory.eINSTANCE.createRecordFile();
        newrecord.setName(connection.getName());
        ConnectionHelper.addPackage(newrecord,connection);
        PackageHelper.addMetadataTable(table,newrecord);
      }
    }
    boolean haveElement=false;
    for (    Object curNode : node.getChildren()) {
      if (((ATreeNode)curNode).getType() == ATreeNode.ELEMENT_TYPE) {
        haveElement=true;
        break;
      }
    }
    fillRootInfo(connection,node,"String_Node_Str",!haveElement);
  }
 catch (  IOException e) {
    throw e;
  }
catch (  URISyntaxException e1) {
    ExceptionHandler.process(e1);
  }
catch (  OdaException e) {
    ExceptionHandler.process(e);
  }
  IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  connectionProperty.setId(factory.getNextId());
  try {
    String folderPath=FolderNameUtil.getImportedXmlSchemaPath(parameter.getNamespaceURI(),portTypeName,operationName);
    IPath path=new Path(folderPath);
    factory.create(connectionItem,path,true);
    if (oldConnectionId != null) {
      connectionItem.getProperty().setId(oldConnectionId);
      factory.save(connectionItem);
    }
    propagateSchemaChange(oldMetadataTable,oldTableMap,connection,connectionItem);
    ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
    RepositoryManager.refresh(ERepositoryObjectType.METADATA_FILE_XML);
  }
 catch (  PersistenceException e) {
    ExceptionHandler.process(e);
  }
catch (  URISyntaxException e) {
    ExceptionHandler.process(e);
  }
}

Fixed version (ground truth):
/** 
 * To optimize, right now it will write the xsd file many times. Since there is no clues if the parameters comes from the same xsd, generate it everytime right now.
 * @param operationName
 * @param hashMap
 * @throws IOException
 */
private void populateMessage2(QName parameter,String portTypeName,String operationName,File schemaFile,Collection<XmlFileConnectionItem> selectItems,File zip) throws IOException {
  String name=parameter.getLocalPart();
  XmlFileConnection connection=null;
  Property connectionProperty=null;
  XmlFileConnectionItem connectionItem=null;
  String oldConnectionId=null;
  String oldTableId=null;
  IMetadataTable oldMetadataTable=null;
  Map<String,String> oldTableMap=null;
  if (selectItems.size() > 0) {
    boolean needRewrite=false;
    for (    XmlFileConnectionItem item : selectItems) {
      connectionProperty=item.getProperty();
      if (connectionProperty.getLabel().equals(name)) {
        oldConnectionId=connectionProperty.getId();
        connectionItem=item;
        connection=(XmlFileConnection)connectionItem.getConnection();
        needRewrite=true;
        Set<MetadataTable> tables=ConnectionHelper.getTables(connection);
        MetadataTable oldTable=null;
        if (tables.size() > 0) {
          oldTable=tables.toArray(new MetadataTable[0])[0];
          oldTableId=oldTable.getId();
          oldMetadataTable=ConvertionHelper.convert(oldTable);
        }
        oldTableMap=RepositoryUpdateManager.getOldTableIdAndNameMap(connectionItem,oldTable,false);
        break;
      }
    }
    if (!needRewrite && !WSDLUtils.isNameValidInXmlFileConnection(parameter,portTypeName,operationName)) {
      return;
    }
  }
  connection=ConnectionFactory.eINSTANCE.createXmlFileConnection();
  connection.setName(ERepositoryObjectType.METADATA_FILE_XML.getKey());
  connectionItem=PropertiesFactory.eINSTANCE.createXmlFileConnectionItem();
  connectionProperty=PropertiesFactory.eINSTANCE.createProperty();
  connectionProperty.setAuthor(((RepositoryContext)CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
  connectionProperty.setLabel(name);
  connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
  connectionProperty.setStatusCode("String_Node_Str");
  connectionItem.setProperty(connectionProperty);
  connectionItem.setConnection(connection);
  connection.setInputModel(false);
  ByteArray byteArray=PropertiesFactory.eINSTANCE.createByteArray();
  byteArray.setInnerContentFromFile(zip);
  connection.setFileContent(byteArray.getInnerContent());
  String schemaFileName=schemaFile.getName();
  schemaFileName=schemaFileName.substring(0,schemaFileName.lastIndexOf("String_Node_Str"));
  connection.setXmlFilePath(schemaFileName.concat("String_Node_Str").concat(zip.getName()));
  try {
    String filePath=schemaFile.getPath();
    XSDSchema xsdSchema=populationUtil.getXSDSchema(filePath);
    List<ATreeNode> rootNodes=populationUtil.getAllRootNodes(xsdSchema);
    ATreeNode node=null;
    for (    ATreeNode curNode : rootNodes) {
      String curName=(String)curNode.getValue();
      if (curName.contains("String_Node_Str")) {
        if (curName.split("String_Node_Str")[1].equals(name)) {
          node=curNode;
          break;
        }
      }
 else       if (curName.equals(name)) {
        node=curNode;
        break;
      }
    }
    node=populationUtil.getSchemaTree(xsdSchema,node);
    orderId=1;
    loopElementFound=false;
    if (ConnectionHelper.getTables(connection).isEmpty()) {
      MetadataTable table=ConnectionFactory.eINSTANCE.createMetadataTable();
      if (oldTableId != null) {
        table.setId(oldTableId);
      }
 else {
        table.setId(ProxyRepositoryFactory.getInstance().getNextId());
      }
      RecordFile record=(RecordFile)ConnectionHelper.getPackage(connection.getName(),connection,RecordFile.class);
      if (record != null) {
        PackageHelper.addMetadataTable(table,record);
      }
 else {
        RecordFile newrecord=RecordFactory.eINSTANCE.createRecordFile();
        newrecord.setName(connection.getName());
        ConnectionHelper.addPackage(newrecord,connection);
        PackageHelper.addMetadataTable(table,newrecord);
      }
    }
    boolean haveElement=false;
    for (    Object curNode : node.getChildren()) {
      if (((ATreeNode)curNode).getType() == ATreeNode.ELEMENT_TYPE) {
        haveElement=true;
        break;
      }
    }
    fillRootInfo(connection,node,"String_Node_Str",!haveElement);
  }
 catch (  IOException e) {
    throw e;
  }
catch (  URISyntaxException e1) {
    ExceptionHandler.process(e1);
  }
catch (  OdaException e) {
    ExceptionHandler.process(e);
  }
  IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  connectionProperty.setId(factory.getNextId());
  try {
    String folderPath=FolderNameUtil.getImportedXmlSchemaPath(parameter.getNamespaceURI(),portTypeName,operationName);
    IPath path=new Path(folderPath);
    factory.create(connectionItem,path,true);
    if (oldConnectionId != null) {
      connectionItem.getProperty().setId(oldConnectionId);
      factory.save(connectionItem);
    }
    propagateSchemaChange(oldMetadataTable,oldTableMap,connection,connectionItem);
    ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
    RepositoryManager.refresh(ERepositoryObjectType.METADATA_FILE_XML);
  }
 catch (  PersistenceException e) {
    ExceptionHandler.process(e);
  }
catch (  URISyntaxException e) {
    ExceptionHandler.process(e);
  }
}