Program: 86832
Project: 86832
Buggy source:
/** 
 * Recursively traverse the List<Object> phrase to produce a (possibly nested) CompoundCohortDefinition If another List<Object> is found in the list, recursively evaluate it in place If anything in this list is a key into searches, replace it with the relevant filter from searches
 * @param phrase
 * @param searches
 * @param context
 * @return Cohort
 */
@SuppressWarnings("String_Node_Str") public static Cohort evaluate(List<Object> phrase,CompositionCohortDefinition composition,EvaluationContext context){
  log.debug("String_Node_Str" + phrase);
  List<Object> use=new ArrayList<Object>();
  for (  Object o : phrase) {
    if (o instanceof List) {
      use.add(evaluate((List<Object>)o,composition,context));
    }
 else     if (o instanceof String) {
      use.add(composition.getSearches().get((String)o));
    }
 else     if (o instanceof Integer) {
      use.add(composition.getSearches().get(o.toString()));
    }
 else {
      use.add(o);
    }
  }
  log.debug("String_Node_Str" + use);
  boolean invertTheNext=false;
  for (ListIterator<Object> i=use.listIterator(); i.hasNext(); ) {
    Object o=i.next();
    if (o instanceof BooleanOperator) {
      if ((BooleanOperator)o == BooleanOperator.NOT) {
        i.remove();
        invertTheNext=!invertTheNext;
      }
 else {
        if (invertTheNext)         throw new RuntimeException("String_Node_Str");
      }
    }
 else {
      if (invertTheNext) {
        i.set(InverseCohortDefinition.invert((Mapped<CohortDefinition>)o));
        invertTheNext=false;
      }
    }
  }
  log.debug("String_Node_Str" + use);
  if (use.size() == 1) {
    return Context.getService(CohortDefinitionService.class).evaluate((Mapped<CohortDefinition>)use.get(0),context);
  }
  BooleanOperator bo=BooleanOperator.AND;
  List<Cohort> args=new ArrayList<Cohort>();
  for (  Object o : use) {
    if (o instanceof BooleanOperator) {
      bo=(BooleanOperator)o;
    }
 else {
      args.add(Context.getService(CohortDefinitionService.class).evaluate((Mapped<CohortDefinition>)o,context));
    }
  }
  Cohort ret=null;
  for (  Cohort cohort : args) {
    if (ret == null) {
      ret=cohort;
    }
 else     if (bo == BooleanOperator.AND) {
      ret=Cohort.intersect(ret,cohort);
    }
 else {
      ret=Cohort.union(ret,cohort);
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Recursively traverse the List<Object> phrase to produce a (possibly nested) CompoundCohortDefinition If another List<Object> is found in the list, recursively evaluate it in place If anything in this list is a key into searches, replace it with the relevant filter from searches
 * @param phrase
 * @param searches
 * @param context
 * @return Cohort
 */
@SuppressWarnings("String_Node_Str") public static Cohort evaluate(List<Object> phrase,CompositionCohortDefinition composition,EvaluationContext context){
  log.debug("String_Node_Str" + phrase);
  List<Object> use=new ArrayList<Object>();
  for (  Object o : phrase) {
    if (o instanceof List) {
      use.add(evaluate((List<Object>)o,composition,context));
    }
 else     if (o instanceof String) {
      use.add(composition.getSearches().get((String)o));
    }
 else     if (o instanceof Integer) {
      use.add(composition.getSearches().get(o.toString()));
    }
 else {
      use.add(o);
    }
  }
  log.debug("String_Node_Str" + use);
  boolean invertTheNext=false;
  for (ListIterator<Object> i=use.listIterator(); i.hasNext(); ) {
    Object o=i.next();
    if (o instanceof BooleanOperator) {
      if ((BooleanOperator)o == BooleanOperator.NOT) {
        i.remove();
        invertTheNext=!invertTheNext;
      }
 else {
        if (invertTheNext)         throw new RuntimeException("String_Node_Str");
      }
    }
 else {
      if (invertTheNext) {
        i.set(InverseCohortDefinition.invert((Mapped<CohortDefinition>)o));
        invertTheNext=false;
      }
    }
  }
  log.debug("String_Node_Str" + use);
  if (use.size() == 1) {
    return Context.getService(CohortDefinitionService.class).evaluate((Mapped<CohortDefinition>)use.get(0),context);
  }
  BooleanOperator bo=BooleanOperator.AND;
  List<Cohort> args=new ArrayList<Cohort>();
  for (  Object o : use) {
    if (o instanceof BooleanOperator) {
      bo=(BooleanOperator)o;
    }
 else     if (o instanceof Cohort) {
      args.add((Cohort)o);
    }
 else {
      args.add(Context.getService(CohortDefinitionService.class).evaluate((Mapped<CohortDefinition>)o,context));
    }
  }
  Cohort ret=null;
  for (  Cohort cohort : args) {
    if (ret == null) {
      ret=cohort;
    }
 else     if (bo == BooleanOperator.AND) {
      ret=Cohort.intersect(ret,cohort);
    }
 else {
      ret=Cohort.union(ret,cohort);
    }
  }
  return ret;
}