Program: 101948
Project: 101948
Buggy source:
@Override public XmiVdb xmiVdbConvert(IFile destination,Properties options) throws Exception {
  NullProgressMonitor monitor=new NullProgressMonitor();
  try {
    VdbPlugin.singleton().setConversionInProgress(true);
    XmiVdb xmiVdb=new XmiVdb(destination);
    populateVdb(xmiVdb);
    List<DynamicModel> dynamicModels=new ArrayList<DynamicModel>(getDynamicModels());
    if (!dynamicModels.isEmpty())     Collections.sort(dynamicModels,new DynamicModelComparator());
    Map<ModelResource,DdlImporter> importerModelMap=new HashMap<ModelResource,DdlImporter>();
    for (    DynamicModel dynModel : dynamicModels) {
      IFile sourceFile=this.getSourceFile();
      IContainer parent=sourceFile.getParent();
      String fileName=dynModel.getName() + DOT_XMI;
      ModelResource modelResource=null;
      IFile modelFile=parent.getFile(new Path(fileName));
      if (modelFile.exists())       modelFile.delete(true,monitor);
      modelResource=ModelerCore.create(modelFile);
      if (modelResource == null)       throw new Exception("String_Node_Str");
      ModelAnnotation annotation=modelResource.getModelAnnotation();
      annotation.setPrimaryMetamodelUri(RelationalPackage.eNS_URI);
      annotation.setModelType(ModelType.get(dynModel.getModelType().getType()));
      VdbSource[] sources=dynModel.getSources();
      if (sources != null) {
        for (        VdbSource source : sources) {
          String translatorProperty=IConnectionInfoHelper.TRANSLATOR_NAMESPACE + IConnectionInfoHelper.TRANSLATOR_NAME_KEY;
          ModelUtil.setModelAnnotationPropertyValue(modelResource,translatorProperty,source.getTranslatorName());
          String jndiProperty=IConnectionInfoHelper.CONNECTION_NAMESPACE + IJBossDsProfileConstants.JNDI_PROP_ID;
          ModelUtil.setModelAnnotationPropertyValue(modelResource,jndiProperty,source.getJndiName());
        }
      }
      modelResource.save(monitor,false);
      ModelBuildUtil.indexResources(monitor,Collections.singleton(modelResource.getCorrespondingResource()));
      Metadata metadata=dynModel.getMetadata();
      if (metadata != null) {
        IProject project=parent.getProject();
        DdlImporter importer=new DdlImporter(new IProject[]{project});
        importer.setModelFolder(parent);
        importer.setModelName(fileName);
        importer.setOptToCreateModelEntitiesForUnsupportedDdl(false);
        String ddlAsDescriptionOption=options.getProperty(Vdb.SET_DDL_AS_DESCRIPTION,Boolean.FALSE.toString());
        importer.setOptToSetModelEntityDescription(Boolean.parseBoolean(ddlAsDescriptionOption));
        Type dynModelType=dynModel.getModelType();
        String modelType=dynModelType.toString();
        importer.setModelType(ModelType.get(modelType));
        importer.setGenerateDefaultSQL(Type.VIRTUAL.equals(dynModelType));
        importer.setDdlFileName(getSourceFile().getLocation().toOSString());
        importer.setSpecifiedParser("String_Node_Str");
        importer.importDdl(metadata.getSchemaText(),monitor,1,new Properties());
        if (importer.hasParseError()) {
          StringBuffer buffer=new StringBuffer();
          buffer.append("String_Node_Str").append(TAB);
          buffer.append(importer.getParseErrorMessage().trim()).append(NEW_LINE);
          buffer.append(TAB).append(TAB).append(SPACE).append(SPACE).append("String_Node_Str").append(TAB);
          buffer.append(importer.getParseErrorLineNumber()).append(NEW_LINE);
          buffer.append(TAB).append(TAB).append(SPACE).append(SPACE).append("String_Node_Str").append(TAB);
          buffer.append(importer.getParseErrorColNumber()).append(NEW_LINE);
          buffer.append(TAB).append(TAB).append(SPACE).append(SPACE).append("String_Node_Str").append(TAB);
          buffer.append(importer.getParseErrorIndex()).append(NEW_LINE);
          throw new Exception(buffer.toString());
        }
        if (!importer.noDdlImported()) {
          importer.save(monitor,1);
        }
        modelResource=importer.model();
        String desc=dynModel.getDescription();
        if (!StringUtilities.isEmpty(desc)) {
          modelResource.getModelAnnotation().setDescription(desc);
          modelResource.save(monitor,false);
        }
        importerModelMap.put(modelResource,importer);
      }
      VdbModelEntry modelEntry=xmiVdb.addEntry(modelFile.getFullPath());
      for (      Map.Entry<Object,Object> prop : dynModel.getProperties().entrySet()) {
        modelEntry.setProperty(prop.getKey().toString(),prop.getValue().toString());
      }
      String desc=dynModel.getDescription();
      if (!StringUtilities.isEmpty(desc)) {
        modelEntry.setDescription(desc);
      }
      modelEntry.setVisible(dynModel.isVisible());
      VdbSourceInfo sourceInfo=modelEntry.getSourceInfo();
      sourceInfo.setIsMultiSource(dynModel.isMultiSource());
      sourceInfo.setAddColumn(dynModel.doAddColumn());
      sourceInfo.setColumnAlias(dynModel.getColumnAlias());
      for (      VdbSource source : dynModel.getSources()) {
        sourceInfo.add(source.getName(),source.getJndiName(),source.getTranslatorName());
      }
      for (      Map.Entry<Object,Object> entry : dynModel.getProperties().entrySet()) {
        modelEntry.setProperty(entry.getKey().toString(),entry.getValue().toString());
      }
    }
    for (    DdlImporter importer : importerModelMap.values()) {
      importer.setMaterializedTableReferences(importerModelMap.keySet());
    }
    return xmiVdb;
  }
  finally {
    VdbPlugin.singleton().setConversionInProgress(false);
  }
}

