Program: 136458
Project: 136458
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=ResultSetUtils.getObject(resultSet,col);
      if (object != null && !(object instanceof String) && object.toString().indexOf("String_Node_Str") > -1) {
        object=resultSet.getTimestamp(col);
      }
      if (object instanceof Date) {
        if (object instanceof Time) {
          object=new TalendFormatTime((Time)object);
        }
 else {
          object=new TalendFormatDate((Date)object);
        }
      }
      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);
            List<Object> inputRowList=new ArrayList<Object>();
            for (int j=0; j < columnCount; j++) {
              String newcol=columnList.get(j).getName();
              Object newobject=ResultSetUtils.getObject(resultSet,newcol);
              if (newobject instanceof Date) {
                if (newobject instanceof Time) {
                  newobject=new TalendFormatTime((Time)newobject);
                }
 else {
                  newobject=new TalendFormatDate((Date)newobject);
                }
              }
              if (indicator.isUsedMapDBMode()) {
                inputRowList.add(newobject == null ? PluginConstant.NULL_STRING : newobject);
                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;
                }
              }
            }
            if (indicator.isUsedMapDBMode()) {
              MapDBUtils.handleDrillDownData(object,inputRowList,indicator);
            }
          }
 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;
              }
            }
          }
        }
      }
    }
  }
  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=ResultSetUtils.getBigObject(resultSet,col);
      if (object != null && !(object instanceof String) && object.toString().indexOf("String_Node_Str") > -1) {
        object=resultSet.getTimestamp(col);
      }
      if (object instanceof Date) {
        if (object instanceof Time) {
          object=new TalendFormatTime((Time)object);
        }
 else {
          object=new TalendFormatDate((Date)object);
        }
      }
      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);
            List<Object> inputRowList=new ArrayList<Object>();
            for (int j=0; j < columnCount; j++) {
              String newcol=columnList.get(j).getName();
              Object newobject=ResultSetUtils.getBigObject(resultSet,newcol);
              if (newobject instanceof Date) {
                if (newobject instanceof Time) {
                  newobject=new TalendFormatTime((Time)newobject);
                }
 else {
                  newobject=new TalendFormatDate((Date)newobject);
                }
              }
              if (indicator.isUsedMapDBMode()) {
                inputRowList.add(newobject == null ? PluginConstant.NULL_STRING : newobject);
                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;
                }
              }
            }
            if (indicator.isUsedMapDBMode()) {
              MapDBUtils.handleDrillDownData(object,inputRowList,indicator);
            }
          }
 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;
              }
            }
          }
        }
      }
    }
  }
  resultSet.close();
  statement.close();
  getConnection().close();
  return ok;
}