Program: 137247
Project: 137247
Buggy source:
@Override protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
  ReturnCode ok=new ReturnCode(true);
  Set<String> columns=getAnalyzedElements();
  List<String> columnlist=sortColumnName(columns,sqlStatement);
  if (columnlist.isEmpty()) {
    ok.setReturnCode(Messages.getString("String_Node_Str"),false);
    return ok;
  }
  Map<String,String> columnlistMap=buildColumnListMap(columnlist);
  Statement statement=createStatement();
  if (continueRun()) {
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + sqlStatement);
    }
    statement.execute(sqlStatement);
  }
  ResultSet resultSet=statement.getResultSet();
  if (resultSet == null) {
    String mess=Messages.getString("String_Node_Str",sqlStatement);
    log.warn(mess);
    ok.setReturnCode(mess,false);
    statement.close();
    return ok;
  }
  ok=getMessageForInvalidJUDIs();
  int columnCount=resultSet.getMetaData().getColumnCount();
  int maxNumberRows=analysis.getParameters().getMaxNumberRows();
  AnalysisResult anaResult=analysis.getResults();
  EMap<Indicator,AnalyzedDataSet> indicToRowMap=anaResult.getIndicToRowMap();
  indicToRowMap.clear();
  int recordIncrement=0;
  int columnListSize=columnlist.size();
  label:   while (resultSet.next()) {
    for (int i=0; i < columnListSize; i++) {
      String col=columnlist.get(i);
      List<Indicator> indicators=getIndicators(col);
      col=columnlistMap.get(col);
      Object object=null;
      try {
        object=resultSet.getObject(col);
      }
 catch (      SQLException e) {
        if ("String_Node_Str".equals(resultSet.getString(col))) {
          object=null;
        }
      }
      if (object != null && !(object instanceof String) && object.toString().indexOf("String_Node_Str") > -1) {
        object=resultSet.getTimestamp(col);
      }
      for (      Indicator indicator : indicators) {
        if (!continueRun()) {
          break label;
        }
        if (indicator instanceof DuplicateCountIndicator) {
          ((DuplicateCountIndicator)indicator).handle(object,resultSet,columnCount);
        }
 else {
          indicator.handle(object);
        }
        AnalyzedDataSet analyzedDataSet=indicToRowMap.get(indicator);
        if (analyzedDataSet == null) {
          analyzedDataSet=AnalysisFactory.eINSTANCE.createAnalyzedDataSet();
          indicToRowMap.put(indicator,analyzedDataSet);
          analyzedDataSet.setDataCount(maxNumberRows);
          analyzedDataSet.setRecordSize(0);
        }
        if (analysis.getParameters().isStoreData()) {
          if (indicator.mustStoreRow()) {
            List<Object[]> valueObjectList=initDataSet(indicator,indicToRowMap,object);
            recordIncrement=valueObjectList.size();
            ColumnSet doSwitch=SwitchHelpers.COLUMN_SET_SWITCH.doSwitch(indicator.getAnalyzedElement().eContainer());
            List<TdColumn> columnList=ColumnSetHelper.getColumns(doSwitch);
            for (int j=0; j < columnCount; j++) {
              String newcol=columnList.get(j).getName();
              Object newobject=null;
              try {
                newobject=resultSet.getObject(newcol);
              }
 catch (              SQLException e) {
                if ("String_Node_Str".equals(resultSet.getString(newcol))) {
                  newobject=null;
                }
              }
              if (indicator.isSaveTempDataToFile()) {
                AbstractDB<Object> mapDB=indicator.getMapDB(StandardDBName.drillDown.name());
                if (mapDB.size() > maxNumberRows) {
                  break;
                }
                indicator.handleDrillDownData(object,newobject,columnCount,j,newcol);
                continue;
              }
 else {
                if (recordIncrement < maxNumberRows) {
                  if (recordIncrement < valueObjectList.size()) {
                    valueObjectList.get(recordIncrement)[j]=newobject;
                  }
 else {
                    Object[] valueObject=new Object[columnCount];
                    valueObject[j]=newobject;
                    valueObjectList.add(valueObject);
                  }
                }
 else {
                  break;
                }
              }
            }
          }
 else           if (indicator instanceof UniqueCountIndicator && analysis.getResults().getIndicToRowMap().get(indicator).getData() != null) {
            List<Object[]> removeValueObjectList=analysis.getResults().getIndicToRowMap().get(indicator).getData();
            ColumnSet doSwitch=SwitchHelpers.COLUMN_SET_SWITCH.doSwitch(indicator.getAnalyzedElement().eContainer());
            List<TdColumn> columnElementList=ColumnSetHelper.getColumns(doSwitch);
            int offsetting=columnElementList.indexOf(indicator.getAnalyzedElement());
            for (            Object[] dataObject : removeValueObjectList) {
              if (dataObject[offsetting].equals(object)) {
                removeValueObjectList.remove(dataObject);
                break;
              }
            }
          }
        }
      }
    }
  }
  for (int i=0; i < columnListSize; i++) {
    String col=columnlist.get(i);
    List<Indicator> indicators=getIndicators(col);
    if (indicators.size() > 0 && indicators.get(0).isSaveTempDataToFile()) {
      break;
    }
    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(maxNumberRows);
          analyzedDataSet.setRecordSize(0);
        }
        addResultToIndicatorToRowMap(indicator,indicToRowMap,maxNumberRows,columnCount);
      }
    }
  }
  resultSet.close();
  statement.close();
  getConnection().close();
  return ok;
}

