nus-yam/ex-repair huggingface dataset:
Program: 173032
Project: 173032
Buggy source:
@Override public void init(Config cfg,DataFlowOperation op,Map<Integer,List<Integer>> expectedIds){
  executor=op.getTaskPlan().getThisExecutor();
  sendPendingMax=MPIContext.sendPendingMax(cfg);
  LOG.fine(String.format("String_Node_Str",executor,expectedIds));
  for (  Map.Entry<Integer,List<Integer>> e : expectedIds.entrySet()) {
    Map<Integer,List<Object>> messagesPerTask=new HashMap<>();
    Map<Integer,Boolean> finishedPerTask=new HashMap<>();
    Map<Integer,Integer> countsPerTask=new HashMap<>();
    for (    int i : e.getValue()) {
      messagesPerTask.put(i,new ArrayList<Object>());
      finishedPerTask.put(i,false);
      countsPerTask.put(i,0);
    }
    messages.put(e.getKey(),messagesPerTask);
    finished.put(e.getKey(),finishedPerTask);
    counts.put(e.getKey(),countsPerTask);
    batchDone.put(e.getKey(),false);
  }
  this.dataFlowOperation=op;
  this.executor=dataFlowOperation.getTaskPlan().getThisExecutor();
}

Fixed version (ground truth):
@Override public void init(Config cfg,DataFlowOperation op,Map<Integer,List<Integer>> expectedIds){
  executor=op.getTaskPlan().getThisExecutor();
  sendPendingMax=MPIContext.sendPendingMax(cfg);
  LOG.fine(String.format("String_Node_Str",executor,expectedIds));
  for (  Map.Entry<Integer,List<Integer>> e : expectedIds.entrySet()) {
    Map<Integer,Queue<Object>> messagesPerTask=new HashMap<>();
    Map<Integer,Boolean> finishedPerTask=new HashMap<>();
    Map<Integer,Integer> countsPerTask=new HashMap<>();
    for (    int i : e.getValue()) {
      messagesPerTask.put(i,new ArrayBlockingQueue<>(sendPendingMax));
      finishedPerTask.put(i,false);
      countsPerTask.put(i,0);
    }
    messages.put(e.getKey(),messagesPerTask);
    finished.put(e.getKey(),finishedPerTask);
    counts.put(e.getKey(),countsPerTask);
    batchDone.put(e.getKey(),false);
  }
  this.dataFlowOperation=op;
  this.executor=dataFlowOperation.getTaskPlan().getThisExecutor();
}
Program: 173033
Project: 173033
Buggy source:
@Override public boolean onMessage(int source,int path,int target,int flags,Object object){
  boolean canAdd=true;
  if (messages.get(target) == null) {
    throw new RuntimeException(String.format("String_Node_Str",executor,target));
  }
  List<Object> m=messages.get(target).get(source);
  Map<Integer,Boolean> finishedMessages=finished.get(target);
  if (m.size() > sendPendingMax) {
    canAdd=false;
  }
 else {
    if (object instanceof MPIMessage) {
      ((MPIMessage)object).incrementRefCount();
    }
    Integer c=counts.get(target).get(source);
    counts.get(target).put(source,c + 1);
    m.add(object);
    if ((flags & MessageFlags.FLAGS_LAST) == MessageFlags.FLAGS_LAST) {
      finishedMessages.put(source,true);
    }
  }
  return canAdd;
}

Fixed version (ground truth):
@Override public boolean onMessage(int source,int path,int target,int flags,Object object){
  boolean canAdd=true;
  if (messages.get(target) == null) {
    throw new RuntimeException(String.format("String_Node_Str",executor,target));
  }
  Queue<Object> m=messages.get(target).get(source);
  Map<Integer,Boolean> finishedMessages=finished.get(target);
  if (m.size() >= sendPendingMax) {
    canAdd=false;
  }
 else {
    if (object instanceof MPIMessage) {
      ((MPIMessage)object).incrementRefCount();
    }
    Integer c=counts.get(target).get(source);
    counts.get(target).put(source,c + 1);
    m.add(object);
    if ((flags & MessageFlags.FLAGS_LAST) == MessageFlags.FLAGS_LAST) {
      finishedMessages.put(source,true);
    }
  }
  return canAdd;
}
Program: 173035
Project: 173035
Buggy source:
public AllGatherStreamingFinalReceiver(MPIDataFlowBroadcast broadcast){
  this.broadcast=broadcast;
}

Fixed version (ground truth):
public AllGatherStreamingFinalReceiver(MPIDataFlowBroadcast broadcast,GatherBatchReceiver gatherRecvr){
  super(gatherRecvr);
  this.broadcast=broadcast;
}
Program: 173036
Project: 173036
Buggy source:
private void receiveDeserializeProgress(MPIMessage currentMessage,int receiveId){
  if (currentMessage == null) {
    return;
  }
  int id=currentMessage.getOriginatingId();
  if (isStoreBased && isLastReceiver) {
    LOG.info("String_Node_Str");
    writeToMemoryManager(currentMessage,receiveId);
    currentMessage.setReceivedState(MPIMessage.ReceivedState.RECEIVE);
    if (!receiver.receiveMessage(currentMessage,operationMemoryManager)) {
      return;
    }
  }
 else {
    Object object=messageDeSerializer.get(receiveId).build(currentMessage,currentMessage.getHeader().getEdge());
    Queue<Pair<Object,MPIMessage>> pendingReceiveMessages=pendingReceiveMessagesPerSource.get(id);
    currentMessage.setReceivedState(MPIMessage.ReceivedState.INIT);
    if (!pendingReceiveMessages.offer(new ImmutablePair<>(object,currentMessage))) {
      throw new RuntimeException(executor + "String_Node_Str" + pendingReceiveMessages.size());
    }
  }
}

Fixed version (ground truth):
private void receiveDeserializeProgress(MPIMessage currentMessage,int receiveId){
  if (currentMessage == null) {
    return;
  }
  int id=currentMessage.getOriginatingId();
  if (isStoreBased && isLastReceiver) {
    writeToMemoryManager(currentMessage,receiveId);
    currentMessage.setReceivedState(MPIMessage.ReceivedState.RECEIVE);
    if (!receiver.receiveMessage(currentMessage,operationMemoryManager)) {
      return;
    }
  }
 else {
    Object object=messageDeSerializer.get(receiveId).build(currentMessage,currentMessage.getHeader().getEdge());
    Queue<Pair<Object,MPIMessage>> pendingReceiveMessages=pendingReceiveMessagesPerSource.get(id);
    currentMessage.setReceivedState(MPIMessage.ReceivedState.INIT);
    if (!pendingReceiveMessages.offer(new ImmutablePair<>(object,currentMessage))) {
      throw new RuntimeException(executor + "String_Node_Str" + pendingReceiveMessages.size());
    }
  }
}
Program: 173037
Project: 173037
Buggy source:
/** 
 * Desetrialize
 */
