Program: 67284
Project: 67284
Buggy source:
/** 
 * @param factTableName
 * @param iterator
 * @param dimensions
 * @param measureColumnName
 * @param stopSign
 * @return
 * @throws BirtException
 * @throws IOException
 */
public FactTable saveFactTable(String factTableName,String[][] factTableJointColumnNames,String[][] DimJointColumnNames,IDatasetIterator iterator,Dimension[] dimensions,String[] measureColumnName,StopSign stopSign) throws BirtException, IOException {
  DiskSortedStack sortedFactTableRows=getSortedFactTableRows(iterator,factTableJointColumnNames,measureColumnName,stopSign);
  int segmentCount=getSegmentCount(sortedFactTableRows.size());
  DimensionInfo[] dimensionInfo=getDimensionInfo(dimensions);
  MeasureInfo[] measureInfo=getMeasureInfo(iterator,measureColumnName);
  saveFactTableMetadata(factTableName,dimensionInfo,measureInfo,segmentCount);
  DimensionDivision[] subDimensions=calculateDimensionDivision(getDimensionMemberCount(dimensions),segmentCount);
  int[][][] columnIndex=getColumnIndex(DimJointColumnNames,dimensions);
  DimensionPositionSeeker[] dimensionSeekers=new DimensionPositionSeeker[dimensions.length];
  for (int i=0; i < dimensionSeekers.length; i++) {
    dimensionSeekers[i]=new DimensionPositionSeeker(getDimCombinatedKey(columnIndex[i],dimensions[i].getAllRows(stopSign)));
  }
  FactTableRow currentRow=null;
  FactTableRow lastRow=null;
  int[] dimensionPosition=new int[dimensions.length];
  DocumentObjectCache documentObjectManager=new DocumentObjectCache(documentManager);
  CombinedPositionContructor combinedPositionCalculator=new CombinedPositionContructor(subDimensions);
  FTSUNameSaveHelper saveHelper=new FTSUNameSaveHelper(documentManager,factTableName);
  Object popObject=sortedFactTableRows.pop();
  while (popObject != null && !stopSign.isStopped()) {
    currentRow=(FactTableRow)popObject;
    if (lastRow != null && currentRow.equals(lastRow)) {
      throw new DataException(ResourceConstants.FACTTABLE_ROW_NOT_DISTINCT,currentRow.toString());
    }
    for (int i=0; i < dimensionPosition.length; i++) {
      dimensionPosition[i]=dimensionSeekers[i].find(currentRow.getDimensionKeys()[i]);
      if (dimensionPosition[i] < 0) {
        String[] args=new String[4];
        args[0]=factTableName;
        args[1]=Arrays.toString(factTableJointColumnNames[i]);
        args[2]=currentRow.getDimensionKeys()[i].toString();
        args[3]=dimensions[i].getName();
        throw new DataException(ResourceConstants.INVALID_DIMENSIONPOSITION_OF_FACTTABLEROW,args);
      }
    }
    int[] subDimensionIndex=getSubDimensionIndex(dimensionPosition,subDimensions);
    String FTSUDocName=FTSUDocumentObjectNamingUtil.getDocumentObjectName(NamingUtil.getFactTableName(factTableName),subDimensionIndex);
    saveHelper.add(FTSUDocName);
    IDocumentObject documentObject=documentObjectManager.getIDocumentObject(FTSUDocName);
    documentObject.writeBytes(new Bytes(combinedPositionCalculator.calculateCombinedPosition(subDimensionIndex,dimensionPosition).toByteArray()));
    for (int i=0; i < measureInfo.length; i++) {
      DocumentObjectUtil.writeValue(documentObject,measureInfo[i].getDataType(),currentRow.getMeasures()[i]);
    }
    popObject=sortedFactTableRows.pop();
    lastRow=currentRow;
  }
  saveHelper.save();
  documentObjectManager.closeAll();
  documentManager.flush();
  return new FactTable(factTableName,documentManager,dimensionInfo,measureInfo,segmentCount,subDimensions);
}

