Program: 88248
Project: 88248
Buggy source:
/** 
 * Runs a streamed nested loop strategy to build the Cartesian product and call the <code>cross()</code> method of the CrossStub implementation. The outer side is read directly from the input reader. The inner side is read and reseted using a SpillingResettableIterator.
 * @see eu.stratosphere.pact.runtime.resettable.SpillingResettableIterator
 * @param memoryManager The task manager's memory manager.
 * @param ioManager The task manager's IO manager
 * @param innerReader The inner reader of the nested loops.
 * @param outerReader The outer reader of the nested loops.
 * @throws RuntimeException Throws a RuntimeException if something fails during execution.
 */
private void runStreamed(MemoryManager memoryManager,IOManager ioManager,RecordReader<KeyValuePair<Key,Value>> innerReader,final RecordReader<KeyValuePair<Key,Value>> outerReader) throws Exception {
  LastRepeatableIterator<KeyValuePair<Key,Value>> outerInput=new LastRepeatableIterator<KeyValuePair<Key,Value>>(){
    SerializationCopier<KeyValuePair<Key,Value>> copier=new SerializationCopier<KeyValuePair<Key,Value>>();
    KeyValuePairDeserializer<Key,Value> deserializer=new KeyValuePairDeserializer<Key,Value>(stub.getSecondInKeyType(),stub.getSecondInValueType());
    @Override public boolean hasNext(){
      return outerReader.hasNext();
    }
    @Override public KeyValuePair<Key,Value> next(){
      try {
        KeyValuePair<Key,Value> pair=outerReader.next();
        copier.setCopy(pair);
        return pair;
      }
 catch (      IOException e) {
        throw new RuntimeException(e);
      }
catch (      InterruptedException e) {
        throw new RuntimeException(e);
      }
    }
    @Override public void remove(){
      throw new UnsupportedOperationException();
    }
    @Override public KeyValuePair<Key,Value> repeatLast(){
      KeyValuePair<Key,Value> pair=deserializer.getInstance();
      copier.getCopy(pair);
      return pair;
    }
  }
;
  SpillingResettableIterator<KeyValuePair<Key,Value>> innerInput=null;
  try {
    try {
      innerInput=new SpillingResettableIterator<KeyValuePair<Key,Value>>(memoryManager,ioManager,innerReader,this.availableMemory,new KeyValuePairDeserializer<Key,Value>(stub.getFirstInKeyType(),stub.getFirstInValueType()),this);
      spillingResetIt=innerInput;
    }
 catch (    MemoryAllocationException mae) {
      throw new RuntimeException("String_Node_Str",mae);
    }
    try {
      innerInput.open();
    }
 catch (    ServiceException se) {
      throw new RuntimeException("String_Node_Str",se);
    }
catch (    IOException ioe) {
      throw new RuntimeException("String_Node_Str",ioe);
    }
catch (    InterruptedException ie) {
      throw new RuntimeException("String_Node_Str",ie);
    }
    if (this.taskCanceled)     return;
    LOG.debug("String_Node_Str" + this.getEnvironment().getTaskName() + "String_Node_Str"+ (this.getEnvironment().getIndexInSubtaskGroup() + 1)+ "String_Node_Str"+ this.getEnvironment().getCurrentNumberOfSubtasks()+ "String_Node_Str");
    stub.open();
    if (config.getLocalStrategy() == LocalStrategy.NESTEDLOOP_STREAMED_OUTER_SECOND) {
      while (!this.taskCanceled && outerInput.hasNext()) {
        Pair outerPair=outerInput.next();
        while (!this.taskCanceled && innerInput.hasNext()) {
          Pair innerPair=innerInput.next();
          stub.cross(innerPair.getKey(),innerPair.getValue(),outerPair.getKey(),outerPair.getValue(),output);
          outerPair=outerInput.repeatLast();
        }
        if (!this.taskCanceled && outerInput.hasNext()) {
          innerInput.reset();
        }
      }
    }
 else {
      while (!this.taskCanceled && outerInput.hasNext()) {
        Pair outerPair=outerInput.next();
        while (!this.taskCanceled && innerInput.hasNext()) {
          Pair innerPair=innerInput.next();
          stub.cross(outerPair.getKey(),outerPair.getValue(),innerPair.getKey(),innerPair.getValue(),output);
          outerPair=outerInput.repeatLast();
        }
        if (!this.taskCanceled && outerInput.hasNext()) {
          innerInput.reset();
        }
      }
    }
    stub.close();
  }
 catch (  Exception ex) {
    if (!this.taskCanceled) {
      LOG.error("String_Node_Str" + this.getEnvironment().getTaskName() + "String_Node_Str"+ (this.getEnvironment().getIndexInSubtaskGroup() + 1)+ "String_Node_Str"+ this.getEnvironment().getCurrentNumberOfSubtasks()+ "String_Node_Str");
      throw ex;
    }
  }
 finally {
    if (innerInput != null) {
      innerInput.close();
    }
  }
}