public static Pair<Object,Integer> deserializeKey(MessageType keyType,List<MPIBuffer> buffers,KryoSerializer serializer){
  int currentIndex=0;
  int keyLength=0;
  Object key=null;
switch (keyType) {
case INTEGER:
    currentIndex=getReadIndex(buffers,currentIndex,4);
  ByteBuffer byteBuffer=buffers.get(currentIndex).getByteBuffer();
LOG.info(String.format("String_Node_Str",byteBuffer.position()));
key=byteBuffer.getInt();
keyLength=4;
break;
case SHORT:
currentIndex=getReadIndex(buffers,currentIndex,2);
key=buffers.get(currentIndex).getByteBuffer().getShort();
keyLength=2;
break;
case LONG:
currentIndex=getReadIndex(buffers,currentIndex,8);
key=buffers.get(currentIndex).getByteBuffer().getInt();
keyLength=8;
break;
case DOUBLE:
currentIndex=getReadIndex(buffers,currentIndex,8);
key=buffers.get(currentIndex).getByteBuffer().getInt();
keyLength=8;
break;
case OBJECT:
currentIndex=getReadIndex(buffers,currentIndex,4);
keyLength=buffers.get(currentIndex).getByteBuffer().getInt();
key=DataDeserializer.deserializeObject(buffers,keyLength,serializer);
break;
case BYTE:
currentIndex=getReadIndex(buffers,currentIndex,4);
keyLength=buffers.get(currentIndex).getByteBuffer().getInt();
key=readBytes(buffers,keyLength);
break;
case STRING:
currentIndex=getReadIndex(buffers,currentIndex,4);
keyLength=buffers.get(currentIndex).getByteBuffer().getInt();
key=new String(readBytes(buffers,keyLength));
break;
default :
break;
}
return new ImmutablePair<>(key,keyLength);
}

Fixed version (ground truth):
/** 
 * Desetrialize
 */
public static Pair<Object,Integer> deserializeKey(MessageType keyType,List<MPIBuffer> buffers,KryoSerializer serializer){
  int currentIndex=0;
  int keyLength=0;
  Object key=null;
switch (keyType) {
case INTEGER:
    currentIndex=getReadIndex(buffers,currentIndex,4);
  ByteBuffer byteBuffer=buffers.get(currentIndex).getByteBuffer();
key=byteBuffer.getInt();
keyLength=4;
break;
case SHORT:
currentIndex=getReadIndex(buffers,currentIndex,2);
key=buffers.get(currentIndex).getByteBuffer().getShort();
keyLength=2;
break;
case LONG:
currentIndex=getReadIndex(buffers,currentIndex,8);
key=buffers.get(currentIndex).getByteBuffer().getInt();
keyLength=8;
break;
case DOUBLE:
currentIndex=getReadIndex(buffers,currentIndex,8);
key=buffers.get(currentIndex).getByteBuffer().getInt();
keyLength=8;
break;
case OBJECT:
currentIndex=getReadIndex(buffers,currentIndex,4);
keyLength=buffers.get(currentIndex).getByteBuffer().getInt();
key=DataDeserializer.deserializeObject(buffers,keyLength,serializer);
break;
case BYTE:
currentIndex=getReadIndex(buffers,currentIndex,4);
keyLength=buffers.get(currentIndex).getByteBuffer().getInt();
key=readBytes(buffers,keyLength);
break;
case STRING:
currentIndex=getReadIndex(buffers,currentIndex,4);
keyLength=buffers.get(currentIndex).getByteBuffer().getInt();
key=new String(readBytes(buffers,keyLength));
break;
default :
break;
}
return new ImmutablePair<>(key,keyLength);
}
Program: 173038
Project: 173038
Buggy source:
public static DataMessageType toDataMessageType(MessageType a){
switch (a) {
case INTEGER:
    return DataMessageType.INTEGER;
case CHAR:
  return DataMessageType.CHAR;
case BYTE:
return DataMessageType.BYTE;
case STRING:
return DataMessageType.STRING;
case LONG:
return DataMessageType.LONG;
case DOUBLE:
return DataMessageType.DOUBLE;
case OBJECT:
return DataMessageType.DOUBLE;
case BUFFER:
return DataMessageType.BUFFER;
case EMPTY:
return DataMessageType.EMPTY;
case SHORT:
return DataMessageType.SHORT;
default :
throw new RuntimeException("String_Node_Str" + "String_Node_Str");
}
}

Fixed version (ground truth):
public static DataMessageType toDataMessageType(MessageType a){
switch (a) {
case INTEGER:
    return DataMessageType.INTEGER;
case CHAR:
  return DataMessageType.CHAR;
case BYTE:
return DataMessageType.BYTE;
case STRING:
return DataMessageType.STRING;
case LONG:
return DataMessageType.LONG;
case DOUBLE:
return DataMessageType.DOUBLE;
case OBJECT:
return DataMessageType.OBJECT;
case BUFFER:
return DataMessageType.BUFFER;
case EMPTY:
return DataMessageType.EMPTY;
case SHORT:
return DataMessageType.SHORT;
default :
throw new RuntimeException("String_Node_Str" + "String_Node_Str");
}
}
Program: 173039
Project: 173039
Buggy source:
private void receiveDeserializeProgress(MPIMessage currentMessage,int receiveId){
  if (currentMessage == null) {
    return;
  }
  int id=currentMessage.getOriginatingId();
  if (isStoreBased && isLastReceiver) {
    writeToMemoryManager(currentMessage,receiveId);
    currentMessage.setReceivedState(MPIMessage.ReceivedState.RECEIVE);
    if (!receiver.receiveMessage(currentMessage,operationMemoryManager)) {
      return;
    }
  }
 else {
    Object object=messageDeSerializer.get(receiveId).build(currentMessage,currentMessage.getHeader().getEdge());
    Queue<Pair<Object,MPIMessage>> pendingReceiveMessages=pendingReceiveMessagesPerSource.get(id);
    currentMessage.setReceivedState(MPIMessage.ReceivedState.INIT);
    if (!pendingReceiveMessages.offer(new ImmutablePair<>(object,currentMessage))) {
      throw new RuntimeException(executor + "String_Node_Str" + pendingReceiveMessages.size());
    }
  }
}

