Program: 137635
Project: 137635
Buggy source:
@Override protected ReturnCode executeSqlQuery(String sqlStatement){
  ReturnCode returnCode=new ReturnCode(true);
  if (delimitedFileconnection == null) {
    delimitedFileconnection=(DelimitedFileConnection)analysis.getContext().getConnection();
  }
  String path=AnalysisExecutorHelper.getFilePath(delimitedFileconnection);
  IPath iPath=new Path(path);
  try {
    File file=iPath.toFile();
    if (!file.exists()) {
      returnCode.setReturnCode(Messages.getString("String_Node_Str"),false);
      return returnCode;
    }
    List<ModelElement> analysisElementList=this.analysis.getContext().getAnalysedElements();
    EMap<Indicator,AnalyzedDataSet> indicToRowMap=analysis.getResults().getIndicToRowMap();
    indicToRowMap.clear();
    List<MetadataColumn> columnElementList=new ArrayList<MetadataColumn>();
    for (int i=0; i < analysisElementList.size(); i++) {
      MetadataColumn mColumn=(MetadataColumn)analysisElementList.get(i);
      MetadataTable mTable=ColumnHelper.getColumnOwnerAsMetadataTable(mColumn);
      columnElementList=mTable == null ? columnElementList : mTable.getColumns();
      if (!columnElementList.isEmpty()) {
        break;
      }
    }
    if (Escape.CSV.equals(delimitedFileconnection.getEscapeType())) {
      useCsvReader(file,delimitedFileconnection,analysisElementList,columnElementList,indicToRowMap);
    }
 else {
      FileInputDelimited fileInputDelimited=AnalysisExecutorHelper.createFileInputDelimited(delimitedFileconnection);
      long currentRow=AnalysisExecutorHelper.getHeadValue(delimitedFileconnection);
      while (fileInputDelimited.nextRecord()) {
        if (!continueRun()) {
          break;
        }
        currentRow++;
        int columsCount=fileInputDelimited.getColumnsCountOfCurrentRow();
        String[] rowValues=new String[columsCount];
        for (int i=0; i < columsCount; i++) {
          rowValues[i]=fileInputDelimited.get(i);
        }
        handleByARow(rowValues,currentRow,analysisElementList,columnElementList,indicToRowMap);
      }
      fileInputDelimited.close();
    }
    for (    MetadataColumn col : columnElementList) {
      List<Indicator> indicators=getIndicators(col.getLabel());
      for (      Indicator indicator : indicators) {
        if (indicator instanceof DuplicateCountIndicator) {
          AnalyzedDataSet analyzedDataSet=indicToRowMap.get(indicator);
          if (analyzedDataSet == null) {
            analyzedDataSet=AnalysisFactory.eINSTANCE.createAnalyzedDataSet();
            indicToRowMap.put(indicator,analyzedDataSet);
            analyzedDataSet.setDataCount(analysis.getParameters().getMaxNumberRows());
            analyzedDataSet.setRecordSize(0);
          }
          addResultToIndicatorToRowMap(indicator,indicToRowMap);
        }
      }
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return returnCode;
}

Fixed version (ground truth):
@Override protected ReturnCode executeSqlQuery(String sqlStatement){
  ReturnCode returnCode=new ReturnCode(true);
  if (delimitedFileconnection == null) {
    delimitedFileconnection=(DelimitedFileConnection)analysis.getContext().getConnection();
  }
  if (delimitedFileconnection.isContextMode()) {
    IRepositoryContextService service=CoreRuntimePlugin.getInstance().getRepositoryContextService();
    delimitedFileconnection=(DelimitedFileConnection)service.cloneOriginalValueConnection(delimitedFileconnection);
  }
  String path=AnalysisExecutorHelper.getFilePath(delimitedFileconnection);
  IPath iPath=new Path(path);
  try {
    File file=iPath.toFile();
    if (!file.exists()) {
      returnCode.setReturnCode(Messages.getString("String_Node_Str"),false);
      return returnCode;
    }
    List<ModelElement> analysisElementList=this.analysis.getContext().getAnalysedElements();
    EMap<Indicator,AnalyzedDataSet> indicToRowMap=analysis.getResults().getIndicToRowMap();
    indicToRowMap.clear();
    List<MetadataColumn> columnElementList=new ArrayList<MetadataColumn>();
    for (int i=0; i < analysisElementList.size(); i++) {
      MetadataColumn mColumn=(MetadataColumn)analysisElementList.get(i);
      MetadataTable mTable=ColumnHelper.getColumnOwnerAsMetadataTable(mColumn);
      columnElementList=mTable == null ? columnElementList : mTable.getColumns();
      if (!columnElementList.isEmpty()) {
        break;
      }
    }
    if (Escape.CSV.equals(delimitedFileconnection.getEscapeType())) {
      useCsvReader(file,delimitedFileconnection,analysisElementList,columnElementList,indicToRowMap);
    }
 else {
      FileInputDelimited fileInputDelimited=AnalysisExecutorHelper.createFileInputDelimited(delimitedFileconnection);
      long currentRow=AnalysisExecutorHelper.getHeadValue(delimitedFileconnection);
      while (fileInputDelimited.nextRecord()) {
        if (!continueRun()) {
          break;
        }
        currentRow++;
        int columsCount=fileInputDelimited.getColumnsCountOfCurrentRow();
        String[] rowValues=new String[columsCount];
        for (int i=0; i < columsCount; i++) {
          rowValues[i]=fileInputDelimited.get(i);
        }
        handleByARow(rowValues,currentRow,analysisElementList,columnElementList,indicToRowMap);
      }
      fileInputDelimited.close();
    }
    for (    MetadataColumn col : columnElementList) {
      List<Indicator> indicators=getIndicators(col.getLabel());
      for (      Indicator indicator : indicators) {
        if (indicator instanceof DuplicateCountIndicator) {
          AnalyzedDataSet analyzedDataSet=indicToRowMap.get(indicator);
          if (analyzedDataSet == null) {
            analyzedDataSet=AnalysisFactory.eINSTANCE.createAnalyzedDataSet();
            indicToRowMap.put(indicator,analyzedDataSet);
            analyzedDataSet.setDataCount(analysis.getParameters().getMaxNumberRows());
            analyzedDataSet.setRecordSize(0);
          }
          addResultToIndicatorToRowMap(indicator,indicToRowMap);
        }
      }
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return returnCode;
}