Program: 67933
Project: 67933
Buggy source:
/** 
 * load map from query id to result set id from report document.
 */
private void loadResultSetMetaData(){
  try {
    HashMap query2ResultMetaData=report.getResultMetaData();
    IDocArchiveReader reader=reportDocReader.getArchive();
    HashMap queryCounts=new HashMap();
    ArrayList result=DteMetaInfoIOUtil.loadDteMetaInfo(reader);
    if (result != null) {
      Set dteMetaInfoSet=new HashSet();
      for (int i=0; i < result.size(); i++) {
        String[] rsetRelation=(String[])result.get(i);
        rssetIdMapping.put(this.getDteMetaInfoString(rsetRelation),rsetRelation[3]);
        String dteMetaInfoString=getDteMetaInfoString(rsetRelation);
        if (dteMetaInfoSet.contains(dteMetaInfoString)) {
          continue;
        }
        dteMetaInfoSet.add(dteMetaInfoString);
        String queryId=rsetRelation[2];
        String rsetId=rsetRelation[3];
        IQueryDefinition query=getQuery(queryId);
        int count=-1;
        Integer countObj=(Integer)queryCounts.get(queryId);
        if (countObj != null) {
          count=countObj.intValue();
        }
        count++;
        String rsetName=getQueryName(queryId);
        if (count > 0) {
          rsetName=rsetName + "String_Node_Str" + count;
        }
        queryCounts.put(queryId,new Integer(count));
        if (null != query2ResultMetaData) {
          ResultMetaData metaData=(ResultMetaData)query2ResultMetaData.get(query);
          if (metaData != null && metaData.getColumnCount() > 0) {
            ReportItemDesign design=(ReportItemDesign)report.getReportItemToQueryMap().get(query);
            ReportItemHandle handle=(ReportItemHandle)design.getHandle();
            if (!handle.allowExport()) {
              continue;
            }
            IResultSetItem resultItem=new ResultSetItem(rsetName,metaData,handle,executionContext.getLocale());
            resultMetaList.add(resultItem);
            rsetName2IdMapping.put(rsetName,rsetId);
            rsetId2queryIdMapping.put(rsetId,queryId);
          }
        }
      }
    }
    if (isCubeExportEnabled && !cubeNameList.isEmpty()) {
      for (Iterator itr=cubeNameList.iterator(); itr.hasNext(); ) {
        String name=(String)itr.next();
        resultMetaList.add(new ResultSetItem(name,null));
      }
    }
  }
 catch (  IOException ioe) {
    logger.log(Level.SEVERE,ioe.getMessage(),ioe);
  }
}

Fixed version (ground truth):
/** 
 * load map from query id to result set id from report document.
 */
private void loadResultSetMetaData(){
  try {
    HashMap query2ResultMetaData=report.getResultMetaData();
    IDocArchiveReader reader=reportDocReader.getArchive();
    HashMap queryCounts=new HashMap();
    ArrayList result=DteMetaInfoIOUtil.loadDteMetaInfo(reader);
    if (result != null) {
      Set dteMetaInfoSet=new HashSet();
      for (int i=0; i < result.size(); i++) {
        String[] rsetRelation=(String[])result.get(i);
        rssetIdMapping.put(this.getDteMetaInfoString(rsetRelation),rsetRelation[3]);
        String dteMetaInfoString=getDteMetaInfoString(rsetRelation);
        if (dteMetaInfoSet.contains(dteMetaInfoString)) {
          continue;
        }
        dteMetaInfoSet.add(dteMetaInfoString);
        String queryId=rsetRelation[2];
        String rsetId=rsetRelation[3];
        IDataQueryDefinition query=getQuery(queryId);
        int count=-1;
        Integer countObj=(Integer)queryCounts.get(queryId);
        if (countObj != null) {
          count=countObj.intValue();
        }
        count++;
        String rsetName=getQueryName(queryId);
        if (count > 0) {
          rsetName=rsetName + "String_Node_Str" + count;
        }
        queryCounts.put(queryId,new Integer(count));
        if (null != query2ResultMetaData) {
          ResultMetaData metaData=(ResultMetaData)query2ResultMetaData.get(query);
          if (metaData != null && metaData.getColumnCount() > 0) {
            ReportItemDesign design=(ReportItemDesign)report.getReportItemToQueryMap().get(query);
            ReportItemHandle handle=(ReportItemHandle)design.getHandle();
            if (!handle.allowExport()) {
              continue;
            }
            IResultSetItem resultItem=new ResultSetItem(rsetName,metaData,handle,executionContext.getLocale());
            resultMetaList.add(resultItem);
            rsetName2IdMapping.put(rsetName,rsetId);
            rsetId2queryIdMapping.put(rsetId,queryId);
          }
        }
      }
    }
    if (isCubeExportEnabled && !cubeNameList.isEmpty()) {
      for (Iterator itr=cubeNameList.iterator(); itr.hasNext(); ) {
        String name=(String)itr.next();
        resultMetaList.add(new ResultSetItem(name,null));
      }
    }
  }
 catch (  IOException ioe) {
    logger.log(Level.SEVERE,ioe.getMessage(),ioe);
  }
}