Program: 51385
Project: 51385
Buggy source:
/** 
 * This is a non-optimistic optimizer. What this means is that an element of the input parameter List is only not included in the returned result List if for no combination of Measures, non-All Members (for Hierarchies that have no All Members) and evaluator default Members did the element evaluate to non-null.
 * @param evaluator The Evaluator
 * @param list The List of elements that are to be determined if there areany non-null.
 * @param call The calling ResolvedFunCall used to determine what Measuresto use.
 * @return List of elements from the input parameter list that haveevaluated to non-null.
 */
protected List nonEmptyListNEW(Evaluator evaluator,List list,ResolvedFunCall call){
  if (list.isEmpty()) {
    return list;
  }
  List result=new ArrayList((list.size() + 2) >> 1);
  final Query query=evaluator.getQuery();
  final String measureSetKey="String_Node_Str" + ctag;
  Set<Member> measureSet=(Set<Member>)query.getEvalCache(measureSetKey);
  if (measureSet == null) {
    measureSet=new HashSet<Member>();
    Set<Member> queryMeasureSet=query.getMeasuresMembers();
    MeasureVisitorNEW visitor=new MeasureVisitorNEW(measureSet,call);
    for (    Member m : queryMeasureSet) {
      if (m.isCalculated()) {
        Exp exp=m.getExpression();
        exp.accept(visitor);
      }
 else {
        measureSet.add(m);
      }
    }
    Formula[] formula=query.getFormulas();
    if (formula != null) {
      for (      Formula f : formula) {
        f.accept(visitor);
      }
    }
    query.putEvalCache(measureSetKey,measureSet);
  }
  final String allMemberListKey="String_Node_Str" + ctag;
  List<Member> allMemberList=(List<Member>)query.getEvalCache(allMemberListKey);
  final String nonAllMembersKey="String_Node_Str" + ctag;
  Member[][] nonAllMembers=(Member[][])query.getEvalCache(nonAllMembersKey);
  if (nonAllMembers == null) {
    Member[] evalMembers=(Member[])evaluator.getMembers().clone();
    Member[] listMembers=(list.get(0) instanceof Member[]) ? (Member[])list.get(0) : new Member[]{(Member)list.get(0)};
    for (    Member lm : listMembers) {
      Hierarchy h=lm.getHierarchy();
      for (int i=0; i < evalMembers.length; i++) {
        Member em=evalMembers[i];
        if ((em != null) && h.equals(em.getHierarchy())) {
          evalMembers[i]=null;
        }
      }
    }
    SchemaReader schemaReader=evaluator.getSchemaReader();
    allMemberList=new ArrayList<Member>();
    List<Member[]> nonAllMemberList=new ArrayList<Member[]>();
    for (int i=0, j=0; i < evalMembers.length; i++) {
      Member em=evalMembers[i];
      if (em == null) {
        continue;
      }
      if (em.isMeasure()) {
        continue;
      }
      if (em.isCalculated()) {
        continue;
      }
      if (!em.isAll()) {
        Hierarchy h=em.getHierarchy();
        Member[] rootMembers=schemaReader.getHierarchyRootMembers(h);
        if (h.hasAll()) {
          boolean found=false;
          for (          Member m : rootMembers) {
            if (m.isAll()) {
              allMemberList.add(m);
              found=true;
              break;
            }
          }
          if (!found) {
            System.out.println("String_Node_Str");
          }
        }
 else {
          nonAllMemberList.add(rootMembers);
        }
      }
    }
    nonAllMembers=(Member[][])nonAllMemberList.toArray(new Member[0][]);
    query.putEvalCache(allMemberListKey,allMemberList);
    query.putEvalCache(nonAllMembersKey,nonAllMembers);
  }
  evaluator=evaluator.push();
  evaluator.setContext(allMemberList);
  if (list.get(0) instanceof Member[]) {
    for (    Member[] ms : ((List<Member[]>)list)) {
      evaluator.setContext(ms);
      if (checkData(nonAllMembers,nonAllMembers.length - 1,measureSet,evaluator)) {
        result.add(ms);
      }
    }
  }
 else {
    for (    Member m : ((List<Member>)list)) {
      evaluator.setContext(m);
      if (checkData(nonAllMembers,nonAllMembers.length - 1,measureSet,evaluator)) {
        result.add(m);
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * This is a non-optimistic optimizer. What this means is that an element of the input parameter List is only not included in the returned result List if for no combination of Measures, non-All Members (for Hierarchies that have no All Members) and evaluator default Members did the element evaluate to non-null.
 * @param evaluator The Evaluator
 * @param list The List of elements that are to be determined if there areany non-null.
 * @param call The calling ResolvedFunCall used to determine what Measuresto use.
 * @return List of elements from the input parameter list that haveevaluated to non-null.
 */
protected List nonEmptyListNEW(Evaluator evaluator,List list,ResolvedFunCall call){
  if (list.isEmpty()) {
    return list;
  }
  List result=new ArrayList((list.size() + 2) >> 1);
  final Query query=evaluator.getQuery();
  final String measureSetKey="String_Node_Str" + ctag;
  Set<Member> measureSet=(Set<Member>)query.getEvalCache(measureSetKey);
  if (measureSet == null) {
    measureSet=new HashSet<Member>();
    Set<Member> queryMeasureSet=query.getMeasuresMembers();
    MeasureVisitorNEW visitor=new MeasureVisitorNEW(measureSet,call);
    for (    Member m : queryMeasureSet) {
      if (m.isCalculated()) {
        Exp exp=m.getExpression();
        exp.accept(visitor);
      }
 else {
        measureSet.add(m);
      }
    }
    Formula[] formula=query.getFormulas();
    if (formula != null) {
      for (      Formula f : formula) {
        f.accept(visitor);
      }
    }
    query.putEvalCache(measureSetKey,measureSet);
  }
  final String allMemberListKey="String_Node_Str" + ctag;
  List<Member> allMemberList=(List<Member>)query.getEvalCache(allMemberListKey);
  final String nonAllMembersKey="String_Node_Str" + ctag;
  Member[][] nonAllMembers=(Member[][])query.getEvalCache(nonAllMembersKey);
  if (nonAllMembers == null) {
    Member[] evalMembers=(Member[])evaluator.getMembers().clone();
    Member[] listMembers=(list.get(0) instanceof Member[]) ? (Member[])list.get(0) : new Member[]{(Member)list.get(0)};
    for (    Member lm : listMembers) {
      Hierarchy h=lm.getHierarchy();
      for (int i=0; i < evalMembers.length; i++) {
        Member em=evalMembers[i];
        if ((em != null) && h.equals(em.getHierarchy())) {
          evalMembers[i]=null;
        }
      }
    }
    Set<Member> independentSlicerMembers=null;
    Set<Member> dependentSlicerMembers=null;
    if (evaluator instanceof RolapEvaluator) {
      RolapEvaluator rev=(RolapEvaluator)evaluator;
      independentSlicerMembers=new HashSet<Member>();
      dependentSlicerMembers=new HashSet<Member>();
      for (      Member m : rev.getSlicerMembers()) {
        boolean slicerFound=false;
        for (        Member lm : listMembers) {
          Hierarchy h=lm.getHierarchy();
          if (h.equals(m.getHierarchy())) {
            slicerFound=true;
            break;
          }
        }
        if (slicerFound) {
          independentSlicerMembers.add(m);
        }
 else {
          dependentSlicerMembers.add(m);
        }
      }
    }
    SchemaReader schemaReader=evaluator.getSchemaReader();
    allMemberList=new ArrayList<Member>();
    List<Member[]> nonAllMemberList=new ArrayList<Member[]>();
    Member em;
    boolean isIndependentSlicerMember=false;
    boolean isDependentSlicerMember=false;
    for (int i=0; i < evalMembers.length; i++) {
      em=evalMembers[i];
      if (independentSlicerMembers == null) {
        isIndependentSlicerMember=false;
      }
 else {
        isIndependentSlicerMember=independentSlicerMembers.contains(em);
      }
      if (dependentSlicerMembers == null) {
        isDependentSlicerMember=false;
      }
 else {
        isDependentSlicerMember=dependentSlicerMembers.contains(em);
      }
      if (em == null) {
        continue;
      }
      if (em.isMeasure()) {
        continue;
      }
      if (isDependentSlicerMember) {
        continue;
      }
      if (!em.isAll() || isIndependentSlicerMember) {
        Hierarchy h=em.getHierarchy();
        Member[] rootMembers=schemaReader.getHierarchyRootMembers(h);
        if (h.hasAll()) {
          boolean found=false;
          for (          Member m : rootMembers) {
            if (m.isAll()) {
              allMemberList.add(m);
              found=true;
              break;
            }
          }
          if (!found) {
            System.out.println("String_Node_Str");
          }
        }
 else {
          nonAllMemberList.add(rootMembers);
        }
      }
    }
    nonAllMembers=(Member[][])nonAllMemberList.toArray(new Member[0][]);
    query.putEvalCache(allMemberListKey,allMemberList);
    query.putEvalCache(nonAllMembersKey,nonAllMembers);
  }
  evaluator=evaluator.push();
  evaluator.setContext(allMemberList);
  if (list.get(0) instanceof Member[]) {
    for (    Member[] ms : ((List<Member[]>)list)) {
      evaluator.setContext(ms);
      if (checkData(nonAllMembers,nonAllMembers.length - 1,measureSet,evaluator)) {
        result.add(ms);
      }
    }
  }
 else {
    for (    Member m : ((List<Member>)list)) {
      evaluator.setContext(m);
      if (checkData(nonAllMembers,nonAllMembers.length - 1,measureSet,evaluator)) {
        result.add(m);
      }
    }
  }
  return result;
}