Program: 51375
Project: 51375
Buggy source:
RolapResult(Query query,boolean execute){
  super(query,new Axis[query.axes.length]);
  this.point=CellKey.Generator.newCellKey(query.axes.length);
  final int expDeps=MondrianProperties.instance().TestExpDependencies.get();
  if (expDeps > 0) {
    this.evaluator=new RolapDependencyTestingEvaluator(this,expDeps);
  }
 else {
    final RolapEvaluator.RolapEvaluatorRoot root=new RolapResultEvaluatorRoot(this);
    this.evaluator=new RolapEvaluator(root);
  }
  RolapCube rcube=(RolapCube)query.getCube();
  this.batchingReader=new FastBatchingCellReader(rcube);
  this.cellInfos=(query.axes.length > 4) ? new CellInfoMap(point) : new CellInfoPool(query.axes.length);
  if (!execute) {
    return;
  }
  boolean normalExecution=true;
  try {
    rcube.clearCachedAggregations(false);
    rcube.checkAggregateModifications();
    final AxisMember axisMembers=new AxisMember();
    final List<Member> nonDefaultAllMembers=new ArrayList<Member>();
    List<Member[]> nonAllMembers=new ArrayList<Member[]>();
    final List<Member> measureMembers=new ArrayList<Member>();
    loadSpecialMembers(nonDefaultAllMembers,nonAllMembers,measureMembers);
    query.clearEvalCache();
    query.putEvalCache("String_Node_Str",nonDefaultAllMembers);
    final List<Member[]> emptyNonAllMembers=Collections.emptyList();
    axisMembers.setSlicer(true);
    loadMembers(emptyNonAllMembers,evaluator,query.slicerAxis,query.slicerCalc,axisMembers);
    axisMembers.setSlicer(false);
    if (!axisMembers.isEmpty()) {
      for (      Member m : axisMembers) {
        evaluator.setSlicerContext(m);
        if (m.isMeasure()) {
          measureMembers.clear();
        }
      }
      replaceNonAllMembers(nonAllMembers,axisMembers);
      axisMembers.clearMembers();
    }
    boolean changed=false;
    axisMembers.clearTotalCellCount();
    for (int i=0; i < axes.length; i++) {
      final QueryAxis axis=query.axes[i];
      final Calc calc=query.axisCalcs[i];
      loadMembers(emptyNonAllMembers,evaluator,axis,calc,axisMembers);
    }
    if (!axisMembers.isEmpty()) {
      for (      Member m : axisMembers) {
        if (m.isMeasure()) {
          measureMembers.clear();
        }
      }
      changed=replaceNonAllMembers(nonAllMembers,axisMembers);
      axisMembers.clearMembers();
    }
    if (changed) {
      axisMembers.countOnly(true);
      axisMembers.clearTotalCellCount();
      for (int i=0; i < axes.length; i++) {
        final QueryAxis axis=query.axes[i];
        final Calc calc=query.axisCalcs[i];
        loadMembers(nonAllMembers,(RolapEvaluator)evaluator.push(),axis,calc,axisMembers);
      }
    }
    axisMembers.checkLimit();
    this.slicerAxis=evalExecute(nonAllMembers,nonAllMembers.size() - 1,(RolapEvaluator)evaluator.push(),query.slicerAxis,query.slicerCalc);
switch (this.slicerAxis.getPositions().size()) {
case 0:
      throw MondrianResource.instance().EmptySlicer.ex();
case 1:
    break;
default :
  throw MondrianResource.instance().CompoundSlicer.ex();
}
boolean redo=true;
while (redo) {
RolapEvaluator e=(RolapEvaluator)evaluator.push();
redo=false;
for (int i=0; i < axes.length; i++) {
  QueryAxis axis=query.axes[i];
  final Calc calc=query.axisCalcs[i];
  Axis axisResult=evalExecute(nonAllMembers,nonAllMembers.size() - 1,e,axis,calc);
  if (!nonAllMembers.isEmpty()) {
    List<Position> pl=axisResult.getPositions();
    for (    Position p : pl) {
      for (      Member m : p) {
        if (m.isCalculated()) {
          CalculatedMeasureVisitor visitor=new CalculatedMeasureVisitor();
          m.getExpression().accept(visitor);
          Dimension dimension=visitor.dimension;
          redo=removeDimension(dimension,nonAllMembers);
        }
      }
      break;
    }
  }
  this.axes[i]=axisResult;
}
}
executeBody(query);
if (this.cellInfos.size() > 10000) {
this.cellInfos.trimToSize();
}
}
 catch (ResultLimitExceededException ex) {
normalExecution=false;
evaluator=null;
cellInfos=null;
batchingReader=null;
for (int i=0; i < axes.length; i++) {
axes[i]=null;
}
slicerAxis=null;
query.clearEvalCache();
throw ex;
}
 finally {
if (normalExecution) {
rcube.pushAggregateModificationsToGlobalCache();
evaluator.clearExpResultCache(true);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("String_Node_Str" + Util.printMemory());
}
}
}

