Program: 55206
Project: 55206
Buggy source:
/** 
 * Registers the given task with the byte buffered channel manager.
 * @param task the task to be registered
 * @param activeOutputChannels the set of output channels which are initially active
 * @param hasAlreadyBeenDeployed stores if the task has already been deployed before at least once
 * @throws InsufficientResourcesException thrown if the channel manager does not have enough memory buffers to safely run this task
 */
public void register(final Task task,final Set<ChannelID> activeOutputChannels,final boolean hasAlreadyBeenDeployed) throws InsufficientResourcesException {
  checkBufferAvailability(task);
  final Environment environment=task.getEnvironment();
  final TaskContext taskContext=task.createTaskContext(this,this.localBufferPoolOwner.remove(task.getVertexID()));
  final Set<GateID> outputGateIDs=environment.getOutputGateIDs();
  for (final Iterator<GateID> gateIt=outputGateIDs.iterator(); gateIt.hasNext(); ) {
    final GateID gateID=gateIt.next();
    final OutputGateContext outputGateContext=taskContext.createOutputGateContext(gateID);
    final Set<ChannelID> outputChannelIDs=environment.getOutputChannelIDsOfGate(gateID);
    for (final Iterator<ChannelID> channelIt=outputChannelIDs.iterator(); channelIt.hasNext(); ) {
      final ChannelID channelID=channelIt.next();
      final OutputChannelContext previousContext=(OutputChannelContext)this.registeredChannels.get(channelID);
      final boolean isActive=true;
      final OutputChannelContext outputChannelContext=outputGateContext.createOutputChannelContext(channelID,previousContext,isActive,this.mergeSpilledBuffers);
      if (outputChannelContext.getType() == ChannelType.INMEMORY && !hasAlreadyBeenDeployed) {
        addReceiverListHint(outputChannelContext);
      }
      if (LOG.isDebugEnabled())       LOG.debug("String_Node_Str" + outputChannelContext.getChannelID() + "String_Node_Str"+ (isActive ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
      this.registeredChannels.put(outputChannelContext.getChannelID(),outputChannelContext);
    }
  }
  final Set<GateID> inputGateIDs=environment.getInputGateIDs();
  for (final Iterator<GateID> gateIt=inputGateIDs.iterator(); gateIt.hasNext(); ) {
    final GateID gateID=gateIt.next();
    final InputGateContext inputGateContext=taskContext.createInputGateContext(gateID);
    final Set<ChannelID> inputChannelIDs=environment.getInputChannelIDsOfGate(gateID);
    for (final Iterator<ChannelID> channelIt=inputChannelIDs.iterator(); channelIt.hasNext(); ) {
      final ChannelID channelID=channelIt.next();
      final InputChannelContext previousContext=(InputChannelContext)this.registeredChannels.get(channelID);
      final InputChannelContext inputChannelContext=inputGateContext.createInputChannelContext(channelID,previousContext);
      if (inputChannelContext.getType() == ChannelType.INMEMORY && !hasAlreadyBeenDeployed) {
        addReceiverListHint(inputChannelContext);
      }
      this.registeredChannels.put(inputChannelContext.getChannelID(),inputChannelContext);
    }
    final LocalBufferPoolOwner bufferPoolOwner=inputGateContext.getLocalBufferPoolOwner();
    if (bufferPoolOwner != null) {
      this.localBufferPoolOwner.put(inputGateContext.getGateID(),bufferPoolOwner);
    }
  }
  this.localBufferPoolOwner.put(task.getVertexID(),taskContext);
  redistributeGlobalBuffers();
}

Fixed version (ground truth):
/** 
 * Registers the given task with the byte buffered channel manager.
 * @param task the task to be registered
 * @param activeOutputChannels the set of output channels which are initially active
 * @param hasAlreadyBeenDeployed stores if the task has already been deployed before at least once
 * @throws InsufficientResourcesException thrown if the channel manager does not have enough memory buffers to safely run this task
 */
public void register(final Task task,final Set<ChannelID> activeOutputChannels,final boolean hasAlreadyBeenDeployed) throws InsufficientResourcesException {
  checkBufferAvailability(task);
  final Environment environment=task.getEnvironment();
  final TaskContext taskContext=task.createTaskContext(this,this.localBufferPoolOwner.remove(task.getVertexID()));
  final Set<GateID> outputGateIDs=environment.getOutputGateIDs();
  for (final Iterator<GateID> gateIt=outputGateIDs.iterator(); gateIt.hasNext(); ) {
    final GateID gateID=gateIt.next();
    final OutputGateContext outputGateContext=taskContext.createOutputGateContext(gateID);
    final Set<ChannelID> outputChannelIDs=environment.getOutputChannelIDsOfGate(gateID);
    for (final Iterator<ChannelID> channelIt=outputChannelIDs.iterator(); channelIt.hasNext(); ) {
      final ChannelID channelID=channelIt.next();
      final OutputChannelContext previousContext=(OutputChannelContext)this.registeredChannels.get(channelID);
      final boolean isActive=true;
      final OutputChannelContext outputChannelContext=outputGateContext.createOutputChannelContext(channelID,previousContext,isActive,this.mergeSpilledBuffers);
      if (outputChannelContext.getType() == ChannelType.INMEMORY && !hasAlreadyBeenDeployed) {
        addReceiverListHint(outputChannelContext);
      }
      if (LOG.isDebugEnabled()) {
        LOG.debug("String_Node_Str" + outputChannelContext.getChannelID() + "String_Node_Str"+ (isActive ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str");
      }
      this.registeredChannels.put(outputChannelContext.getChannelID(),outputChannelContext);
    }
  }
  final Set<GateID> inputGateIDs=environment.getInputGateIDs();
  for (final Iterator<GateID> gateIt=inputGateIDs.iterator(); gateIt.hasNext(); ) {
    final GateID gateID=gateIt.next();
    final InputGateContext inputGateContext=taskContext.createInputGateContext(gateID);
    final Set<ChannelID> inputChannelIDs=environment.getInputChannelIDsOfGate(gateID);
    for (final Iterator<ChannelID> channelIt=inputChannelIDs.iterator(); channelIt.hasNext(); ) {
      final ChannelID channelID=channelIt.next();
      final InputChannelContext previousContext=(InputChannelContext)this.registeredChannels.get(channelID);
      final InputChannelContext inputChannelContext=inputGateContext.createInputChannelContext(channelID,previousContext);
      if (inputChannelContext.getType() == ChannelType.INMEMORY && !hasAlreadyBeenDeployed) {
        addReceiverListHint(inputChannelContext);
      }
      this.registeredChannels.put(inputChannelContext.getChannelID(),inputChannelContext);
    }
    final LocalBufferPoolOwner bufferPoolOwner=inputGateContext.getLocalBufferPoolOwner();
    if (bufferPoolOwner != null) {
      this.localBufferPoolOwner.put(inputGateContext.getGateID(),bufferPoolOwner);
    }
  }
  this.localBufferPoolOwner.put(task.getVertexID(),taskContext);
  redistributeGlobalBuffers();
}