Program: 75513
Project: 75513
Buggy source:
/** 
 * @param aggrComputedColumns
 * @throws DataException
 */
private void populateAggrCCs(List aggrComputedColumns) throws DataException {
  if (aggrComputedColumns.size() == 0)   return;
  ExpressionCompiler compiler=new ExpressionCompiler();
  compiler.setDataSetMode(true);
  try {
    Context cx=Context.enter();
    List aggrInfos=new ArrayList();
    List aggrNames=new ArrayList();
    for (int i=0; i < aggrComputedColumns.size(); i++) {
      ComputedColumn cc=(ComputedColumn)aggrComputedColumns.get(i);
      List args=cc.getAggregateArgument();
      IBaseExpression[] exprs=null;
      int offset=0;
      if (cc.getExpression() != null) {
        exprs=new IBaseExpression[args.size() + 1];
        offset=1;
        exprs[0]=cc.getExpression();
      }
 else       exprs=new IBaseExpression[args.size()];
      for (int j=offset; j < args.size(); j++) {
        exprs[j]=(IBaseExpression)args.get(j - offset);
      }
      for (int j=0; j < exprs.length; j++) {
        compiler.compile(exprs[j],cx);
      }
      IAggregation aggrFunction=AggregationFactory.getInstance().getAggregation(cc.getAggregateFunction());
      IAggrInfo aggrInfo=new AggrInfo(cc.getName(),0,aggrFunction,exprs,cc.getAggregateFilter());
      aggrInfos.add(aggrInfo);
      aggrNames.add(cc.getName());
    }
    if (!psController.needDoOperation(PassStatusController.DATA_SET_FILTERING))     PassUtil.pass(populator,new OdiResultSetWrapper(populator.getResultIterator()),false,this.session);
    AggregationHelper helper=new AggregationHelper(new AggrDefnManager(aggrInfos),this.populator);
    AggrComputedColumnHelper ccHelper=new AggrComputedColumnHelper(helper,aggrNames);
    this.populator.getQuery().getFetchEvents().add(0,ccHelper);
    PassUtil.pass(populator,new OdiResultSetWrapper(populator.getResultIterator()),false,this.session);
    this.populator.getQuery().getFetchEvents().remove(0);
  }
  finally {
    Context.exit();
  }
}

Fixed version (ground truth):
/** 
 * @param aggrComputedColumns
 * @throws DataException
 */
private void populateAggrCCs(List aggrComputedColumns) throws DataException {
  if (aggrComputedColumns.size() == 0)   return;
  ExpressionCompiler compiler=new ExpressionCompiler();
  compiler.setDataSetMode(true);
  try {
    Context cx=Context.enter();
    List aggrInfos=new ArrayList();
    List aggrNames=new ArrayList();
    for (int i=0; i < aggrComputedColumns.size(); i++) {
      ComputedColumn cc=(ComputedColumn)aggrComputedColumns.get(i);
      List args=cc.getAggregateArgument();
      IBaseExpression[] exprs=null;
      int offset=0;
      if (cc.getExpression() != null) {
        exprs=new IBaseExpression[args.size() + 1];
        offset=1;
        exprs[0]=cc.getExpression();
      }
 else       exprs=new IBaseExpression[args.size()];
      for (int j=offset; j < args.size() + offset; j++) {
        exprs[j]=(IBaseExpression)args.get(j - offset);
      }
      for (int j=0; j < exprs.length; j++) {
        compiler.compile(exprs[j],cx);
      }
      if (cc.getAggregateFilter() != null)       compiler.compile(cc.getAggregateFilter(),cx);
      IAggregation aggrFunction=AggregationFactory.getInstance().getAggregation(cc.getAggregateFunction());
      IAggrInfo aggrInfo=new AggrInfo(cc.getName(),0,aggrFunction,exprs,cc.getAggregateFilter());
      aggrInfos.add(aggrInfo);
      aggrNames.add(cc.getName());
    }
    if (!psController.needDoOperation(PassStatusController.DATA_SET_FILTERING))     PassUtil.pass(populator,new OdiResultSetWrapper(populator.getResultIterator()),false,this.session);
    AggregationHelper helper=new AggregationHelper(new AggrDefnManager(aggrInfos),this.populator);
    AggrComputedColumnHelper ccHelper=new AggrComputedColumnHelper(helper,aggrNames);
    this.populator.getQuery().getFetchEvents().add(0,ccHelper);
    PassUtil.pass(populator,new OdiResultSetWrapper(populator.getResultIterator()),false,this.session);
    this.populator.getQuery().getFetchEvents().remove(0);
  }
  finally {
    Context.exit();
  }
}