Program: 65516
Project: 65516
Buggy source:
/** 
 * @param context
 * @param queryResults
 * @param queryResultID
 * @param useDetails
 * @param lowestGroupLevel
 * @throws DataException
 */
ResultIterator2(IServiceForResultSet rService,org.eclipse.birt.data.engine.odi.IResultIterator odiResult,Scriptable scope,int rawIdStartingValue) throws DataException {
  super(rService,odiResult,scope,rawIdStartingValue);
  Object[] params={rService,odiResult,scope};
  logger.entering(ResultIterator2.class.getName(),"String_Node_Str",params);
  this.lowestGroupLevel=rService.getQueryDefn().getGroups().size();
  this.currRowIndex=-1;
  this.cachedRowId=0;
  this.isSummary=(rService.getQueryDefn() instanceof IQueryDefinition) ? ((IQueryDefinition)rService.getQueryDefn()).isSummaryQuery() : false;
  if (this.isSummary) {
    if (lowestGroupLevel == 0)     this.groupLevelCalculator=new SummaryGroupLevelCalculator(null);
 else {
      int[][] groupIndex=new int[lowestGroupLevel + 1][];
      for (int i=0; i <= lowestGroupLevel; i++) {
        groupIndex[i]=this.odiResult.getGroupStartAndEndIndex(i);
      }
      this.groupLevelCalculator=new SummaryGroupLevelCalculator(groupIndex);
    }
    if (rService.getSession().getEngineContext().getMode() == DataEngineContext.MODE_GENERATION) {
      this.saveToDoc=true;
      streamManager=new StreamManager(rService.getSession().getEngineContext(),new QueryResultInfo(rService.getQueryResults().getID(),null,0));
      try {
        bindings=findSavedBinding(rService.getQueryDefn().getBindings());
        this.doSaveResultClass(streamManager.getOutStream(DataEngineContext.DATASET_META_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE),bindings);
        raDataSet=(RAOutputStream)streamManager.getOutStream(DataEngineContext.DATASET_DATA_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE);
        rowCountOffset=raDataSet.getOffset();
        dataSetStream=new DataOutputStream(raDataSet);
        IOUtil.writeInt(dataSetStream,-1);
        dataSetLenStream=new DataOutputStream(streamManager.getOutStream(DataEngineContext.DATASET_DATA_LEN_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE));
      }
 catch (      Exception e) {
        throw new DataException(e.getLocalizedMessage());
      }
    }
  }
  logger.exiting(ResultIterator2.class.getName(),"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * @param context
 * @param queryResults
 * @param queryResultID
 * @param useDetails
 * @param lowestGroupLevel
 * @throws DataException
 */
ResultIterator2(IServiceForResultSet rService,org.eclipse.birt.data.engine.odi.IResultIterator odiResult,Scriptable scope,int rawIdStartingValue) throws DataException {
  super(rService,odiResult,scope,rawIdStartingValue);
  Object[] params={rService,odiResult,scope};
  logger.entering(ResultIterator2.class.getName(),"String_Node_Str",params);
  this.lowestGroupLevel=rService.getQueryDefn().getGroups().size();
  this.currRowIndex=-1;
  this.cachedRowId=0;
  this.dtContext=rService.getSession().getEngineContext();
  this.isSummary=(rService.getQueryDefn() instanceof IQueryDefinition) ? ((IQueryDefinition)rService.getQueryDefn()).isSummaryQuery() : false;
  if (this.isSummary) {
    if (lowestGroupLevel == 0)     this.groupLevelCalculator=new SummaryGroupLevelCalculator(null);
 else {
      int[][] groupIndex=new int[lowestGroupLevel + 1][];
      for (int i=0; i <= lowestGroupLevel; i++) {
        groupIndex[i]=this.odiResult.getGroupStartAndEndIndex(i);
      }
      this.groupLevelCalculator=new SummaryGroupLevelCalculator(groupIndex);
    }
    if (rService.getSession().getEngineContext().getMode() == DataEngineContext.MODE_GENERATION) {
      this.saveToDoc=true;
      streamManager=new StreamManager(rService.getSession().getEngineContext(),new QueryResultInfo(rService.getQueryResults().getID(),null,0));
      try {
        bindings=findSavedBinding(rService.getQueryDefn().getBindings());
        this.doSaveResultClass(streamManager.getOutStream(DataEngineContext.DATASET_META_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE),bindings);
        raDataSet=(RAOutputStream)streamManager.getOutStream(DataEngineContext.DATASET_DATA_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE);
        rowCountOffset=raDataSet.getOffset();
        dataSetStream=new DataOutputStream(raDataSet);
        IOUtil.writeInt(dataSetStream,-1);
        dataSetLenStream=new DataOutputStream(streamManager.getOutStream(DataEngineContext.DATASET_DATA_LEN_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE));
      }
 catch (      Exception e) {
        throw new DataException(e.getLocalizedMessage());
      }
    }
  }
  logger.exiting(ResultIterator2.class.getName(),"String_Node_Str");
}