Fixed version (ground truth):
/** 
 * @param factTableName
 * @param iterator
 * @param dimensions
 * @param measureColumnName
 * @param stopSign
 * @return
 * @throws BirtException
 * @throws IOException
 */
public FactTable saveFactTable(String factTableName,String[][] factTableJointColumnNames,String[][] DimJointColumnNames,IDatasetIterator iterator,Dimension[] dimensions,String[] measureColumnName,StopSign stopSign,boolean suppressInvalidFacttableRow) throws BirtException, IOException {
  DiskSortedStack sortedFactTableRows=getSortedFactTableRows(iterator,factTableJointColumnNames,measureColumnName,stopSign);
  int segmentCount=getSegmentCount(sortedFactTableRows.size());
  DimensionInfo[] dimensionInfo=getDimensionInfo(dimensions);
  MeasureInfo[] measureInfo=getMeasureInfo(iterator,measureColumnName);
  saveFactTableMetadata(factTableName,dimensionInfo,measureInfo,segmentCount);
  DimensionDivision[] subDimensions=calculateDimensionDivision(getDimensionMemberCount(dimensions),segmentCount);
  int[][][] columnIndex=getColumnIndex(DimJointColumnNames,dimensions);
  DimensionPositionSeeker[] dimensionSeekers=new DimensionPositionSeeker[dimensions.length];
  for (int i=0; i < dimensionSeekers.length; i++) {
    dimensionSeekers[i]=new DimensionPositionSeeker(getDimCombinatedKey(columnIndex[i],dimensions[i].getAllRows(stopSign)));
  }
  FactTableRow currentRow=null;
  FactTableRow lastRow=null;
  int[] dimensionPosition=new int[dimensions.length];
  DocumentObjectCache documentObjectManager=new DocumentObjectCache(documentManager);
  CombinedPositionContructor combinedPositionCalculator=new CombinedPositionContructor(subDimensions);
  FTSUNameSaveHelper saveHelper=new FTSUNameSaveHelper(documentManager,factTableName);
  Object popObject=sortedFactTableRows.pop();
  start:   while (popObject != null && !stopSign.isStopped()) {
    currentRow=(FactTableRow)popObject;
    if (lastRow != null && currentRow.equals(lastRow)) {
      throw new DataException(ResourceConstants.FACTTABLE_ROW_NOT_DISTINCT,currentRow.toString());
    }
    for (int i=0; i < dimensionPosition.length; i++) {
      dimensionPosition[i]=dimensionSeekers[i].find(currentRow.getDimensionKeys()[i]);
      if (dimensionPosition[i] < 0) {
        if (suppressInvalidFacttableRow) {
          popObject=sortedFactTableRows.pop();
          lastRow=currentRow;
          continue start;
        }
        String[] args=new String[4];
        args[0]=factTableName;
        args[1]=Arrays.toString(factTableJointColumnNames[i]);
        args[2]=currentRow.getDimensionKeys()[i].toString();
        args[3]=dimensions[i].getName();
        throw new DataException(ResourceConstants.INVALID_DIMENSIONPOSITION_OF_FACTTABLEROW,args);
      }
    }
    int[] subDimensionIndex=getSubDimensionIndex(dimensionPosition,subDimensions);
    String FTSUDocName=FTSUDocumentObjectNamingUtil.getDocumentObjectName(NamingUtil.getFactTableName(factTableName),subDimensionIndex);
    saveHelper.add(FTSUDocName);
    IDocumentObject documentObject=documentObjectManager.getIDocumentObject(FTSUDocName);
    documentObject.writeBytes(new Bytes(combinedPositionCalculator.calculateCombinedPosition(subDimensionIndex,dimensionPosition).toByteArray()));
    for (int i=0; i < measureInfo.length; i++) {
      DocumentObjectUtil.writeValue(documentObject,measureInfo[i].getDataType(),currentRow.getMeasures()[i]);
    }
    popObject=sortedFactTableRows.pop();
    lastRow=currentRow;
  }
  saveHelper.save();
  documentObjectManager.closeAll();
  documentManager.flush();
  return new FactTable(factTableName,documentManager,dimensionInfo,measureInfo,segmentCount,subDimensions);
}