Program: 55188
Project: 55188
Buggy source:
/** 
 * Calls the <code>MatchStub#match()</code> method for all two key-value pairs that share the same key and come  from different inputs. The output of the <code>match()</code> method is forwarded. <p> This method first zig-zags between the two sorted inputs in order to find a common key, and then calls the match stub with the cross product of the values.
 * @throws Exception Forwards all exceptions from the user code and the I/O system.
 * @see eu.stratosphere.pact.runtime.task.util.MatchTaskIterator#callWithNextKey()
 */
@Override public boolean callWithNextKey(final GenericMatcher<T1,T2,O> matchFunction,final Collector<O> collector) throws Exception {
  if (!this.iterator1.nextKey() || !this.iterator2.nextKey()) {
    return false;
  }
  final TypePairComparator<T1,T2> comparator=this.comp;
  comparator.setReference(this.iterator1.getCurrent());
  T2 current2=this.iterator2.getCurrent();
  while (true) {
    final int comp=comparator.compareToReference(current2);
    if (comp == 0)     break;
    if (comp < 0) {
      if (!this.iterator2.nextKey()) {
        return false;
      }
      current2=this.iterator2.getCurrent();
    }
 else {
      if (!this.iterator1.nextKey()) {
        return false;
      }
      comparator.setReference(this.iterator1.getCurrent());
    }
  }
  final KeyGroupedIterator<T1>.ValuesIterator values1=this.iterator1.getValues();
  final KeyGroupedIterator<T2>.ValuesIterator values2=this.iterator2.getValues();
  final T1 firstV1=values1.next();
  final T2 firstV2=values2.next();
  final boolean v1HasNext=values1.hasNext();
  final boolean v2HasNext=values2.hasNext();
  if (v1HasNext) {
    if (v2HasNext) {
      crossMwithNValues(firstV1,values1,firstV2,values2,matchFunction,collector);
    }
 else {
      crossSecond1withNValues(firstV2,firstV1,values1,matchFunction,collector);
    }
  }
 else {
    if (v2HasNext) {
      crossFirst1withNValues(firstV1,firstV2,values2,matchFunction,collector);
    }
 else {
      matchFunction.match(firstV1,firstV2,collector);
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Calls the <code>MatchStub#match()</code> method for all two key-value pairs that share the same key and come  from different inputs. The output of the <code>match()</code> method is forwarded. <p> This method first zig-zags between the two sorted inputs in order to find a common key, and then calls the match stub with the cross product of the values.
 * @throws Exception Forwards all exceptions from the user code and the I/O system.
 * @see eu.stratosphere.pact.runtime.task.util.MatchTaskIterator#callWithNextKey()
 */
@Override public boolean callWithNextKey(final GenericMatcher<T1,T2,O> matchFunction,final Collector<O> collector) throws Exception {
  if (!this.iterator1.nextKey() || !this.iterator2.nextKey()) {
    while (this.iterator1.nextKey())     ;
    while (this.iterator2.nextKey())     ;
    return false;
  }
  final TypePairComparator<T1,T2> comparator=this.comp;
  comparator.setReference(this.iterator1.getCurrent());
  T2 current2=this.iterator2.getCurrent();
  while (true) {
    final int comp=comparator.compareToReference(current2);
    if (comp == 0)     break;
    if (comp < 0) {
      if (!this.iterator2.nextKey()) {
        return false;
      }
      current2=this.iterator2.getCurrent();
    }
 else {
      if (!this.iterator1.nextKey()) {
        return false;
      }
      comparator.setReference(this.iterator1.getCurrent());
    }
  }
  final KeyGroupedIterator<T1>.ValuesIterator values1=this.iterator1.getValues();
  final KeyGroupedIterator<T2>.ValuesIterator values2=this.iterator2.getValues();
  final T1 firstV1=values1.next();
  final T2 firstV2=values2.next();
  final boolean v1HasNext=values1.hasNext();
  final boolean v2HasNext=values2.hasNext();
  if (v1HasNext) {
    if (v2HasNext) {
      crossMwithNValues(firstV1,values1,firstV2,values2,matchFunction,collector);
    }
 else {
      crossSecond1withNValues(firstV2,firstV1,values1,matchFunction,collector);
    }
  }
 else {
    if (v2HasNext) {
      crossFirst1withNValues(firstV1,firstV2,values2,matchFunction,collector);
    }
 else {
      matchFunction.match(firstV1,firstV2,collector);
    }
  }
  return true;
}