Fixed version (ground truth):
@Override protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
  ReturnCode ok=new ReturnCode(true);
  Set<String> columns=getAnalyzedElements();
  List<String> columnlist=sortColumnName(columns,sqlStatement);
  if (columnlist.isEmpty()) {
    ok.setReturnCode(Messages.getString("String_Node_Str"),false);
    return ok;
  }
  Map<String,String> columnlistMap=buildColumnListMap(columnlist);
  Statement statement=createStatement();
  if (continueRun()) {
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + sqlStatement);
    }
    statement.execute(sqlStatement);
  }
  ResultSet resultSet=statement.getResultSet();
  if (resultSet == null) {
    String mess=Messages.getString("String_Node_Str",sqlStatement);
    log.warn(mess);
    ok.setReturnCode(mess,false);
    statement.close();
    return ok;
  }
  ok=getMessageForInvalidJUDIs();
  int columnCount=resultSet.getMetaData().getColumnCount();
  int maxNumberRows=analysis.getParameters().getMaxNumberRows();
  AnalysisResult anaResult=analysis.getResults();
  EMap<Indicator,AnalyzedDataSet> indicToRowMap=anaResult.getIndicToRowMap();
  indicToRowMap.clear();
  int recordIncrement=0;
  int columnListSize=columnlist.size();
  label:   while (resultSet.next()) {
    for (int i=0; i < columnListSize; i++) {
      String col=columnlist.get(i);
      List<Indicator> indicators=getIndicators(col);
      col=columnlistMap.get(col);
      Object object=null;
      try {
        object=resultSet.getObject(col);
      }
 catch (      SQLException e) {
        if ("String_Node_Str".equals(resultSet.getString(col))) {
          object=null;
        }
      }
      if (object != null && !(object instanceof String) && object.toString().indexOf("String_Node_Str") > -1) {
        object=resultSet.getTimestamp(col);
      }
      for (      Indicator indicator : indicators) {
        indicator.setDirllDownSize(maxNumberRows);
        if (!continueRun()) {
          break label;
        }
        if (indicator instanceof DuplicateCountIndicator) {
          ((DuplicateCountIndicator)indicator).handle(object,resultSet,columnCount);
        }
 else {
          indicator.handle(object);
        }
        AnalyzedDataSet analyzedDataSet=indicToRowMap.get(indicator);
        if (analyzedDataSet == null) {
          analyzedDataSet=AnalysisFactory.eINSTANCE.createAnalyzedDataSet();
          indicToRowMap.put(indicator,analyzedDataSet);
          analyzedDataSet.setDataCount(maxNumberRows);
          analyzedDataSet.setRecordSize(0);
        }
        if (analysis.getParameters().isStoreData()) {
          if (indicator.mustStoreRow()) {
            List<Object[]> valueObjectList=initDataSet(indicator,indicToRowMap,object);
            recordIncrement=valueObjectList.size();
            ColumnSet doSwitch=SwitchHelpers.COLUMN_SET_SWITCH.doSwitch(indicator.getAnalyzedElement().eContainer());
            List<TdColumn> columnList=ColumnSetHelper.getColumns(doSwitch);
            for (int j=0; j < columnCount; j++) {
              String newcol=columnList.get(j).getName();
              Object newobject=null;
              try {
                newobject=resultSet.getObject(newcol);
              }
 catch (              SQLException e) {
                if ("String_Node_Str".equals(resultSet.getString(newcol))) {
                  newobject=null;
                }
              }
              if (indicator.isUsedMapDBMode()) {
                indicator.handleDrillDownData(object,newobject,columnCount,j,newcol);
                continue;
              }
 else {
                if (recordIncrement < maxNumberRows) {
                  if (recordIncrement < valueObjectList.size()) {
                    valueObjectList.get(recordIncrement)[j]=newobject;
                  }
 else {
                    Object[] valueObject=new Object[columnCount];
                    valueObject[j]=newobject;
                    valueObjectList.add(valueObject);
                  }
                }
 else {
                  break;
                }
              }
            }
          }
 else           if (indicator instanceof UniqueCountIndicator && analysis.getResults().getIndicToRowMap().get(indicator).getData() != null) {
            List<Object[]> removeValueObjectList=analysis.getResults().getIndicToRowMap().get(indicator).getData();
            ColumnSet doSwitch=SwitchHelpers.COLUMN_SET_SWITCH.doSwitch(indicator.getAnalyzedElement().eContainer());
            List<TdColumn> columnElementList=ColumnSetHelper.getColumns(doSwitch);
            int offsetting=columnElementList.indexOf(indicator.getAnalyzedElement());
            for (            Object[] dataObject : removeValueObjectList) {
              if (dataObject[offsetting].equals(object)) {
                removeValueObjectList.remove(dataObject);
                break;
              }
            }
          }
        }
      }
    }
  }
  for (int i=0; i < columnListSize; i++) {
    String col=columnlist.get(i);
    List<Indicator> indicators=getIndicators(col);
    if (indicators.size() > 0 && indicators.get(0).isUsedMapDBMode()) {
      break;
    }
    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(maxNumberRows);
          analyzedDataSet.setRecordSize(0);
        }
        addResultToIndicatorToRowMap(indicator,indicToRowMap,maxNumberRows,columnCount);
      }
    }
  }
  resultSet.close();
  statement.close();
  getConnection().close();
  return ok;
}