Program: 69785
Project: 69785
Buggy source:
CrosstabCellHandle addGrandTotal(List<MeasureViewHandle> measureList,List<String> functionList,boolean needTransaction) throws SemanticException {
  if (!isValidParameters(functionList,measureList))   return null;
  verifyTotalMeasureFunctions(crosstabView.getAxisType(),functionList,measureList);
  PropertyHandle propHandle=crosstabView.getGrandTotalProperty();
  CommandStack stack=null;
  if (needTransaction) {
    stack=crosstabView.getCommandStack();
    stack.startTrans(Messages.getString("String_Node_Str"));
  }
  CrosstabCellHandle totalCell=null;
  try {
    ExtendedItemHandle grandTotal=null;
    if (propHandle.getContentCount() <= 0) {
      grandTotal=CrosstabExtendedItemFactory.createCrosstabCell(crosstabView.getModuleHandle());
      propHandle.add(grandTotal);
    }
    CrosstabReportItemHandle crosstab=crosstabView.getCrosstab();
    if (crosstab != null && measureList != null) {
      addMeasureAggregations(crosstabView.getAxisType(),measureList,functionList,false);
      addTotalMeasureHeader(crosstabView.getAxisType(),null,measureList);
    }
    validateCrosstab();
    totalCell=(CrosstabCellHandle)CrosstabUtil.getReportItem(grandTotal);
  }
 catch (  SemanticException e) {
    crosstabView.getLogger().log(Level.INFO,e.getMessage(),e);
    if (needTransaction) {
      stack.rollback();
    }
    throw e;
  }
  if (needTransaction) {
    stack.commit();
  }
  return totalCell;
}

Fixed version (ground truth):
CrosstabCellHandle addGrandTotal(List<MeasureViewHandle> measureList,List<String> functionList,boolean needTransaction) throws SemanticException {
  if (!isValidParameters(functionList,measureList))   return null;
  verifyTotalMeasureFunctions(crosstabView.getAxisType(),functionList,measureList);
  PropertyHandle propHandle=crosstabView.getGrandTotalProperty();
  CommandStack stack=null;
  if (needTransaction) {
    stack=crosstabView.getCommandStack();
    stack.startTrans(Messages.getString("String_Node_Str"));
  }
  CrosstabCellHandle totalCell=null;
  try {
    ExtendedItemHandle grandTotal=null;
    if (propHandle.getContentCount() <= 0) {
      grandTotal=CrosstabExtendedItemFactory.createCrosstabCell(crosstabView.getModuleHandle());
      propHandle.add(grandTotal);
    }
    CrosstabReportItemHandle crosstab=crosstabView.getCrosstab();
    if (crosstab != null && measureList != null) {
      boolean isVerticalMeasure=MEASURE_DIRECTION_VERTICAL.equals(crosstab.getMeasureDirection());
      boolean needCheckCounterAxis=((isVerticalMeasure && crosstabView.getAxisType() == COLUMN_AXIS_TYPE) || (!isVerticalMeasure && crosstabView.getAxisType() == ROW_AXIS_TYPE));
      addMeasureAggregations(crosstabView.getAxisType(),measureList,functionList,needCheckCounterAxis);
      addTotalMeasureHeader(crosstabView.getAxisType(),null,measureList);
    }
    validateCrosstab();
    totalCell=(CrosstabCellHandle)CrosstabUtil.getReportItem(grandTotal);
  }
 catch (  SemanticException e) {
    crosstabView.getLogger().log(Level.INFO,e.getMessage(),e);
    if (needTransaction) {
      stack.rollback();
    }
    throw e;
  }
  if (needTransaction) {
    stack.commit();
  }
  return totalCell;
}