Fixed version (ground truth):
private void receiveDeserializeProgress(MPIMessage currentMessage,int receiveId){
  if (currentMessage == null) {
    return;
  }
  int id=currentMessage.getOriginatingId();
  if (isStoreBased && isLastReceiver) {
    writeToMemoryManager(currentMessage,receiveId);
    currentMessage.setReceivedState(MPIMessage.ReceivedState.RECEIVE);
    if (!receiver.receiveMessage(currentMessage,operationMemoryManager)) {
      return;
    }
    currentMessage.incrementRefCount();
    currentMessage.release();
  }
 else {
    Object object=messageDeSerializer.get(receiveId).build(currentMessage,currentMessage.getHeader().getEdge());
    Queue<Pair<Object,MPIMessage>> pendingReceiveMessages=pendingReceiveMessagesPerSource.get(id);
    currentMessage.setReceivedState(MPIMessage.ReceivedState.INIT);
    if (!pendingReceiveMessages.offer(new ImmutablePair<>(object,currentMessage))) {
      throw new RuntimeException(executor + "String_Node_Str" + pendingReceiveMessages.size());
    }
  }
}
Program: 173040
Project: 173040
Buggy source:
public void setStoreBased(boolean storeBased){
  isStoreBased=storeBased;
  if (isStoreBased) {
    opertionID=(int)System.currentTimeMillis();
    this.kryoSerializer=new KryoSerializer();
    Path dataPath=new Path("String_Node_Str");
    this.memoryManager=new LMDBMemoryManager(dataPath);
    if (!isKeyed) {
      this.operationMemoryManager=memoryManager.addOperation(opertionID,MessageTypeConverter.toDataMessageType(type));
    }
 else {
      this.operationMemoryManager=memoryManager.addOperation(opertionID,MessageTypeConverter.toDataMessageType(type),MessageTypeConverter.toDataMessageType(keyType));
    }
  }
}

Fixed version (ground truth):
public void setStoreBased(boolean storeBased){
  isStoreBased=storeBased;
  if (isStoreBased) {
    opertionID=(int)System.currentTimeMillis();
    this.kryoSerializer=new KryoSerializer();
    Path dataPath=new Path("String_Node_Str" + this.executor);
    this.memoryManager=new LMDBMemoryManager(dataPath);
    if (!isKeyed) {
      this.operationMemoryManager=memoryManager.addOperation(opertionID,MessageTypeConverter.toDataMessageType(type));
    }
 else {
      this.operationMemoryManager=memoryManager.addOperation(opertionID,MessageTypeConverter.toDataMessageType(type),MessageTypeConverter.toDataMessageType(keyType));
    }
  }
}
Program: 173041
Project: 173041
Buggy source:
@Override public Object getDataBuffers(Object partialObject,int edge){
  MPIMessage currentMessage=(MPIMessage)partialObject;
  MessageType type=currentMessage.getType();
  if (!keyed) {
    return DataDeserializer.getAsByteBuffer(currentMessage.getBuffers(),currentMessage.getHeader().getLength(),type);
  }
 else {
    Pair<Integer,ByteBuffer> keyPair=KeyDeserializer.getKeyAsByteBuffer(currentMessage.getKeyType(),currentMessage.getBuffers());
    ByteBuffer data=DataDeserializer.getAsByteBuffer(currentMessage.getBuffers(),currentMessage.getHeader().getLength() - keyPair.getKey(),type);
    return new ImmutablePair<>(keyPair.getValue(),data);
  }
}

Fixed version (ground truth):
@Override public Object getDataBuffers(Object partialObject,int edge){
  MPIMessage currentMessage=(MPIMessage)partialObject;
  MessageType type=currentMessage.getType();
  if (!keyed) {
    return DataDeserializer.getAsByteBuffer(currentMessage.getBuffers(),currentMessage.getHeader().getLength(),type);
  }
 else {
    Pair<Integer,ByteBuffer> keyPair=KeyDeserializer.getKeyAsByteBuffer(currentMessage.getKeyType(),currentMessage.getBuffers());
    MessageType keyType=currentMessage.getKeyType();
    ByteBuffer data;
    if (keyType == MessageType.BUFFER || keyType == MessageType.STRING || keyType == MessageType.BYTE || keyType == MessageType.OBJECT) {
      data=DataDeserializer.getAsByteBuffer(currentMessage.getBuffers(),currentMessage.getHeader().getLength() - keyPair.getKey() - 4,type);
    }
 else {
      data=DataDeserializer.getAsByteBuffer(currentMessage.getBuffers(),currentMessage.getHeader().getLength() - keyPair.getKey(),type);
    }
    return new ImmutablePair<>(keyPair.getValue(),data);
  }
}
Program: 173042
Project: 173042
Buggy source:
private Object buildMessage(MPIMessage message){
  MessageType type=message.getType();
  if (!keyed) {
    return DataDeserializer.deserializeData(message.getBuffers(),message.getHeader().getLength(),serializer,type);
  }
 else {
    Pair<Object,Integer> keyPair=KeyDeserializer.deserializeKey(message.getKeyType(),message.getBuffers(),serializer);
    return DataDeserializer.deserializeData(message.getBuffers(),message.getHeader().getLength() - keyPair.getValue(),serializer,type);
  }
}

Fixed version (ground truth):
private Object buildMessage(MPIMessage message){
  MessageType type=message.getType();
  if (!keyed) {
    return DataDeserializer.deserializeData(message.getBuffers(),message.getHeader().getLength(),serializer,type);
  }
 else {
    Pair<Object,Integer> keyPair=KeyDeserializer.deserializeKey(message.getKeyType(),message.getBuffers(),serializer);
    MessageType keyType=message.getKeyType();
    if (keyType == MessageType.BUFFER || keyType == MessageType.STRING || keyType == MessageType.BYTE || keyType == MessageType.OBJECT) {
      return DataDeserializer.deserializeData(message.getBuffers(),message.getHeader().getLength() - keyPair.getValue() - 4,serializer,type);
    }
 else {
      return DataDeserializer.deserializeData(message.getBuffers(),message.getHeader().getLength() - keyPair.getValue(),serializer,type);
    }
  }
}
Program: 173043
Project: 173043
Buggy source:
/** 
 * Serialized the message into the buffer
 * @param payload
 * @param sendMessage
 * @param buffer
 * @return true if the message is completely written
 */