Fixed version (ground truth):
RolapResult(Query query,boolean execute){
  super(query,new Axis[query.axes.length]);
  this.point=CellKey.Generator.newCellKey(query.axes.length);
  final int expDeps=MondrianProperties.instance().TestExpDependencies.get();
  if (expDeps > 0) {
    this.evaluator=new RolapDependencyTestingEvaluator(this,expDeps);
  }
 else {
    final RolapEvaluator.RolapEvaluatorRoot root=new RolapResultEvaluatorRoot(this);
    this.evaluator=new RolapEvaluator(root);
  }
  RolapCube rcube=(RolapCube)query.getCube();
  this.batchingReader=new FastBatchingCellReader(rcube);
  this.cellInfos=(query.axes.length > 4) ? new CellInfoMap(point) : new CellInfoPool(query.axes.length);
  if (!execute) {
    return;
  }
  boolean normalExecution=true;
  try {
    rcube.clearCachedAggregations();
    rcube.checkAggregateModifications();
    final AxisMember axisMembers=new AxisMember();
    final List<Member> nonDefaultAllMembers=new ArrayList<Member>();
    List<Member[]> nonAllMembers=new ArrayList<Member[]>();
    final List<Member> measureMembers=new ArrayList<Member>();
    loadSpecialMembers(nonDefaultAllMembers,nonAllMembers,measureMembers);
    query.clearEvalCache();
    query.putEvalCache("String_Node_Str",nonDefaultAllMembers);
    final List<Member[]> emptyNonAllMembers=Collections.emptyList();
    axisMembers.setSlicer(true);
    loadMembers(emptyNonAllMembers,evaluator,query.slicerAxis,query.slicerCalc,axisMembers);
    axisMembers.setSlicer(false);
    if (!axisMembers.isEmpty()) {
      for (      Member m : axisMembers) {
        evaluator.setSlicerContext(m);
        if (m.isMeasure()) {
          measureMembers.clear();
        }
      }
      replaceNonAllMembers(nonAllMembers,axisMembers);
      axisMembers.clearMembers();
    }
    boolean changed=false;
    axisMembers.clearTotalCellCount();
    for (int i=0; i < axes.length; i++) {
      final QueryAxis axis=query.axes[i];
      final Calc calc=query.axisCalcs[i];
      loadMembers(emptyNonAllMembers,evaluator,axis,calc,axisMembers);
    }
    if (!axisMembers.isEmpty()) {
      for (      Member m : axisMembers) {
        if (m.isMeasure()) {
          measureMembers.clear();
        }
      }
      changed=replaceNonAllMembers(nonAllMembers,axisMembers);
      axisMembers.clearMembers();
    }
    if (changed) {
      axisMembers.countOnly(true);
      axisMembers.clearTotalCellCount();
      for (int i=0; i < axes.length; i++) {
        final QueryAxis axis=query.axes[i];
        final Calc calc=query.axisCalcs[i];
        loadMembers(nonAllMembers,(RolapEvaluator)evaluator.push(),axis,calc,axisMembers);
      }
    }
    axisMembers.checkLimit();
    this.slicerAxis=evalExecute(nonAllMembers,nonAllMembers.size() - 1,(RolapEvaluator)evaluator.push(),query.slicerAxis,query.slicerCalc);
switch (this.slicerAxis.getPositions().size()) {
case 0:
      throw MondrianResource.instance().EmptySlicer.ex();
case 1:
    break;
default :
  throw MondrianResource.instance().CompoundSlicer.ex();
}
boolean redo=true;
while (redo) {
RolapEvaluator e=(RolapEvaluator)evaluator.push();
redo=false;
for (int i=0; i < axes.length; i++) {
  QueryAxis axis=query.axes[i];
  final Calc calc=query.axisCalcs[i];
  Axis axisResult=evalExecute(nonAllMembers,nonAllMembers.size() - 1,e,axis,calc);
  if (!nonAllMembers.isEmpty()) {
    List<Position> pl=axisResult.getPositions();
    for (    Position p : pl) {
      for (      Member m : p) {
        if (m.isCalculated()) {
          CalculatedMeasureVisitor visitor=new CalculatedMeasureVisitor();
          m.getExpression().accept(visitor);
          Dimension dimension=visitor.dimension;
          redo=removeDimension(dimension,nonAllMembers);
        }
      }
      break;
    }
  }
  this.axes[i]=axisResult;
}
}
executeBody(query);
if (this.cellInfos.size() > 10000) {
this.cellInfos.trimToSize();
}
}
 catch (ResultLimitExceededException ex) {
normalExecution=false;
evaluator=null;
cellInfos=null;
batchingReader=null;
for (int i=0; i < axes.length; i++) {
axes[i]=null;
}
slicerAxis=null;
query.clearEvalCache();
throw ex;
}
 finally {
if (normalExecution) {
rcube.pushAggregateModificationsToGlobalCache();
evaluator.clearExpResultCache(true);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("String_Node_Str" + Util.printMemory());
}
}
}