Program: 77872
Project: 77872
Buggy source:
/** 
 * Save below information into report document: result class group information subquery information
 * @param odiResult
 * @throws DataException
 */
private void saveResultIterator(IResultIterator odiResult,int groupLevel,int[] subQueryInfo) throws DataException {
  try {
    OutputStream streamForDataSet=null;
    OutputStream streamForResultClass=null;
    OutputStream streamForGroupInfo=null;
    OutputStream streamForRowIndexInfo=null;
    boolean isSubQuery=streamManager.isSubquery();
    if (streamManager.isSecondRD() == false) {
      if (context.getMode() == DataEngineContext.MODE_GENERATION && isSubQuery == false) {
        streamForResultClass=streamManager.getOutStream(DataEngineContext.DATASET_META_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE);
        streamForDataSet=streamManager.getOutStream(DataEngineContext.DATASET_DATA_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE);
      }
    }
 else {
      streamForRowIndexInfo=streamManager.getOutStream(DataEngineContext.ROW_INDEX_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE);
    }
    streamForGroupInfo=streamManager.getOutStream(DataEngineContext.GROUP_INFO_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE);
    odiResult.doSave(new StreamWrapper(streamForResultClass,streamForDataSet,streamForGroupInfo,streamForRowIndexInfo),isSubQuery,RDSave.this.exprNameSet);
    if (streamForResultClass != null)     streamForResultClass.close();
    if (streamForGroupInfo != null)     streamForGroupInfo.close();
    if (streamForRowIndexInfo != null)     streamForRowIndexInfo.close();
    if (streamForDataSet != null)     streamForDataSet.close();
    if (isSubQuery == true && streamManager.hasOutStream(DataEngineContext.SUBQUERY_INFO_STREAM,StreamManager.SUB_QUERY_ROOT_STREAM,StreamManager.SELF_SCOPE) == false) {
      OutputStream streamForSubQuery=streamManager.getOutStream(DataEngineContext.SUBQUERY_INFO_STREAM,StreamManager.SUB_QUERY_ROOT_STREAM,StreamManager.SELF_SCOPE);
      RDSubQueryUtil.doSave(streamForSubQuery,groupLevel,subQueryInfo);
      streamForSubQuery.close();
    }
  }
 catch (  IOException e) {
    throw new DataException(ResourceConstants.RD_SAVE_ERROR,e,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Save below information into report document: result class group information subquery information
 * @param odiResult
 * @throws DataException
 */
private void saveResultIterator(IResultIterator odiResult,int groupLevel,int[] subQueryInfo) throws DataException {
  try {
    OutputStream streamForDataSet=null;
    OutputStream streamForResultClass=null;
    OutputStream streamForGroupInfo=null;
    OutputStream streamForRowIndexInfo=null;
    OutputStream streamForParentIndexInfo=null;
    boolean isSubQuery=streamManager.isSubquery();
    if (streamManager.isSecondRD() == false) {
      if (context.getMode() == DataEngineContext.MODE_GENERATION && isSubQuery == false) {
        streamForResultClass=streamManager.getOutStream(DataEngineContext.DATASET_META_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE);
        streamForDataSet=streamManager.getOutStream(DataEngineContext.DATASET_DATA_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE);
      }
    }
 else {
      streamForRowIndexInfo=streamManager.getOutStream(DataEngineContext.ROW_INDEX_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE);
      if (context.getMode() == DataEngineContext.MODE_UPDATE && isSubQuery == true)       streamForParentIndexInfo=streamManager.getOutStream(DataEngineContext.SUBQUERY_PARENTINDEX_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE);
    }
    streamForGroupInfo=streamManager.getOutStream(DataEngineContext.GROUP_INFO_STREAM,StreamManager.ROOT_STREAM,StreamManager.SELF_SCOPE);
    odiResult.doSave(new StreamWrapper(streamForResultClass,streamForDataSet,streamForGroupInfo,streamForRowIndexInfo,streamForParentIndexInfo),isSubQuery,RDSave.this.exprNameSet);
    if (streamForResultClass != null)     streamForResultClass.close();
    if (streamForGroupInfo != null)     streamForGroupInfo.close();
    if (streamForRowIndexInfo != null)     streamForRowIndexInfo.close();
    if (streamForDataSet != null)     streamForDataSet.close();
    if (streamForParentIndexInfo != null)     streamForParentIndexInfo.close();
    if (isSubQuery == true && streamManager.hasOutStream(DataEngineContext.SUBQUERY_INFO_STREAM,StreamManager.SUB_QUERY_ROOT_STREAM,StreamManager.SELF_SCOPE) == false) {
      OutputStream streamForSubQuery=streamManager.getOutStream(DataEngineContext.SUBQUERY_INFO_STREAM,StreamManager.SUB_QUERY_ROOT_STREAM,StreamManager.SELF_SCOPE);
      RDSubQueryUtil.doSave(streamForSubQuery,groupLevel,subQueryInfo);
      streamForSubQuery.close();
    }
  }
 catch (  IOException e) {
    throw new DataException(ResourceConstants.RD_SAVE_ERROR,e,"String_Node_Str");
  }
}