private boolean serializeBody(Object payload,MPISendMessage sendMessage,MPIBuffer buffer){
  MessageType type=sendMessage.getMPIMessage().getType();
  if (type == MessageType.OBJECT || type == MessageType.INTEGER || type == MessageType.LONG || type == MessageType.DOUBLE || type == MessageType.BYTE || type == MessageType.STRING) {
    if (!keyed) {
      return serializeData(payload,sendMessage.getSerializationState(),buffer,type);
    }
 else {
      KeyedContent keyedContent=(KeyedContent)payload;
      return serializeKeyedData(keyedContent.getObject(),keyedContent.getSource(),sendMessage.getSerializationState(),buffer,type,keyedContent.getKeyType());
    }
  }
  if (type == MessageType.BUFFER) {
    return serializeBuffer(payload,sendMessage,buffer);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Serialized the message into the buffer
 * @return true if the message is completely written
 */
private boolean serializeBody(Object payload,MPISendMessage sendMessage,MPIBuffer buffer){
  MessageType type=sendMessage.getMPIMessage().getType();
  if (type == MessageType.OBJECT || type == MessageType.INTEGER || type == MessageType.LONG || type == MessageType.DOUBLE || type == MessageType.BYTE || type == MessageType.STRING) {
    if (!keyed) {
      return serializeData(payload,sendMessage.getSerializationState(),buffer,type);
    }
 else {
      KeyedContent keyedContent=(KeyedContent)payload;
      return serializeKeyedData(keyedContent.getObject(),keyedContent.getSource(),sendMessage.getSerializationState(),buffer,type,keyedContent.getKeyType());
    }
  }
  if (type == MessageType.BUFFER) {
    return serializeBuffer(payload,sendMessage,buffer);
  }
  return false;
}
Program: 173044
Project: 173044
Buggy source:
@Override public Object getDataBuffers(Object partialObject,int edge){
  MPIMessage currentMessage=(MPIMessage)partialObject;
  int readLength=0;
  int bufferIndex=0;
  List<MPIBuffer> buffers=currentMessage.getBuffers();
  List<Object> returnList=new ArrayList<>();
  MessageHeader header=currentMessage.getHeader();
  if (header == null) {
    throw new RuntimeException("String_Node_Str");
  }
  while (readLength < header.getLength()) {
    List<MPIBuffer> messageBuffers=new ArrayList<>();
    MPIBuffer mpiBuffer=buffers.get(bufferIndex);
    ByteBuffer byteBuffer=mpiBuffer.getByteBuffer();
    int length=byteBuffer.getInt();
    int tempLength=0;
    int tempBufferIndex=bufferIndex;
    while (tempLength < length) {
      mpiBuffer=buffers.get(tempBufferIndex);
      messageBuffers.add(mpiBuffer);
      tempLength+=mpiBuffer.getByteBuffer().remaining();
      tempBufferIndex++;
    }
    Object object=getSingleDataBuffers(currentMessage,messageBuffers,length);
    readLength+=length + 4;
    if (keyed) {
      readLength+=4;
    }
    byteBuffer=mpiBuffer.getByteBuffer();
    if (byteBuffer.remaining() > 0) {
      bufferIndex=tempBufferIndex - 1;
    }
 else {
      bufferIndex=tempBufferIndex;
    }
    returnList.add(object);
  }
  return returnList;
}

Fixed version (ground truth):
@Override public Object getDataBuffers(Object partialObject,int edge){
  MPIMessage currentMessage=(MPIMessage)partialObject;
  int readLength=0;
  int bufferIndex=0;
  List<MPIBuffer> buffers=currentMessage.getBuffers();
  List<Object> returnList=new ArrayList<>();
  MessageHeader header=currentMessage.getHeader();
  if (header == null) {
    throw new RuntimeException("String_Node_Str");
  }
  while (readLength < header.getLength()) {
    List<MPIBuffer> messageBuffers=new ArrayList<>();
    MPIBuffer mpiBuffer=buffers.get(bufferIndex);
    ByteBuffer byteBuffer=mpiBuffer.getByteBuffer();
    int length=byteBuffer.getInt();
    int tempLength=0;
    int tempBufferIndex=bufferIndex;
    while (tempLength < length) {
      mpiBuffer=buffers.get(tempBufferIndex);
      messageBuffers.add(mpiBuffer);
      tempLength+=mpiBuffer.getByteBuffer().remaining();
      tempBufferIndex++;
    }
    Object object=getSingleDataBuffers(currentMessage,messageBuffers,length);
    readLength+=length + 4;
    if (keyed && (currentMessage.getKeyType() == MessageType.BUFFER || currentMessage.getKeyType() == MessageType.STRING || currentMessage.getKeyType() == MessageType.BYTE || currentMessage.getKeyType() == MessageType.OBJECT)) {
      readLength+=4;
    }
    byteBuffer=mpiBuffer.getByteBuffer();
    if (byteBuffer.remaining() > 0) {
      bufferIndex=tempBufferIndex - 1;
    }
 else {
      bufferIndex=tempBufferIndex;
    }
    returnList.add(object);
  }
  return returnList;
}
Program: 173045
Project: 173045
Buggy source:
@Override public Object build(Object partialObject,int edge){
  MPIMessage currentMessage=(MPIMessage)partialObject;
  int readLength=0;
  int bufferIndex=0;
  List<MPIBuffer> buffers=currentMessage.getBuffers();
  List<Object> returnList=new ArrayList<>();
  MessageHeader header=currentMessage.getHeader();
  if (header == null) {
    throw new RuntimeException("String_Node_Str");
  }
  while (readLength < header.getLength()) {
    List<MPIBuffer> messageBuffers=new ArrayList<>();
    MPIBuffer mpiBuffer=buffers.get(bufferIndex);
    ByteBuffer byteBuffer=mpiBuffer.getByteBuffer();
    int length=byteBuffer.getInt();
    int tempLength=0;
    int tempBufferIndex=bufferIndex;
    while (tempLength < length) {
      mpiBuffer=buffers.get(tempBufferIndex);
      messageBuffers.add(mpiBuffer);
      tempLength+=mpiBuffer.getByteBuffer().remaining();
      tempBufferIndex++;
    }
    Object object=buildMessage(currentMessage,messageBuffers,length);
    readLength+=length + 4;
    if (keyed) {
      readLength+=4;
    }
    byteBuffer=mpiBuffer.getByteBuffer();
    if (byteBuffer.remaining() > 0) {
      bufferIndex=tempBufferIndex - 1;
    }
 else {
      bufferIndex=tempBufferIndex;
    }
    returnList.add(object);
  }
  return returnList;
}

Fixed version (ground truth):
@Override public Object build(Object partialObject,int edge){
  MPIMessage currentMessage=(MPIMessage)partialObject;
  int readLength=0;
  int bufferIndex=0;
  List<MPIBuffer> buffers=currentMessage.getBuffers();
  List<Object> returnList=new ArrayList<>();
  MessageHeader header=currentMessage.getHeader();
  if (header == null) {
    throw new RuntimeException("String_Node_Str");
  }
  while (readLength < header.getLength()) {
    List<MPIBuffer> messageBuffers=new ArrayList<>();
    MPIBuffer mpiBuffer=buffers.get(bufferIndex);
    ByteBuffer byteBuffer=mpiBuffer.getByteBuffer();
    int length=byteBuffer.getInt();
    int tempLength=0;
    int tempBufferIndex=bufferIndex;
    while (tempLength < length) {
      mpiBuffer=buffers.get(tempBufferIndex);
      messageBuffers.add(mpiBuffer);
      tempLength+=mpiBuffer.getByteBuffer().remaining();
      tempBufferIndex++;
    }
    Object object=buildMessage(currentMessage,messageBuffers,length);
    readLength+=length + 4;
    if (keyed && (currentMessage.getKeyType() == MessageType.BUFFER || currentMessage.getKeyType() == MessageType.STRING || currentMessage.getKeyType() == MessageType.BYTE || currentMessage.getKeyType() == MessageType.OBJECT)) {
      readLength+=4;
    }
    byteBuffer=mpiBuffer.getByteBuffer();
    if (byteBuffer.remaining() > 0) {
      bufferIndex=tempBufferIndex - 1;
    }
 else {
      bufferIndex=tempBufferIndex;
    }
    returnList.add(object);
  }
  return returnList;
}
Program: 173046
Project: 173046
Buggy source:
public DataFlowOperation direct(Map<String,Object> properties,MessageType type,int edge,Set<Integer> sourceTasks,int destTask,MessageReceiver receiver){
  LOG.info("String_Node_Str");
  LOG.info("String_Node_Str" + type.toString());
  LOG.info("String_Node_Str" + edge);
  LOG.info("String_Node_Str" + sourceTasks.size());
  LOG.info("String_Node_Str" + sourceTasks.iterator().next());
  LOG.info("String_Node_Str" + destTask);
  LOG.info("String_Node_Str" + receiver.toString());
  LOG.info("String_Node_Str");
  Config mergedCfg=Config.newBuilder().putAll(config).putAll(properties).build();
  MPIDirectDataFlowCommunication dataFlowOperation=new MPIDirectDataFlowCommunication(channel,sourceTasks,destTask,receiver);
  dataFlowOperation.init(mergedCfg,type,instancePlan,edge);
  return dataFlowOperation;
}

Fixed version (ground truth):
public DataFlowOperation direct(Map<String,Object> properties,MessageType type,int edge,Set<Integer> sourceTasks,int destTask,MessageReceiver receiver){
  Config mergedCfg=Config.newBuilder().putAll(config).putAll(properties).build();
  MPIDirectDataFlowCommunication dataFlowOperation=new MPIDirectDataFlowCommunication(channel,sourceTasks,destTask,receiver);
  dataFlowOperation.init(mergedCfg,type,instancePlan,edge);
  return dataFlowOperation;
}
Program: 173047
Project: 173047
Buggy source:
private void initProgressTrackers(){
  Set<Integer> items=pendingSendMessagesPerSource.keySet();
  LOG.info(String.format("String_Node_Str",executor,items));
  sendProgressTracker=new ProgressionTracker(items);
  Set<Integer> items1=pendingReceiveMessagesPerSource.keySet();
  LOG.info(String.format("String_Node_Str",executor,items1));
  receiveProgressTracker=new ProgressionTracker(items1);
  Set<Integer> items2=pendingReceiveDeSerializations.keySet();
  LOG.info(String.format("String_Node_Str",executor,items1));
  deserializeProgressTracker=new ProgressionTracker(items2);
}

Fixed version (ground truth):
private void initProgressTrackers(){
  Set<Integer> items=pendingSendMessagesPerSource.keySet();
  sendProgressTracker=new ProgressionTracker(items);
  Set<Integer> items1=pendingReceiveMessagesPerSource.keySet();
  receiveProgressTracker=new ProgressionTracker(items1);
  Set<Integer> items2=pendingReceiveDeSerializations.keySet();
  LOG.info("String_Node_Str");
  LOG.info(String.format("String_Node_Str",executor,items1));
  LOG.info("String_Node_Str" + pendingReceiveDeSerializations.size());
  LOG.info("String_Node_Str" + pendingReceiveDeSerializations.get(0).poll());
  LOG.info("String_Node_Str");
  deserializeProgressTracker=new ProgressionTracker(items2);
}
Program: 173048
Project: 173048
Buggy source:
private void receiveDeserializeProgress(MPIMessage currentMessage,int receiveId){
  if (currentMessage == null) {
    return;
  }
  int id=currentMessage.getOriginatingId();
  if (isStoreBased && isLastReceiver) {
    LOG.info("String_Node_Str");
    writeToMemoryManager(currentMessage,receiveId);
    currentMessage.setReceivedState(MPIMessage.ReceivedState.RECEIVE);
    if (!receiver.receiveMessage(currentMessage,operationMemoryManager)) {
      return;
    }
  }
 else {
    Object object=messageDeSerializer.get(receiveId).build(currentMessage,currentMessage.getHeader().getEdge());
    Queue<Pair<Object,MPIMessage>> pendingReceiveMessages=pendingReceiveMessagesPerSource.get(id);
    currentMessage.setReceivedState(MPIMessage.ReceivedState.INIT);
    if (!pendingReceiveMessages.offer(new ImmutablePair<>(object,currentMessage))) {
      throw new RuntimeException(executor + "String_Node_Str" + pendingReceiveMessages.size());
    }
  }
}

Fixed version (ground truth):
private void receiveDeserializeProgress(MPIMessage currentMessage,int receiveId){
  if (currentMessage == null) {
    return;
  }
  int id=currentMessage.getOriginatingId();
  LOG.info("String_Node_Str");
  LOG.info("String_Node_Str" + receiveId);
  LOG.info("String_Node_Str");
  if (isStoreBased && isLastReceiver) {
    LOG.info("String_Node_Str");
    writeToMemoryManager(currentMessage,receiveId);
    currentMessage.setReceivedState(MPIMessage.ReceivedState.RECEIVE);
    if (!receiver.receiveMessage(currentMessage,operationMemoryManager)) {
      return;
    }
  }
 else {
    LOG.info("String_Node_Str");
    LOG.info("String_Node_Str" + receiveId);
    LOG.info("String_Node_Str");
    Object object=messageDeSerializer.get(receiveId).build(currentMessage,currentMessage.getHeader().getEdge());
    Queue<Pair<Object,MPIMessage>> pendingReceiveMessages=pendingReceiveMessagesPerSource.get(id);
    currentMessage.setReceivedState(MPIMessage.ReceivedState.INIT);
    if (!pendingReceiveMessages.offer(new ImmutablePair<>(object,currentMessage))) {
      throw new RuntimeException(executor + "String_Node_Str" + pendingReceiveMessages.size());
    }
  }
}
Program: 173049
Project: 173049
Buggy source:
public boolean sendMessage(int source,Object message,int path,int flags,RoutingParameters routingParameters){
  try {
    LOG.info("String_Node_Str" + source);
    LOG.info("String_Node_Str" + message.toString());
    LOG.info("String_Node_Str" + routingParameters.toString());
    LOG.info("String_Node_Str" + routingParameters.getDestinationId());
    LOG.info("String_Node_Str" + path);
    ArrayBlockingQueue<Pair<Object,MPISendMessage>> pendingSendMessages=pendingSendMessagesPerSource.get(source);
    MPIMessage mpiMessage=new MPIMessage(source,type,MPIMessageDirection.OUT,this);
    int di=-1;
    if (routingParameters.getExternalRoutes().size() > 0) {
      di=routingParameters.getDestinationId();
    }
    MPISendMessage sendMessage=new MPISendMessage(source,mpiMessage,edge,di,path,flags,routingParameters.getInternalRoutes(),routingParameters.getExternalRoutes());
    boolean ret=pendingSendMessages.offer(new ImmutablePair<Object,MPISendMessage>(message,sendMessage));
    LOG.info("String_Node_Str" + ret);
    return ret;
  }
  finally {
    int a;
  }
}

Fixed version (ground truth):
public boolean sendMessage(int source,Object message,int path,int flags,RoutingParameters routingParameters){
  try {
    ArrayBlockingQueue<Pair<Object,MPISendMessage>> pendingSendMessages=pendingSendMessagesPerSource.get(source);
    MPIMessage mpiMessage=new MPIMessage(source,type,MPIMessageDirection.OUT,this);
    int di=-1;
    if (routingParameters.getExternalRoutes().size() > 0) {
      di=routingParameters.getDestinationId();
    }
    MPISendMessage sendMessage=new MPISendMessage(source,mpiMessage,edge,di,path,flags,routingParameters.getInternalRoutes(),routingParameters.getExternalRoutes());
    boolean ret=pendingSendMessages.offer(new ImmutablePair<Object,MPISendMessage>(message,sendMessage));
    return ret;
  }
  finally {
    int a;
  }
}
Program: 173050
Project: 173050
Buggy source:
private void receiveProgress(Queue<Pair<Object,MPIMessage>> pendingReceiveMessages){
  while (pendingReceiveMessages.size() > 0) {
    Pair<Object,MPIMessage> pair=pendingReceiveMessages.peek();
    MPIMessage.ReceivedState state=pair.getRight().getReceivedState();
    MPIMessage currentMessage=pair.getRight();
    Object object=pair.getLeft();
    if (state == MPIMessage.ReceivedState.INIT) {
      currentMessage.incrementRefCount();
    }
    if (state == MPIMessage.ReceivedState.DOWN || state == MPIMessage.ReceivedState.INIT) {
      currentMessage.setReceivedState(MPIMessage.ReceivedState.DOWN);
      if (!receiver.passMessageDownstream(object,currentMessage)) {
        break;
      }
      currentMessage.setReceivedState(MPIMessage.ReceivedState.RECEIVE);
      if (!receiver.receiveMessage(currentMessage,object)) {
        break;
      }
      currentMessage.release();
      pendingReceiveMessages.poll();
    }
 else     if (state == MPIMessage.ReceivedState.RECEIVE) {
      currentMessage.setReceivedState(MPIMessage.ReceivedState.RECEIVE);
      if (!receiver.receiveMessage(currentMessage,object)) {
        break;
      }
      currentMessage.release();
      pendingReceiveMessages.poll();
    }
  }
}

Fixed version (ground truth):
private void receiveProgress(Queue<Pair<Object,MPIMessage>> pendingReceiveMessages){
  while (pendingReceiveMessages.size() > 0) {
    Pair<Object,MPIMessage> pair=pendingReceiveMessages.peek();
    MPIMessage.ReceivedState state=pair.getRight().getReceivedState();
    MPIMessage currentMessage=pair.getRight();
    Object object=pair.getLeft();
    LOG.info("String_Node_Str");
    LOG.info("String_Node_Str" + state);
    LOG.info("String_Node_Str");
    if (state == MPIMessage.ReceivedState.INIT) {
      currentMessage.incrementRefCount();
    }
    if (state == MPIMessage.ReceivedState.DOWN || state == MPIMessage.ReceivedState.INIT) {
      currentMessage.setReceivedState(MPIMessage.ReceivedState.DOWN);
      if (!receiver.passMessageDownstream(object,currentMessage)) {
        break;
      }
      currentMessage.setReceivedState(MPIMessage.ReceivedState.RECEIVE);
      if (!receiver.receiveMessage(currentMessage,object)) {
        break;
      }
      currentMessage.release();
      pendingReceiveMessages.poll();
    }
 else     if (state == MPIMessage.ReceivedState.RECEIVE) {
      LOG.info("String_Node_Str");
      LOG.info("String_Node_Str" + state);
      LOG.info("String_Node_Str");
      currentMessage.setReceivedState(MPIMessage.ReceivedState.RECEIVE);
      if (!receiver.receiveMessage(currentMessage,object)) {
        break;
      }
      currentMessage.release();
      pendingReceiveMessages.poll();
    }
  }
}
Program: 173052
Project: 173052
Buggy source:
@Override public boolean receiveMessage(MPIMessage currentMessage,Object object){
  MessageHeader header=currentMessage.getHeader();
  LG.info("String_Node_Str");
  LG.info("String_Node_Str" + header.toString());
  LG.info("String_Node_Str" + currentMessage.toString());
  LG.info("String_Node_Str" + object.toString());
  LG.info("String_Node_Str" + header.getSourceId());
  LG.info("String_Node_Str" + header.getSourceId());
  LG.info("String_Node_Str");
  return finalReceiver.onMessage(header.getSourceId(),0,destination,header.getFlags(),object);
}

Fixed version (ground truth):
@Override public boolean receiveMessage(MPIMessage currentMessage,Object object){
  MessageHeader header=currentMessage.getHeader();
  LG.info("String_Node_Str");
  LG.info("String_Node_Str" + header.toString());
  LG.info("String_Node_Str" + currentMessage.toString());
  LG.info("String_Node_Str" + object.toString());
  LG.info("String_Node_Str" + header.getSourceId());
  LG.info("String_Node_Str" + header.getSourceId());
  LG.info("String_Node_Str");
  return finalReceiver.onMessage(header.getSourceId(),MPIContext.DEFAULT_PATH,destination,header.getFlags(),object);
}
Program: 173053
Project: 173053
Buggy source:
public MPIDirectDataFlowCommunication(TWSChannel channel,Set<Integer> srcs,int dest,MessageReceiver finalRcvr){
  this.sources=srcs;
  this.destination=dest;
  this.finalReceiver=finalRcvr;
  this.delegete=new MPIDataFlowOperation(channel);
}

Fixed version (ground truth):
public MPIDirectDataFlowCommunication(TWSChannel channel,Set<Integer> srcs,int dest,MessageReceiver finalRcvr){
  this.sources=srcs;
  this.destination=dest;
  this.finalReceiver=finalRcvr;
  this.delegete=new MPIDataFlowOperation(channel);
  this.finalReceiverProgress=new AtomicBoolean(false);
}
Program: 173054
Project: 173054
Buggy source:
public ProgressionTracker(Set<Integer> items){
  if (items.size() == 0) {
    canProgress=false;
  }
 else {
    canProgress=true;
    this.progressItems=new ArrayBlockingQueue<>(items.size());
    for (    int i : items) {
      progressItems.offer(i);
    }
  }
}

Fixed version (ground truth):
public ProgressionTracker(Set<Integer> items){
  if (items.size() == 0) {
    LOG.info("String_Node_Str" + items.size());
    canProgress=false;
  }
 else {
    LOG.info("String_Node_Str" + items.size());
    canProgress=true;
    this.progressItems=new ArrayBlockingQueue<>(items.size());
    for (    int i : items) {
      progressItems.offer(i);
    }
  }
}
Program: 173056
Project: 173056
Buggy source:
public boolean receiveMessage(MPIMessage currentMessage,Object object){
  MessageHeader header=currentMessage.getHeader();
  return finalReceiver.onMessage(header.getSourceId(),MPIContext.DEFAULT_PATH,router.mainTaskOfExecutor(instancePlan.getThisExecutor(),MPIContext.DEFAULT_PATH),header.getFlags(),object);
}

Fixed version (ground truth):
public boolean receiveMessage(MPIMessage currentMessage,Object object){
  MessageHeader header=currentMessage.getHeader();
  return finalReceiver.onMessage(header.getSourceId(),MPIContext.DEFAULT_PATH,header.getDestinationIdentifier(),header.getFlags(),object);
}
Program: 173057
Project: 173057
Buggy source:
/** 
 * Progress the serializations
 */
public void progress(){
  if (partialSendAttempts > 1000000 || sendAttempts > 1000000 || sendCount > 5900) {
    String s="String_Node_Str";
    for (    Map.Entry<Integer,Queue<MPIBuffer>> e : receiveBuffers.entrySet()) {
      s+=e.getKey() + "String_Node_Str" + e.getValue().size()+ "String_Node_Str";
    }
    LOG.info(String.format("String_Node_Str",executor,sendCount,receiveCount,sendBufferReleaseCount,receiveBufferReleaseCount,s,sendsOfferred,sendsPartialOfferred));
    ((TWSMPIChannel)channel).setDebug(true);
  }
  if (sendProgressTracker.canProgress()) {
    int sendId=sendProgressTracker.next();
    if (sendId != Integer.MIN_VALUE) {
      sendProgress(pendingSendMessagesPerSource.get(sendId),sendId);
      sendProgressTracker.finish(sendId);
    }
  }
  if (deserializeProgressTracker.canProgress()) {
    int deserializeId=deserializeProgressTracker.next();
    if (deserializeId != Integer.MIN_VALUE) {
      receiveDeserializeProgress(pendingReceiveDeSerializations.get(deserializeId).poll(),deserializeId);
      deserializeProgressTracker.finish(deserializeId);
    }
  }
  if (receiveProgressTracker.canProgress()) {
    int receiveId=receiveProgressTracker.next();
    if (receiveId != Integer.MIN_VALUE) {
      receiveProgress(pendingReceiveMessagesPerSource.get(receiveId));
      receiveProgressTracker.finish(receiveId);
    }
  }
}

Fixed version (ground truth):
/** 
 * Progress the serializations
 */
public void progress(){
  if (partialSendAttempts > 1000000 || sendAttempts > 1000000) {
    String s="String_Node_Str";
    for (    Map.Entry<Integer,Queue<MPIBuffer>> e : receiveBuffers.entrySet()) {
      s+=e.getKey() + "String_Node_Str" + e.getValue().size()+ "String_Node_Str";
    }
    LOG.info(String.format("String_Node_Str",executor,sendCount,receiveCount,sendBufferReleaseCount,receiveBufferReleaseCount,s,sendsOfferred,sendsPartialOfferred));
    ((TWSMPIChannel)channel).setDebug(true);
  }
  if (sendProgressTracker.canProgress()) {
    int sendId=sendProgressTracker.next();
    if (sendId != Integer.MIN_VALUE) {
      sendProgress(pendingSendMessagesPerSource.get(sendId),sendId);
      sendProgressTracker.finish(sendId);
    }
  }
  if (deserializeProgressTracker.canProgress()) {
    int deserializeId=deserializeProgressTracker.next();
    if (deserializeId != Integer.MIN_VALUE) {
      receiveDeserializeProgress(pendingReceiveDeSerializations.get(deserializeId).poll(),deserializeId);
      deserializeProgressTracker.finish(deserializeId);
    }
  }
  if (receiveProgressTracker.canProgress()) {
    int receiveId=receiveProgressTracker.next();
    if (receiveId != Integer.MIN_VALUE) {
      receiveProgress(pendingReceiveMessagesPerSource.get(receiveId));
      receiveProgressTracker.finish(receiveId);
    }
  }
}
Program: 173058
Project: 173058
Buggy source:
@Override public void init(Config cfg,DataFlowOperation op,Map<Integer,List<Integer>> expectedIds){
  this.executor=op.getTaskPlan().getThisExecutor();
  this.operation=op;
  this.sendPendingMax=MPIContext.sendPendingMax(cfg);
  this.reducedValues=new ArrayBlockingQueue<>(sendPendingMax);
  for (  Map.Entry<Integer,List<Integer>> e : expectedIds.entrySet()) {
    Map<Integer,List<Object>> messagesPerTask=new HashMap<>();
    Map<Integer,Integer> countsPerTask=new HashMap<>();
    Map<Integer,Integer> totalCountsPerTask=new HashMap<>();
    for (    int i : e.getValue()) {
      messagesPerTask.put(i,new ArrayList<Object>());
      countsPerTask.put(i,0);
      totalCountsPerTask.put(i,0);
    }
    LOG.fine(String.format("String_Node_Str",executor,e.getKey(),e.getValue().toString()));
    messages.put(e.getKey(),messagesPerTask);
    counts.put(e.getKey(),countsPerTask);
    totalCounts.put(e.getKey(),totalCountsPerTask);
  }
}

Fixed version (ground truth):
@Override public void init(Config cfg,DataFlowOperation op,Map<Integer,List<Integer>> expectedIds){
  this.executor=op.getTaskPlan().getThisExecutor();
  this.operation=op;
  this.sendPendingMax=MPIContext.sendPendingMax(cfg);
  this.reducedValues=new ArrayBlockingQueue<>(sendPendingMax);
  for (  Map.Entry<Integer,List<Integer>> e : expectedIds.entrySet()) {
    Map<Integer,Queue<Object>> messagesPerTask=new HashMap<>();
    Map<Integer,Integer> countsPerTask=new HashMap<>();
    Map<Integer,Integer> totalCountsPerTask=new HashMap<>();
    for (    int i : e.getValue()) {
      messagesPerTask.put(i,new ArrayBlockingQueue<>(sendPendingMax * 4));
      countsPerTask.put(i,0);
      totalCountsPerTask.put(i,0);
    }
    LOG.fine(String.format("String_Node_Str",executor,e.getKey(),e.getValue().toString()));
    messages.put(e.getKey(),messagesPerTask);
    counts.put(e.getKey(),countsPerTask);
    totalCounts.put(e.getKey(),totalCountsPerTask);
  }
}
Program: 173059
Project: 173059
Buggy source:
@Override public boolean onMessage(int source,int path,int target,int flags,Object object){
  boolean canAdd=true;
  List<Object> m=messages.get(target).get(source);
  Integer c=counts.get(target).get(source);
  if (m.size() > sendPendingMax * 4) {
    canAdd=false;
    onMessageAttempts++;
  }
 else {
    onMessageAttempts=0;
    m.add(object);
    counts.get(target).put(source,c + 1);
    Integer tc=totalCounts.get(target).get(source);
    totalCounts.get(target).put(source,tc + 1);
  }
  return canAdd;
}

Fixed version (ground truth):
@Override public boolean onMessage(int source,int path,int target,int flags,Object object){
  boolean canAdd=true;
  Queue<Object> m=messages.get(target).get(source);
  Integer c=counts.get(target).get(source);
  if (m.size() >= sendPendingMax * 4) {
    canAdd=false;
    onMessageAttempts++;
  }
 else {
    onMessageAttempts=0;
    m.offer(object);
    counts.get(target).put(source,c + 1);
    Integer tc=totalCounts.get(target).get(source);
    totalCounts.get(target).put(source,tc + 1);
  }
  return canAdd;
}
Program: 173060
Project: 173060
Buggy source:
@Override public void progress(){
  for (  int t : messages.keySet()) {
    boolean canProgress=true;
    Map<Integer,List<Object>> messagePerTarget=messages.get(t);
    Map<Integer,Integer> countsPerTarget=counts.get(t);
    Map<Integer,Integer> totalCountMap=totalCounts.get(t);
    while (canProgress) {
      boolean found=true;
      for (      Map.Entry<Integer,List<Object>> e : messagePerTarget.entrySet()) {
        if (e.getValue().size() == 0) {
          found=false;
          canProgress=false;
        }
      }
      if (found && reducedValues.size() < sendPendingMax) {
        Object previous=null;
        for (        Map.Entry<Integer,List<Object>> e : messagePerTarget.entrySet()) {
          if (previous == null) {
            previous=e.getValue().remove(0);
          }
 else {
            Object current=e.getValue().remove(0);
            previous=reduceFunction.reduce(previous,current);
          }
        }
        if (previous != null) {
          reducedValues.offer(previous);
        }
      }
 else {
        progressAttempts++;
      }
      if (reducedValues.size() > 0) {
        Object previous=reducedValues.peek();
        boolean handle=handleMessage(t,previous,0,destination);
        if (handle) {
          reducedValues.poll();
          for (          Map.Entry<Integer,Integer> e : countsPerTarget.entrySet()) {
            Integer i=e.getValue();
            countsPerTarget.put(e.getKey(),i - 1);
          }
        }
 else {
          canProgress=false;
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void progress(){
  for (  int t : messages.keySet()) {
    boolean canProgress=true;
    Map<Integer,Queue<Object>> messagePerTarget=messages.get(t);
    Map<Integer,Integer> countsPerTarget=counts.get(t);
    Map<Integer,Integer> totalCountMap=totalCounts.get(t);
    while (canProgress) {
      boolean found=true;
      for (      Map.Entry<Integer,Queue<Object>> e : messagePerTarget.entrySet()) {
        if (e.getValue().size() == 0) {
          found=false;
          canProgress=false;
        }
      }
      if (found && reducedValues.size() < sendPendingMax) {
        Object previous=null;
        for (        Map.Entry<Integer,Queue<Object>> e : messagePerTarget.entrySet()) {
          if (previous == null) {
            previous=e.getValue().poll();
          }
 else {
            Object current=e.getValue().poll();
            previous=reduceFunction.reduce(previous,current);
          }
        }
        if (previous != null) {
          reducedValues.offer(previous);
        }
        progressAttempts=0;
      }
 else {
        progressAttempts++;
      }
      if (reducedValues.size() > 0) {
        Object previous=reducedValues.peek();
        boolean handle=handleMessage(t,previous,0,destination);
        if (handle) {
          reducedValues.poll();
          for (          Map.Entry<Integer,Integer> e : countsPerTarget.entrySet()) {
            Integer i=e.getValue();
            countsPerTarget.put(e.getKey(),i - 1);
          }
        }
 else {
          canProgress=false;
        }
      }
    }
  }
}
Program: 173061
Project: 173061
Buggy source:
@Override public void run(){
  try {
    LOG.log(Level.INFO,"String_Node_Str" + id);
    IntData data=generateData();
    for (int i=0; i < 6000; i++) {
      while (!reduce.send(task,data,0)) {
        reduce.progress();
        Thread.yield();
      }
      if (i % 100 == 0) {
        LOG.info(String.format("String_Node_Str",id,i));
      }
    }
    LOG.info(String.format("String_Node_Str",id));
    status=Status.MAP_FINISHED;
  }
 catch (  Throwable t) {
    t.printStackTrace();
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    LOG.log(Level.INFO,"String_Node_Str" + id);
    IntData data=generateData();
    for (int i=0; i < 6000; i++) {
      while (!reduce.send(task,data,0)) {
        reduce.progress();
        Thread.yield();
      }
      if (i % 100 == 0 || i > 5990) {
        LOG.info(String.format("String_Node_Str",id,i));
      }
    }
    LOG.info(String.format("String_Node_Str",id));
    status=Status.MAP_FINISHED;
  }
 catch (  Throwable t) {
    t.printStackTrace();
  }
}
Program: 173062
Project: 173062
Buggy source:
/** 
 * Setup the receives and send sendBuffers
 */
protected void setupCommunication(){
  int maxReceiveBuffers=MPIContext.receiveBufferCount(config);
  int receiveBufferSize=MPIContext.bufferSize(config);
  for (  Integer recv : receivingExecutors) {
    Queue<MPIBuffer> recvList=new LinkedList<>();
    for (int i=0; i < maxReceiveBuffers; i++) {
      recvList.add(new MPIBuffer(receiveBufferSize));
    }
    LOG.fine(instancePlan.getThisExecutor() + "String_Node_Str" + recv);
    channel.receiveMessage(recv,edge,this,recvList);
    receiveBuffers.put(recv,recvList);
  }
  int sendBufferSize=MPIContext.bufferSize(config);
  int sendBufferCount=MPIContext.sendBuffersCount(config);
  for (int i=0; i < sendBufferCount; i++) {
    MPIBuffer buffer=new MPIBuffer(sendBufferSize);
    sendBuffers.offer(buffer);
  }
}

Fixed version (ground truth):
/** 
 * Setup the receives and send sendBuffers
 */
protected void setupCommunication(){
  int maxReceiveBuffers=MPIContext.receiveBufferCount(config);
  int receiveBufferSize=MPIContext.bufferSize(config);
  for (  Integer recv : receivingExecutors) {
    Queue<MPIBuffer> recvList=new LinkedBlockingQueue<>();
    for (int i=0; i < maxReceiveBuffers; i++) {
      recvList.add(new MPIBuffer(receiveBufferSize));
    }
    LOG.fine(instancePlan.getThisExecutor() + "String_Node_Str" + recv);
    channel.receiveMessage(recv,edge,this,recvList);
    receiveBuffers.put(recv,recvList);
  }
  int sendBufferSize=MPIContext.bufferSize(config);
  int sendBufferCount=MPIContext.sendBuffersCount(config);
  for (int i=0; i < sendBufferCount; i++) {
    MPIBuffer buffer=new MPIBuffer(sendBufferSize);
    sendBuffers.offer(buffer);
  }
}