Program: 88250
Project: 88250
Buggy source:
/** 
 * Runs a blocked nested loop strategy to build the Cartesian product and call the <code>cross()</code> method of the CrossStub implementation. The outer side is read using a BlockResettableIterator. The inner side is read using a SpillingResettableIterator.
 * @see eu.stratosphere.pact.runtime.resettable.SpillingResettableIterator
 * @see eu.stratosphere.pact.runtime.resettable.BlockResettableIterator
 * @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 runBlocked(MemoryManager memoryManager,IOManager ioManager,RecordReader<KeyValuePair<Key,Value>> innerReader,RecordReader<KeyValuePair<Key,Value>> outerReader) throws Exception {
  SpillingResettableIterator<KeyValuePair<Key,Value>> innerInput=null;
  BlockResettableIterator<KeyValuePair<Key,Value>> outerInput=null;
  try {
    if (config.getLocalStrategy() == LocalStrategy.NESTEDLOOP_BLOCKED_OUTER_SECOND) {
      try {
        innerInput=new SpillingResettableIterator<KeyValuePair<Key,Value>>(memoryManager,ioManager,innerReader,this.availableMemory / 2,new KeyValuePairDeserializer<Key,Value>(stub.getFirstInKeyType(),stub.getFirstInValueType()),this);
        spillingResetIt=innerInput;
      }
 catch (      MemoryAllocationException mae) {
        throw new RuntimeException("String_Node_Str",mae);
      }
      try {
        outerInput=new BlockResettableIterator<KeyValuePair<Key,Value>>(memoryManager,outerReader,this.availableMemory / 2,1,new KeyValuePairDeserializer<Key,Value>(stub.getSecondInKeyType(),stub.getSecondInValueType()),this);
        blockResetIt=outerInput;
      }
 catch (      MemoryAllocationException mae) {
        throw new RuntimeException("String_Node_Str",mae);
      }
    }
 else     if (config.getLocalStrategy() == LocalStrategy.NESTEDLOOP_BLOCKED_OUTER_FIRST) {
      try {
        innerInput=new SpillingResettableIterator<KeyValuePair<Key,Value>>(memoryManager,ioManager,innerReader,this.availableMemory / 2,new KeyValuePairDeserializer<Key,Value>(stub.getSecondInKeyType(),stub.getSecondInValueType()),this);
        spillingResetIt=innerInput;
      }
 catch (      MemoryAllocationException mae) {
        throw new RuntimeException("String_Node_Str",mae);
      }
      try {
        outerInput=new BlockResettableIterator<KeyValuePair<Key,Value>>(memoryManager,outerReader,this.availableMemory / 2,1,new KeyValuePairDeserializer<Key,Value>(stub.getFirstInKeyType(),stub.getFirstInValueType()),this);
        blockResetIt=outerInput;
      }
 catch (      MemoryAllocationException mae) {
        throw new RuntimeException("String_Node_Str",mae);
      }
    }
 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;
    outerInput.open();
    LOG.debug("String_Node_Str" + this.getEnvironment().getTaskName() + "String_Node_Str"+ (this.getEnvironment().getIndexInSubtaskGroup() + 1)+ "String_Node_Str"+ this.getEnvironment().getCurrentNumberOfSubtasks()+ "String_Node_Str");
    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();
    boolean moreOuterBlocks=false;
    if (config.getLocalStrategy() == LocalStrategy.NESTEDLOOP_BLOCKED_OUTER_SECOND) {
      do {
        while (!this.taskCanceled && innerInput.hasNext()) {
          Pair<Key,Value> innerPair=innerInput.next();
          while (!this.taskCanceled && outerInput.hasNext()) {
            Pair<Key,Value> outerPair=outerInput.next();
            stub.cross(innerPair.getKey(),innerPair.getValue(),outerPair.getKey(),outerPair.getValue(),output);
            innerPair=innerInput.repeatLast();
          }
          outerInput.reset();
        }
        moreOuterBlocks=outerInput.nextBlock();
        if (moreOuterBlocks) {
          innerInput.reset();
        }
      }
 while (!this.taskCanceled && moreOuterBlocks);
    }
 else {
      do {
        while (!this.taskCanceled && innerInput.hasNext()) {
          Pair<Key,Value> innerPair=innerInput.next();
          while (!this.taskCanceled && outerInput.hasNext()) {
            Pair<Key,Value> outerPair=outerInput.next();
            stub.cross(outerPair.getKey(),outerPair.getValue(),innerPair.getKey(),innerPair.getValue(),output);
            innerPair=innerInput.repeatLast();
          }
          outerInput.reset();
        }
        moreOuterBlocks=outerInput.nextBlock();
        if (moreOuterBlocks) {
          innerInput.reset();
        }
      }
 while (!this.taskCanceled && moreOuterBlocks);
    }
    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 {
    Throwable t1=null, t2=null;
    try {
      if (innerInput != null) {
        innerInput.close();
      }
    }
 catch (    Throwable t) {
      LOG.warn(t);
      t1=t;
    }
    try {
      if (outerInput != null) {
        outerInput.close();
      }
    }
 catch (    Throwable t) {
      LOG.warn(t);
      t2=t;
    }
    if (t1 != null)     throw new RuntimeException("String_Node_Str",t1);
    if (t2 != null)     throw new RuntimeException("String_Node_Str",t2);
  }
}

Fixed version (ground truth):
/** 
 * Runs a blocked nested loop strategy to build the Cartesian product and call the <code>cross()</code> method of the CrossStub implementation. The outer side is read using a BlockResettableIterator. The inner side is read using a SpillingResettableIterator.
 * @see eu.stratosphere.pact.runtime.resettable.SpillingResettableIterator
 * @see eu.stratosphere.pact.runtime.resettable.BlockResettableIterator
 * @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 runBlocked(MemoryManager memoryManager,IOManager ioManager,RecordReader<KeyValuePair<Key,Value>> innerReader,RecordReader<KeyValuePair<Key,Value>> outerReader) throws Exception {
  SpillingResettableIterator<KeyValuePair<Key,Value>> innerInput=null;
  BlockResettableIterator<KeyValuePair<Key,Value>> outerInput=null;
  try {
    final boolean firstInputIsOuter;
    if (config.getLocalStrategy() == LocalStrategy.NESTEDLOOP_BLOCKED_OUTER_SECOND) {
      try {
        innerInput=new SpillingResettableIterator<KeyValuePair<Key,Value>>(memoryManager,ioManager,innerReader,this.availableMemory / 2,new KeyValuePairDeserializer<Key,Value>(stub.getFirstInKeyType(),stub.getFirstInValueType()),this);
        spillingResetIt=innerInput;
      }
 catch (      MemoryAllocationException mae) {
        throw new RuntimeException("String_Node_Str",mae);
      }
      try {
        outerInput=new BlockResettableIterator<KeyValuePair<Key,Value>>(memoryManager,outerReader,this.availableMemory / 2,1,new KeyValuePairDeserializer<Key,Value>(stub.getSecondInKeyType(),stub.getSecondInValueType()),this);
        blockResetIt=outerInput;
      }
 catch (      MemoryAllocationException mae) {
        throw new RuntimeException("String_Node_Str",mae);
      }
      firstInputIsOuter=false;
    }
 else     if (config.getLocalStrategy() == LocalStrategy.NESTEDLOOP_BLOCKED_OUTER_FIRST) {
      try {
        innerInput=new SpillingResettableIterator<KeyValuePair<Key,Value>>(memoryManager,ioManager,innerReader,this.availableMemory / 2,new KeyValuePairDeserializer<Key,Value>(stub.getSecondInKeyType(),stub.getSecondInValueType()),this);
        spillingResetIt=innerInput;
      }
 catch (      MemoryAllocationException mae) {
        throw new RuntimeException("String_Node_Str",mae);
      }
      try {
        outerInput=new BlockResettableIterator<KeyValuePair<Key,Value>>(memoryManager,outerReader,this.availableMemory / 2,1,new KeyValuePairDeserializer<Key,Value>(stub.getFirstInKeyType(),stub.getFirstInValueType()),this);
        blockResetIt=outerInput;
      }
 catch (      MemoryAllocationException mae) {
        throw new RuntimeException("String_Node_Str",mae);
      }
      firstInputIsOuter=true;
    }
 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;
    outerInput.open();
    LOG.debug("String_Node_Str" + this.getEnvironment().getTaskName() + "String_Node_Str"+ (this.getEnvironment().getIndexInSubtaskGroup() + 1)+ "String_Node_Str"+ this.getEnvironment().getCurrentNumberOfSubtasks()+ "String_Node_Str");
    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();
    boolean moreOuterBlocks=false;
    do {
      while (!this.taskCanceled && innerInput.hasNext()) {
        Pair<Key,Value> innerPair=innerInput.next();
        while (!this.taskCanceled && outerInput.hasNext()) {
          Pair<Key,Value> outerPair=outerInput.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);
          }
          innerPair=innerInput.repeatLast();
        }
        outerInput.reset();
      }
      moreOuterBlocks=outerInput.nextBlock();
      if (moreOuterBlocks) {
        innerInput.reset();
      }
    }
 while (!this.taskCanceled && moreOuterBlocks);
    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 {
    Throwable t1=null, t2=null;
    try {
      if (innerInput != null) {
        innerInput.close();
      }
    }
 catch (    Throwable t) {
      LOG.warn(t);
      t1=t;
    }
    try {
      if (outerInput != null) {
        outerInput.close();
      }
    }
 catch (    Throwable t) {
      LOG.warn(t);
      t2=t;
    }
    if (t1 != null)     throw new RuntimeException("String_Node_Str",t1);
    if (t2 != null)     throw new RuntimeException("String_Node_Str",t2);
  }
}