Program: 73977
Project: 73977
Buggy source:
private void validateSingleMeasureDetail(MeasureViewHandle measureView,LevelViewHandle rowLevelView,LevelViewHandle colLevelView) throws SemanticException {
  AggregationCellHandle detailCell=measureView.getCell();
  LevelHandle rowLevel=detailCell.getAggregationOnRow();
  LevelHandle colLevel=detailCell.getAggregationOnColumn();
  if (rowLevelView == null) {
    detailCell.setAggregationOnRow(null);
  }
 else   if (rowLevel == null || !rowLevel.equals(rowLevelView.getCubeLevel())) {
    detailCell.setAggregationOnRow(rowLevelView.getCubeLevel());
  }
  if (colLevelView == null) {
    detailCell.setAggregationOnColumn(null);
  }
 else   if (colLevel == null || !colLevel.equals(colLevelView.getCubeLevel())) {
    detailCell.setAggregationOnColumn(colLevelView.getCubeLevel());
  }
  rowLevel=detailCell.getAggregationOnRow();
  colLevel=detailCell.getAggregationOnColumn();
  String aggregateRowName=rowLevel == null ? null : rowLevel.getQualifiedName();
  String aggregateColumnName=colLevel == null ? null : colLevel.getQualifiedName();
  if (detailCell.getContents().size() == 0 || (detailCell.getContents().size() == 1 && detailCell.getContents().get(0) instanceof DataItemHandle)) {
    String name=CrosstabModelUtil.generateComputedColumnName(measureView,aggregateColumnName,aggregateRowName);
    ComputedColumn column=StructureFactory.newComputedColumn(crosstab.getModelHandle(),name);
    String dataType=measureView.getDataType();
    column.setDataType(dataType);
    column.setExpression(ExpressionUtil.createJSMeasureExpression(measureView.getCubeMeasureName()));
    String measureFunc=measureView.getCubeMeasure() == null ? DEFAULT_MEASURE_FUNCTION : measureView.getCubeMeasure().getFunction();
    column.setAggregateFunction(CrosstabModelUtil.getRollUpAggregationFunction(measureFunc));
    if (aggregateRowName != null) {
      column.addAggregateOn(aggregateRowName);
    }
    if (aggregateColumnName != null) {
      column.addAggregateOn(aggregateColumnName);
    }
    ComputedColumnHandle columnHandle=((ReportItemHandle)crosstab.getModelHandle()).addColumnBinding(column,false);
    DataItemHandle dataItem;
    if (detailCell.getContents().size() == 0) {
      dataItem=crosstab.getModuleHandle().getElementFactory().newDataItem(null);
      dataItem.setResultSetColumn(columnHandle.getName());
      detailCell.addContent(dataItem);
    }
 else {
      dataItem=(DataItemHandle)detailCell.getContents().get(0);
      dataItem.setResultSetColumn(columnHandle.getName());
    }
  }
}

Fixed version (ground truth):
private void validateSingleMeasureDetail(MeasureViewHandle measureView,LevelViewHandle rowLevelView,LevelViewHandle colLevelView) throws SemanticException {
  AggregationCellHandle detailCell=measureView.getCell();
  LevelHandle rowLevel=detailCell.getAggregationOnRow();
  LevelHandle colLevel=detailCell.getAggregationOnColumn();
  if (rowLevelView == null) {
    detailCell.setAggregationOnRow(null);
  }
 else   if (rowLevel == null || !rowLevel.equals(rowLevelView.getCubeLevel())) {
    detailCell.setAggregationOnRow(rowLevelView.getCubeLevel());
  }
  if (colLevelView == null) {
    detailCell.setAggregationOnColumn(null);
  }
 else   if (colLevel == null || !colLevel.equals(colLevelView.getCubeLevel())) {
    detailCell.setAggregationOnColumn(colLevelView.getCubeLevel());
  }
  rowLevel=detailCell.getAggregationOnRow();
  colLevel=detailCell.getAggregationOnColumn();
  String aggregateRowName=rowLevel == null ? null : rowLevel.getQualifiedName();
  String aggregateColumnName=colLevel == null ? null : colLevel.getQualifiedName();
  if (detailCell.getContents().size() == 0 || (detailCell.getContents().size() == 1 && detailCell.getContents().get(0) instanceof DataItemHandle)) {
    String name=CrosstabModelUtil.generateComputedColumnName(measureView,aggregateColumnName,aggregateRowName);
    ComputedColumn column=StructureFactory.newComputedColumn(crosstab.getModelHandle(),name);
    String dataType=measureView.getDataType();
    column.setDataType(dataType);
    column.setExpression(ExpressionUtil.createJSMeasureExpression(measureView.getCubeMeasureName()));
    String measureFunc=CrosstabModelUtil.getAggregationFunction(crosstab,detailCell);
    if (measureFunc == null) {
      measureFunc=CrosstabModelUtil.getDefaultMeasureAggregationFunction(measureView);
    }
    column.setAggregateFunction(measureFunc);
    if (aggregateRowName != null) {
      column.addAggregateOn(aggregateRowName);
    }
    if (aggregateColumnName != null) {
      column.addAggregateOn(aggregateColumnName);
    }
    ComputedColumnHandle columnHandle=((ReportItemHandle)crosstab.getModelHandle()).addColumnBinding(column,false);
    DataItemHandle dataItem;
    if (detailCell.getContents().size() == 0) {
      dataItem=crosstab.getModuleHandle().getElementFactory().newDataItem(null);
      dataItem.setResultSetColumn(columnHandle.getName());
      detailCell.addContent(dataItem);
    }
 else {
      dataItem=(DataItemHandle)detailCell.getContents().get(0);
      dataItem.setResultSetColumn(columnHandle.getName());
    }
  }
}