Program: 29412
Project: 29412
Buggy source:
/** 
 * The slices that occur in the context described by the given predicates. <p>The order is deterministic but does not necessarily bear any relationship to the order in which slices can appear in the template's output because it is dependent on the ordering of individual templates in the parsed input.
 * @param slicedRawTextNodes The sliced raw text nodes to search.
 * @param prevContextPredicate Applied to the context before the slice being tested.
 * @param sliceContextPredicate Applied to the context of the slice being tested.
 * @param nextContextPredicate Applied to the context after the slice being tested.
 * @return a list of slices such that input predicates are all true when applied to the contextsat and around that slice.
 */
public static List<RawTextSlice> find(Iterable<? extends SlicedRawTextNode> slicedTextNodes,@Nullable Predicate<? super Context> prevContextPredicate,@Nullable Predicate<? super Context> sliceContextPredicate,@Nullable Predicate<? super Context> nextContextPredicate){
  if (prevContextPredicate == null) {
    prevContextPredicate=Predicates.<Context>alwaysTrue();
  }
  if (sliceContextPredicate == null) {
    sliceContextPredicate=Predicates.<Context>alwaysTrue();
  }
  if (nextContextPredicate == null) {
    nextContextPredicate=Predicates.<Context>alwaysTrue();
  }
  ImmutableList.Builder<RawTextSlice> matches=ImmutableList.builder();
  for (  SlicedRawTextNode slicedTextNode : slicedTextNodes) {
    slicedTextNode.mergeAdjacentSlicesWithSameContext();
    Context prevContext=slicedTextNode.startContext;
    List<RawTextSlice> slices=slicedTextNode.slices;
    for (int i=0, n=slices.size(); i < n; ++i) {
      RawTextSlice current=slices.get(i);
      Context nextContext;
      if (i + 1 < n) {
        nextContext=slices.get(i + 1).context;
      }
 else {
        nextContext=slicedTextNode.endContext;
      }
      if (prevContextPredicate.apply(prevContext) && sliceContextPredicate.apply(current.context) && nextContextPredicate.apply(nextContext)) {
        matches.add(current);
      }
      prevContext=current.context;
    }
  }
  return matches.build();
}

Fixed version (ground truth):
/** 
 * The slices that occur in the context described by the given predicates. <p>The order is deterministic but does not necessarily bear any relationship to the order in which slices can appear in the template's output because it is dependent on the ordering of individual templates in the parsed input.
 * @param slicedTextNodes The sliced raw text nodes to search.
 * @param prevContextPredicate Applied to the context before the slice being tested.
 * @param sliceContextPredicate Applied to the context of the slice being tested.
 * @param nextContextPredicate Applied to the context after the slice being tested.
 * @return a list of slices such that input predicates are all true when applied to the contextsat and around that slice.
 */
public static List<RawTextSlice> find(Iterable<? extends SlicedRawTextNode> slicedTextNodes,@Nullable Predicate<? super Context> prevContextPredicate,@Nullable Predicate<? super Context> sliceContextPredicate,@Nullable Predicate<? super Context> nextContextPredicate){
  if (prevContextPredicate == null) {
    prevContextPredicate=Predicates.<Context>alwaysTrue();
  }
  if (sliceContextPredicate == null) {
    sliceContextPredicate=Predicates.<Context>alwaysTrue();
  }
  if (nextContextPredicate == null) {
    nextContextPredicate=Predicates.<Context>alwaysTrue();
  }
  ImmutableSet.Builder<RawTextSlice> matches=ImmutableSet.builder();
  for (  SlicedRawTextNode slicedTextNode : slicedTextNodes) {
    Context prevContext=slicedTextNode.startContext;
    List<RawTextSlice> slices=slicedTextNode.slices;
    for (int i=0, n=slices.size(); i < n; ++i) {
      RawTextSlice current=slices.get(i);
      Context nextContext;
      if (i + 1 < n) {
        nextContext=slices.get(i + 1).getContext();
      }
 else {
        nextContext=slicedTextNode.endContext;
      }
      if (prevContextPredicate.apply(prevContext) && sliceContextPredicate.apply(current.getContext()) && nextContextPredicate.apply(nextContext)) {
        matches.add(current);
      }
      prevContext=current.getContext();
    }
  }
  return matches.build().asList();
}