Program: 66702
Project: 66702
Buggy source:
/** 
 * @param eventHandler
 * @param stopSign
 * @param manager
 * @throws DataException
 * @throws IOException
 */
private void populatePLSDataSetData(IEventHandler eventHandler,StreamManager manager) throws DataException, IOException {
  org.eclipse.birt.data.engine.impl.document.ResultIterator docIt=new org.eclipse.birt.data.engine.impl.document.ResultIterator(engine.getSession().getTempDir(),getEngineContext(),null,queryDefn.getQueryResultsID(),queryDefn);
  PLSEnabledDataSetPopulator populator=new PLSEnabledDataSetPopulator(queryDefn,queryDefn.getQueryExecutionHints().getTargetGroupInstances(),docIt);
  ResultClass processedRC=(ResultClass)populateResultClass(populator.getResultClass());
  SmartCache cache=new SmartCache(new CacheRequest(0,new ArrayList(),null,eventHandler),new OdiAdapter(populator),processedRC,engine.getSession());
  manager.dropStream1(DataEngineContext.DATASET_DATA_STREAM);
  manager.dropStream1(DataEngineContext.DATASET_DATA_LEN_STREAM);
  cleanUpOldRD();
  OutputStream resultClassStream=manager.getOutStream(DataEngineContext.DATASET_META_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE);
  processedRC.doSave(resultClassStream,new ArrayList(queryDefn.getBindings().values()),manager.getVersion());
  resultClassStream.close();
  DataOutputStream dataSetDataStream=new DataOutputStream(manager.getOutStream(DataEngineContext.DATASET_DATA_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE));
  DataOutputStream rowLensStream=new DataOutputStream(manager.getOutStream(DataEngineContext.DATASET_DATA_LEN_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE));
  cache.doSave(dataSetDataStream,rowLensStream,null,new HashMap(),eventHandler.getAllColumnBindings());
  dataSetDataStream.flush();
  cache.close();
  DataOutputStream plsGroupLevelStream=new DataOutputStream(manager.getOutStream(DataEngineContext.PLS_GROUPLEVEL_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE));
  IOUtil.writeInt(plsGroupLevelStream,PLSUtil.getOutmostPlsGroupLevel(queryDefn));
  plsGroupLevelStream.close();
}

Fixed version (ground truth):
/** 
 * @param eventHandler
 * @param stopSign
 * @param manager
 * @throws DataException
 * @throws IOException
 */
private void populatePLSDataSetData(IEventHandler eventHandler,StreamManager manager) throws DataException, IOException {
  org.eclipse.birt.data.engine.impl.document.ResultIterator docIt;
  if (!queryDefn.isSummaryQuery()) {
    docIt=new org.eclipse.birt.data.engine.impl.document.ResultIterator(engine.getSession().getTempDir(),getEngineContext(),null,queryDefn.getQueryResultsID(),queryDefn);
  }
 else {
    docIt=new org.eclipse.birt.data.engine.impl.document.ResultIterator2(engine.getSession().getTempDir(),getEngineContext(),null,queryDefn.getQueryResultsID(),queryDefn.getGroups().size(),queryDefn.isSummaryQuery(),queryDefn);
  }
  PLSEnabledDataSetPopulator populator=new PLSEnabledDataSetPopulator(queryDefn,queryDefn.getQueryExecutionHints().getTargetGroupInstances(),docIt);
  ResultClass processedRC=(ResultClass)populateResultClass(populator.getResultClass());
  SmartCache cache=new SmartCache(new CacheRequest(0,new ArrayList(),null,eventHandler),new OdiAdapter(populator),processedRC,engine.getSession());
  manager.dropStream1(DataEngineContext.DATASET_DATA_STREAM);
  manager.dropStream1(DataEngineContext.DATASET_DATA_LEN_STREAM);
  cleanUpOldRD();
  OutputStream resultClassStream=manager.getOutStream(DataEngineContext.DATASET_META_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE);
  processedRC.doSave(resultClassStream,new ArrayList(queryDefn.getBindings().values()),manager.getVersion());
  resultClassStream.close();
  DataOutputStream dataSetDataStream=new DataOutputStream(manager.getOutStream(DataEngineContext.DATASET_DATA_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE));
  DataOutputStream rowLensStream=new DataOutputStream(manager.getOutStream(DataEngineContext.DATASET_DATA_LEN_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE));
  cache.doSave(dataSetDataStream,rowLensStream,null,new HashMap(),eventHandler.getAllColumnBindings());
  dataSetDataStream.flush();
  cache.close();
  DataOutputStream plsGroupLevelStream=new DataOutputStream(manager.getOutStream(DataEngineContext.PLS_GROUPLEVEL_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE));
  IOUtil.writeInt(plsGroupLevelStream,PLSUtil.getOutmostPlsGroupLevel(queryDefn));
  plsGroupLevelStream.close();
}