Fixed version (ground truth):
/** 
 * Runs a streamed nested loop strategy to build the Cartesian product and call the <code>cross()</code> method of the CrossStub implementation. The outer side is read directly from the input reader. The inner side is read and reseted using a SpillingResettableIterator.
 * @see eu.stratosphere.pact.runtime.resettable.SpillingResettableIterator
 * @param memoryManager The task manager's memory manager.
 * @param ioManager The task manager's IO manager
 * @param innerReader The inner reader of the nested loops.
 * @param outerReader The outer reader of the nested loops.
 * @throws RuntimeException Throws a RuntimeException if something fails during execution.
 */
private void runStreamed(MemoryManager memoryManager,IOManager ioManager,RecordReader<KeyValuePair<Key,Value>> innerReader,final RecordReader<KeyValuePair<Key,Value>> outerReader) throws Exception {
  SpillingResettableIterator<KeyValuePair<Key,Value>> innerInput=null;
  RepeatableReaderIterator outerInput=null;
  try {
    final boolean firstInputIsOuter;
    if (config.getLocalStrategy() == LocalStrategy.NESTEDLOOP_STREAMED_OUTER_FIRST) {
      try {
        innerInput=new SpillingResettableIterator<KeyValuePair<Key,Value>>(memoryManager,ioManager,innerReader,this.availableMemory,new KeyValuePairDeserializer<Key,Value>(stub.getSecondInKeyType(),stub.getSecondInValueType()),this);
        spillingResetIt=innerInput;
      }
 catch (      MemoryAllocationException mae) {
        throw new RuntimeException("String_Node_Str",mae);
      }
      outerInput=new RepeatableReaderIterator(outerReader,stub.getFirstInKeyType(),stub.getFirstInValueType());
      firstInputIsOuter=true;
    }
 else     if (config.getLocalStrategy() == LocalStrategy.NESTEDLOOP_STREAMED_OUTER_SECOND) {
      try {
        innerInput=new SpillingResettableIterator<KeyValuePair<Key,Value>>(memoryManager,ioManager,innerReader,this.availableMemory,new KeyValuePairDeserializer<Key,Value>(stub.getFirstInKeyType(),stub.getFirstInValueType()),this);
        spillingResetIt=innerInput;
      }
 catch (      MemoryAllocationException mae) {
        throw new RuntimeException("String_Node_Str",mae);
      }
      outerInput=new RepeatableReaderIterator(outerReader,stub.getSecondInKeyType(),stub.getSecondInValueType());
      firstInputIsOuter=false;
    }
 else {
      throw new RuntimeException("String_Node_Str" + config.getLocalStrategy());
    }
    try {
      innerInput.open();
    }
 catch (    ServiceException se) {
      throw new RuntimeException("String_Node_Str",se);
    }
catch (    IOException ioe) {
      throw new RuntimeException("String_Node_Str",ioe);
    }
catch (    InterruptedException ie) {
      throw new RuntimeException("String_Node_Str",ie);
    }
    if (this.taskCanceled)     return;
    LOG.debug("String_Node_Str" + this.getEnvironment().getTaskName() + "String_Node_Str"+ (this.getEnvironment().getIndexInSubtaskGroup() + 1)+ "String_Node_Str"+ this.getEnvironment().getCurrentNumberOfSubtasks()+ "String_Node_Str");
    stub.open();
    while (!this.taskCanceled && outerInput.hasNext()) {
      Pair outerPair=outerInput.next();
      while (!this.taskCanceled && innerInput.hasNext()) {
        Pair innerPair=innerInput.next();
        if (firstInputIsOuter) {
          stub.cross(outerPair.getKey(),outerPair.getValue(),innerPair.getKey(),innerPair.getValue(),output);
        }
 else {
          stub.cross(innerPair.getKey(),innerPair.getValue(),outerPair.getKey(),outerPair.getValue(),output);
        }
        outerPair=outerInput.repeatLast();
      }
      if (!this.taskCanceled && outerInput.hasNext()) {
        innerInput.reset();
      }
    }
    stub.close();
  }
 catch (  Exception ex) {
    if (!this.taskCanceled) {
      LOG.error("String_Node_Str" + this.getEnvironment().getTaskName() + "String_Node_Str"+ (this.getEnvironment().getIndexInSubtaskGroup() + 1)+ "String_Node_Str"+ this.getEnvironment().getCurrentNumberOfSubtasks()+ "String_Node_Str");
      throw ex;
    }
  }
 finally {
    if (innerInput != null) {
      innerInput.close();
    }
  }
}