Fixed version (ground truth):
@Override public XmiVdb xmiVdbConvert(IFile destination,Properties options) throws Exception {
  NullProgressMonitor monitor=new NullProgressMonitor();
  try {
    VdbPlugin.singleton().setConversionInProgress(true);
    XmiVdb xmiVdb=new XmiVdb(destination);
    populateVdb(xmiVdb);
    List<DynamicModel> dynamicModels=new ArrayList<DynamicModel>(getDynamicModels());
    if (!dynamicModels.isEmpty())     Collections.sort(dynamicModels,new DynamicModelComparator());
    Map<ModelResource,DdlImporter> importerModelMap=new HashMap<ModelResource,DdlImporter>();
    for (    DynamicModel dynModel : dynamicModels) {
      IFile sourceFile=this.getSourceFile();
      IContainer parent=sourceFile.getParent();
      String fileName=dynModel.getName() + DOT_XMI;
      ModelResource modelResource=null;
      IFile modelFile=parent.getFile(new Path(fileName));
      if (modelFile.exists())       modelFile.delete(true,monitor);
      modelResource=ModelerCore.create(modelFile);
      if (modelResource == null)       throw new Exception("String_Node_Str");
      ModelAnnotation annotation=modelResource.getModelAnnotation();
      annotation.setPrimaryMetamodelUri(RelationalPackage.eNS_URI);
      annotation.setModelType(ModelType.get(dynModel.getModelType().getType()));
      VdbSource[] sources=dynModel.getSources();
      if (sources != null) {
        boolean propsAreSet=false;
        for (        VdbSource source : sources) {
          if (propsAreSet)           break;
          String translatorProperty=IConnectionInfoHelper.TRANSLATOR_NAMESPACE + IConnectionInfoHelper.TRANSLATOR_NAME_KEY;
          ModelUtil.setModelAnnotationPropertyValue(modelResource,translatorProperty,source.getTranslatorName());
          String jndiProperty=IConnectionInfoHelper.CONNECTION_NAMESPACE + IJBossDsProfileConstants.JNDI_PROP_ID;
          ModelUtil.setModelAnnotationPropertyValue(modelResource,jndiProperty,source.getJndiName());
          propsAreSet=true;
        }
      }
      modelResource.save(monitor,false);
      ModelBuildUtil.indexResources(monitor,Collections.singleton(modelResource.getCorrespondingResource()));
      Metadata metadata=dynModel.getMetadata();
      if (metadata != null) {
        IProject project=parent.getProject();
        DdlImporter importer=new DdlImporter(new IProject[]{project});
        importer.setModelFolder(parent);
        importer.setModelName(fileName);
        importer.setOptToCreateModelEntitiesForUnsupportedDdl(false);
        String ddlAsDescriptionOption=options.getProperty(Vdb.SET_DDL_AS_DESCRIPTION,Boolean.FALSE.toString());
        importer.setOptToSetModelEntityDescription(Boolean.parseBoolean(ddlAsDescriptionOption));
        Type dynModelType=dynModel.getModelType();
        String modelType=dynModelType.toString();
        importer.setModelType(ModelType.get(modelType));
        importer.setGenerateDefaultSQL(Type.VIRTUAL.equals(dynModelType));
        importer.setDdlFileName(getSourceFile().getLocation().toOSString());
        importer.setSpecifiedParser("String_Node_Str");
        importer.importDdl(metadata.getSchemaText(),monitor,1,new Properties());
        if (importer.hasParseError()) {
          StringBuffer buffer=new StringBuffer();
          buffer.append("String_Node_Str").append(TAB);
          buffer.append(importer.getParseErrorMessage().trim()).append(NEW_LINE);
          buffer.append(TAB).append(TAB).append(SPACE).append(SPACE).append("String_Node_Str").append(TAB);
          buffer.append(importer.getParseErrorLineNumber()).append(NEW_LINE);
          buffer.append(TAB).append(TAB).append(SPACE).append(SPACE).append("String_Node_Str").append(TAB);
          buffer.append(importer.getParseErrorColNumber()).append(NEW_LINE);
          buffer.append(TAB).append(TAB).append(SPACE).append(SPACE).append("String_Node_Str").append(TAB);
          buffer.append(importer.getParseErrorIndex()).append(NEW_LINE);
          throw new Exception(buffer.toString());
        }
        if (!importer.noDdlImported()) {
          importer.save(monitor,1);
        }
        modelResource=importer.model();
        String desc=dynModel.getDescription();
        if (!StringUtilities.isEmpty(desc)) {
          modelResource.getModelAnnotation().setDescription(desc);
          modelResource.save(monitor,false);
        }
        importerModelMap.put(modelResource,importer);
      }
      VdbModelEntry modelEntry=xmiVdb.addEntry(modelFile.getFullPath());
      for (      Map.Entry<Object,Object> prop : dynModel.getProperties().entrySet()) {
        modelEntry.setProperty(prop.getKey().toString(),prop.getValue().toString());
      }
      String desc=dynModel.getDescription();
      if (!StringUtilities.isEmpty(desc)) {
        modelEntry.setDescription(desc);
      }
      modelEntry.setVisible(dynModel.isVisible());
      VdbSourceInfo sourceInfo=modelEntry.getSourceInfo();
      sourceInfo.setIsMultiSource(dynModel.isMultiSource());
      sourceInfo.setAddColumn(dynModel.doAddColumn());
      sourceInfo.setColumnAlias(dynModel.getColumnAlias());
      for (      VdbSource source : dynModel.getSources()) {
        sourceInfo.add(source.getName(),source.getJndiName(),source.getTranslatorName());
      }
      for (      Map.Entry<Object,Object> entry : dynModel.getProperties().entrySet()) {
        modelEntry.setProperty(entry.getKey().toString(),entry.getValue().toString());
      }
    }
    for (    DdlImporter importer : importerModelMap.values()) {
      importer.setMaterializedTableReferences(importerModelMap.keySet());
    }
    return xmiVdb;
  }
  finally {
    VdbPlugin.singleton().setConversionInProgress(false);
  }
}