nus-yam/ex-repair huggingface dataset:
Program: 172988
Project: 172988
Buggy source:
@Override public boolean onMessage(int source,int destination,int target,int flags,Object object){
  byte[] d=(byte[])object;
  merger.add(d,d.length);
  return true;
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public boolean onMessage(int source,int destination,int target,int flags,Object object){
  if (keyed) {
    List<KeyedContent> keyedContents=(List<KeyedContent>)object;
    for (    KeyedContent kc : keyedContents) {
      Object data=kc.getValue();
      byte[] d=kryoSerializer.serialize(data);
      sortedMerger.add(kc.getKey(),d,d.length);
    }
  }
 else {
    List<Object> contents=(List<Object>)object;
    for (    Object kc : contents) {
      byte[] d=kryoSerializer.serialize(kc);
      sortedMerger.add(d,d.length);
    }
  }
  return true;
}
Program: 172989
Project: 172989
Buggy source:
@Override public void onFinish(){
  merger.switchToReading();
  Iterator<Object> itr=merger.readIterator();
  batchReceiver.receive(0,itr);
}

Fixed version (ground truth):
@Override public void onFinish(){
  sortedMerger.switchToReading();
  Iterator<Object> itr=sortedMerger.readIterator();
  batchReceiver.receive(0,itr);
}
Program: 172990
Project: 172990
Buggy source:
public PartitionBatchFinalReceiver(GatherBatchReceiver receiver,boolean srt,boolean d){
  this.batchReceiver=receiver;
  this.sorted=srt;
  this.disk=d;
}

Fixed version (ground truth):
public PartitionBatchFinalReceiver(GatherBatchReceiver receiver,boolean srt,boolean d){
  this.batchReceiver=receiver;
  this.sorted=srt;
  this.disk=d;
  this.kryoSerializer=new KryoSerializer();
}
Program: 172991
Project: 172991
Buggy source:
@Override public boolean onMessage(int src,int destination,int target,int flags,Object object){
  this.source=src;
  List<Object> dests=destinationMessages.get(destination);
  int size=dests.size();
  if (size > highWaterMark) {
    return false;
  }
  dests.add(new ImmutableTriple<>(object,src,flags));
  if (dests.size() > lowWaterMark) {
    readyToSend.put(destination,dests);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onMessage(int src,int destination,int target,int flags,Object object){
  this.source=src;
  List<Object> dests=destinationMessages.get(destination);
  int size=dests.size();
  if (size > highWaterMark) {
    return false;
  }
  dests.add(object);
  if (dests.size() > lowWaterMark) {
    lock.lock();
    try {
      readyToSend.put(destination,new ArrayList<>(dests));
      dests.clear();
    }
  finally {
      lock.unlock();
    }
  }
  return true;
}
Program: 172992
Project: 172992
Buggy source:
@Override public void progress(){
  Iterator<Map.Entry<Integer,List<Object>>> it=readyToSend.entrySet().iterator();
  while (it.hasNext()) {
    Map.Entry<Integer,List<Object>> e=it.next();
    List<Object> send=new ArrayList<>(e.getValue());
    if (operation.sendPartial(source,send,0,e.getKey())) {
      e.getValue().clear();
      it.remove();
    }
  }
}

Fixed version (ground truth):
@Override public void progress(){
  lock.lock();
  try {
    Iterator<Map.Entry<Integer,List<Object>>> it=readyToSend.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry<Integer,List<Object>> e=it.next();
      List<Object> send=new ArrayList<>(e.getValue());
      if (operation.sendPartial(source,send,0,e.getKey())) {
        e.getValue().clear();
        it.remove();
      }
    }
  }
  finally {
    lock.unlock();
  }
}
Program: 172993
Project: 172993
Buggy source:
@Override public boolean onMessage(int source,int path,int target,int flags,Object object){
  if (object instanceof List) {
    for (    Object o : (List)object) {
      if (o instanceof KeyedContent) {
        addValue(((KeyedContent)o).getObject().toString());
      }
 else {
        addValue(o.toString());
      }
    }
  }
 else   if (object instanceof KeyedContent) {
    String value=((KeyedContent)object).getObject().toString();
    addValue(value);
  }
 else {
    addValue(object.toString());
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onMessage(int source,int path,int target,int flags,Object object){
  if (object instanceof List) {
    for (    Object o : (List)object) {
      if (o instanceof KeyedContent) {
        addValue(((KeyedContent)o).getValue().toString());
      }
 else {
        addValue(o.toString());
      }
    }
  }
 else   if (object instanceof KeyedContent) {
    String value=((KeyedContent)object).getValue().toString();
    addValue(value);
  }
 else {
    addValue(object.toString());
  }
  return true;
}
Program: 172994
Project: 172994
Buggy source:
/** 
 * The actual message callback
 * @param object the actual message
 */
boolean onMessage(int source,int destination,int target,int flags,Object object);

Fixed version (ground truth):
/** 
 * The actual message callback
 * @param source  the source task
 * @param destination the final destination
 * @param target the target of this receiver
 * @param flags the communication flags
 * @param object the actual message
 * @return true if the message is accepted
 */
boolean onMessage(int source,int destination,int target,int flags,Object object);
Program: 172995
Project: 172995
Buggy source:
public boolean receiveSendInternally(int source,int t,int path,int flags,Object message){
  if (source == path) {
    return finalReceiver.onMessage(source,path,t,flags,message);
  }
  return partialReceiver.onMessage(source,path,t,flags,message);
}

Fixed version (ground truth):
public boolean receiveSendInternally(int source,int t,int destination,int flags,Object message){
  if (source == destination) {
    return finalReceiver.onMessage(source,destination,t,flags,message);
  }
  return partialReceiver.onMessage(source,destination,t,flags,message);
}
Program: 172997
Project: 172997
Buggy source:
private void buildHeader(MPIBuffer buffer,MPISendMessage sendMessage){
  if (buffer.getCapacity() < 16) {
    throw new RuntimeException("String_Node_Str");
  }
  ByteBuffer byteBuffer=buffer.getByteBuffer();
  byteBuffer.putInt(sendMessage.getSource());
  byteBuffer.putInt(sendMessage.getFlags());
  byteBuffer.putInt(sendMessage.getDestintationIdentifier());
  byteBuffer.putInt(0);
  sendMessage.setWrittenHeaderSize(16);
  buffer.setSize(16);
}

Fixed version (ground truth):
private void buildHeader(MPIBuffer buffer,MPISendMessage sendMessage){
  if (buffer.getCapacity() < HEADER_SIZE) {
    throw new RuntimeException("String_Node_Str");
  }
  ByteBuffer byteBuffer=buffer.getByteBuffer();
  byteBuffer.putInt(sendMessage.getSource());
  byteBuffer.putInt(sendMessage.getFlags());
  byteBuffer.putInt(sendMessage.getDestintationIdentifier());
  byteBuffer.putInt(0);
  sendMessage.setWrittenHeaderSize(HEADER_SIZE);
  buffer.setSize(16);
}
Program: 172998
Project: 172998
Buggy source:
public RRServer(Config cfg,String host,int port,Progress loop){
  server=new Server(cfg,host,port,loop,new Handler(),false);
}

Fixed version (ground truth):
public RRServer(Config cfg,String host,int port,Progress loop,int wId){
  this.workerId=wId;
  server=new Server(cfg,host,port,loop,new Handler(),false);
}
Program: 172999
Project: 172999
Buggy source:
@Override public void onReceiveComplete(SocketChannel channel,TCPMessage readRequest){
  ByteBuffer data=readRequest.getByteBuffer();
  byte[] id=new byte[RequestID.ID_SIZE];
  data.get(id);
  String messageType=ByteUtils.unPackString(data);
  int serverWorkerId=data.getInt();
  RequestID requestID=RequestID.fromBytes(id);
  Message.Builder builder=messageBuilders.get(messageType);
  if (builder == null) {
    throw new RuntimeException("String_Node_Str");
  }
  try {
    builder.mergeFrom(data.array());
    Message m=builder.build();
    MessageHandler handler=requests.get(requestID);
    handler.onMessage(requestID,serverWorkerId,m);
  }
 catch (  InvalidProtocolBufferException e) {
    LOG.log(Level.SEVERE,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
@Override public void onReceiveComplete(SocketChannel channel,TCPMessage readRequest){
  ByteBuffer data=readRequest.getByteBuffer();
  byte[] id=new byte[RequestID.ID_SIZE];
  data.get(id);
  String messageType=ByteUtils.unPackString(data);
  int clientId=data.getInt();
  RequestID requestID=RequestID.fromBytes(id);
  Message.Builder builder=messageBuilders.get(messageType);
  if (builder == null) {
    throw new RuntimeException("String_Node_Str");
  }
  try {
    builder.mergeFrom(data.array());
    Message m=builder.build();
    MessageHandler handler=requestHandlers.get(messageType);
    handler.onMessage(requestID,clientId,m);
    requestToWorkers.put(requestID,clientId);
    requestChannels.put(requestID,channel);
  }
 catch (  InvalidProtocolBufferException e) {
    LOG.log(Level.SEVERE,"String_Node_Str",e);
  }
}
Program: 173000
Project: 173000
Buggy source:
public boolean sendResponse(RequestID id,Message message){
  if (requestChannels.containsKey(id)) {
    LOG.log(Level.SEVERE,"String_Node_Str");
    return false;
  }
  SocketChannel channel=requestChannels.get(id);
  if (!socketChannels.contains(channel)) {
    LOG.log(Level.WARNING,"String_Node_Str");
    return false;
  }
  byte[] data=message.toByteArray();
  int clientWorkerId=requestToWorkers.get(id);
  String messageType=message.getDescriptorForType().getFullName();
  int capacity=id.getId().length + data.length + 4;
  ByteBuffer buffer=ByteBuffer.allocate(capacity);
  buffer.put(id.getId());
  ByteUtils.packString(messageType,buffer);
  buffer.putInt(clientWorkerId);
  buffer.put(data);
  TCPMessage request=server.send(channel,buffer,capacity,0);
  return request != null;
}

Fixed version (ground truth):
/** 
 * Send a response to a request id
 * @param id request id
 * @param message message
 * @return true if response was accepted
 */
public boolean sendResponse(RequestID id,Message message){
  if (requestChannels.containsKey(id)) {
    LOG.log(Level.SEVERE,"String_Node_Str");
    return false;
  }
  SocketChannel channel=requestChannels.get(id);
  if (!socketChannels.contains(channel)) {
    LOG.log(Level.WARNING,"String_Node_Str");
    return false;
  }
  byte[] data=message.toByteArray();
  int clientWorkerId=requestToWorkers.get(id);
  String messageType=message.getDescriptorForType().getFullName();
  int capacity=id.getId().length + data.length + 4;
  ByteBuffer buffer=ByteBuffer.allocate(capacity);
  buffer.put(id.getId());
  ByteUtils.packString(messageType,buffer);
  buffer.putInt(workerId);
  buffer.put(data);
  TCPMessage request=server.send(channel,buffer,capacity,0);
  if (request != null) {
    requestChannels.remove(id);
    requestToWorkers.remove(id);
    return true;
  }
 else {
    return false;
  }
}
Program: 173001
Project: 173001
Buggy source:
@Override public void onReceiveComplete(SocketChannel ch,TCPMessage readRequest){
  ByteBuffer data=readRequest.getByteBuffer();
  byte[] id=new byte[RequestID.ID_SIZE];
  data.get(id);
  String messageType=ByteUtils.unPackString(data);
  int serverWorkerId=data.getInt();
  RequestID requestID=RequestID.fromBytes(id);
  Message.Builder builder=messageBuilders.get(messageType);
  if (builder == null) {
    throw new RuntimeException("String_Node_Str");
  }
  try {
    builder.mergeFrom(data.array());
    Message m=builder.build();
    MessageHandler handler=responseHandlers.get(messageType);
    if (handler == null) {
      LOG.log(Level.WARNING,"String_Node_Str" + messageType);
    }
 else {
      handler.onMessage(requestID,serverWorkerId,m);
    }
  }
 catch (  InvalidProtocolBufferException e) {
    LOG.log(Level.SEVERE,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
@Override public void onReceiveComplete(SocketChannel ch,TCPMessage readRequest){
  ByteBuffer data=readRequest.getByteBuffer();
  byte[] id=new byte[RequestID.ID_SIZE];
  data.get(id);
  String messageType=ByteUtils.unPackString(data);
  int serverWorkerId=data.getInt();
  RequestID requestID=RequestID.fromBytes(id);
  Message.Builder builder=messageBuilders.get(messageType);
  if (builder == null) {
    throw new RuntimeException("String_Node_Str");
  }
  try {
    builder.clear();
    int headerLength=8 + id.length + messageType.getBytes().length;
    int dataLength=readRequest.getLength() - headerLength;
    byte[] d=new byte[dataLength];
    data.get(d);
    builder.mergeFrom(d);
    Message m=builder.build();
    MessageHandler handler=responseHandlers.get(messageType);
    if (handler == null) {
      LOG.log(Level.WARNING,"String_Node_Str" + messageType);
    }
 else {
      handler.onMessage(requestID,serverWorkerId,m);
    }
  }
 catch (  InvalidProtocolBufferException e) {
    LOG.log(Level.SEVERE,"String_Node_Str",e);
  }
}
Program: 173002
Project: 173002
Buggy source:
@Override public void onReceiveComplete(SocketChannel channel,TCPMessage readRequest){
  ByteBuffer data=readRequest.getByteBuffer();
  byte[] id=new byte[RequestID.ID_SIZE];
  data.get(id);
  String messageType=ByteUtils.unPackString(data);
  int clientId=data.getInt();
  RequestID requestID=RequestID.fromBytes(id);
  Message.Builder builder=messageBuilders.get(messageType);
  if (builder == null) {
    throw new RuntimeException("String_Node_Str");
  }
  try {
    builder.mergeFrom(data.array());
    Message m=builder.build();
    MessageHandler handler=requestHandlers.get(messageType);
    handler.onMessage(requestID,clientId,m);
    requestToWorkers.put(requestID,clientId);
    requestChannels.put(requestID,channel);
  }
 catch (  InvalidProtocolBufferException e) {
    LOG.log(Level.SEVERE,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
@Override public void onReceiveComplete(SocketChannel channel,TCPMessage readRequest){
  ByteBuffer data=readRequest.getByteBuffer();
  byte[] id=new byte[RequestID.ID_SIZE];
  data.get(id);
  String messageType=ByteUtils.unPackString(data);
  int clientId=data.getInt();
  RequestID requestID=RequestID.fromBytes(id);
  Message.Builder builder=messageBuilders.get(messageType);
  if (builder == null) {
    throw new RuntimeException("String_Node_Str");
  }
  try {
    builder.clear();
    int headerLength=8 + id.length + messageType.getBytes().length;
    int dataLength=readRequest.getLength() - headerLength;
    byte[] d=new byte[dataLength];
    data.get(d);
    builder.mergeFrom(d);
    Message m=builder.build();
    MessageHandler handler=requestHandlers.get(messageType);
    handler.onMessage(requestID,clientId,m);
    requestToWorkers.put(requestID,clientId);
    requestChannels.put(requestID,channel);
  }
 catch (  InvalidProtocolBufferException e) {
    LOG.log(Level.SEVERE,"String_Node_Str",e);
  }
}
Program: 173003
Project: 173003
Buggy source:
@Override public void onMessage(RequestID id,int workerId,Message message){
  if (message instanceof Network.Ping) {
    System.out.println("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void onMessage(RequestID id,int workerId,Message message){
  if (message instanceof Network.Ping) {
    System.out.println("String_Node_Str");
    LOG.log(Level.INFO,"String_Node_Str");
  }
}
Program: 173004
Project: 173004
Buggy source:
public void prepare(){
  outputCollection=new DefaultOutputCollection(outQueue);
  task.prepare(config,new TaskContext(0,0,"String_Node_Str",0));
}

Fixed version (ground truth):
public void prepare(){
  outputCollection=new DefaultOutputCollection(outQueue);
  task.prepare(config,new TaskContext(0,0,"String_Node_Str",0,outputCollection));
}
Program: 173005
Project: 173005
Buggy source:
public void prepare(){
  outputCollection=new DefaultOutputCollection(outQueue);
  task.prepare(config,new TaskContext(0,0,"String_Node_Str",0));
}

Fixed version (ground truth):
public void prepare(){
  outputCollection=new DefaultOutputCollection(outQueue);
  task.prepare(config,new TaskContext(0,0,"String_Node_Str",0,outputCollection));
}
Program: 173006
Project: 173006
Buggy source:
public void execute(ExecutionPlan execution){
  Map<Integer,INodeInstance> nodes=execution.getNodes();
  tasks=new ArrayBlockingQueue<>(nodes.size() * 2);
  tasks.addAll(nodes.values());
  for (int i=0; i < numThreads; i++) {
    Thread t=new Thread(new Worker());
    t.start();
    threads.add(t);
  }
}

Fixed version (ground truth):
public void execute(ExecutionPlan execution){
  Map<Integer,INodeInstance> nodes=execution.getNodes();
  tasks=new ArrayBlockingQueue<>(nodes.size() * 2);
  tasks.addAll(nodes.values());
  for (  INodeInstance node : tasks) {
    node.prepare();
  }
  for (int i=0; i < numThreads; i++) {
    Thread t=new Thread(new Worker());
    t.start();
    threads.add(t);
  }
}
Program: 173007
Project: 173007
Buggy source:
@Override public void init(Config config,int id,ResourcePlan resourcePlan){
  Generator g=new Generator();
  Receiver r=new Receiver();
  GraphBuilder builder=GraphBuilder.newBuilder();
  builder.addSource("String_Node_Str",g);
  builder.addSink("String_Node_Str",r);
  DataFlowTaskGraph graph=builder.build();
  RoundRobinTaskScheduling roundRobinTaskScheduling=new RoundRobinTaskScheduling();
  roundRobinTaskScheduling.initialize(config);
  WorkerPlan workerPlan=createWorkerPlan(resourcePlan);
  TaskSchedulePlan taskSchedulePlan=roundRobinTaskScheduling.schedule(graph,workerPlan);
  TWSNetwork network=new TWSNetwork(config,resourcePlan.getThisId());
  DefaultExecutor defaultExecutor=new DefaultExecutor(resourcePlan,network);
  ExecutionPlan plan=defaultExecutor.schedule(config,graph,taskSchedulePlan);
  while (true) {
    network.getChannel().progress();
  }
}

Fixed version (ground truth):
@Override public void init(Config config,int id,ResourcePlan resourcePlan){
  Generator g=new Generator();
  Receiver r=new Receiver();
  GraphBuilder builder=GraphBuilder.newBuilder();
  builder.addSource("String_Node_Str",g);
  builder.setParallelism("String_Node_Str",4);
  builder.addSink("String_Node_Str",r);
  builder.setParallelism("String_Node_Str",4);
  builder.addConfiguration("String_Node_Str","String_Node_Str",512);
  builder.addConfiguration("String_Node_Str","String_Node_Str",1000);
  builder.addConfiguration("String_Node_Str","String_Node_Str",2);
  builder.addConfiguration("String_Node_Str","String_Node_Str",300);
  builder.addConfiguration("String_Node_Str","String_Node_Str",1000);
  builder.addConfiguration("String_Node_Str","String_Node_Str",2);
  DataFlowTaskGraph graph=builder.build();
  RoundRobinTaskScheduling roundRobinTaskScheduling=new RoundRobinTaskScheduling();
  roundRobinTaskScheduling.initialize(config);
  WorkerPlan workerPlan=createWorkerPlan(resourcePlan);
  TaskSchedulePlan taskSchedulePlan=roundRobinTaskScheduling.schedule(graph,workerPlan);
  TWSNetwork network=new TWSNetwork(config,resourcePlan.getThisId());
  DefaultExecutor defaultExecutor=new DefaultExecutor(resourcePlan,network);
  ExecutionPlan plan=defaultExecutor.schedule(config,graph,taskSchedulePlan);
  while (true) {
    network.getChannel().progress();
  }
}
Program: 173008
Project: 173008
Buggy source:
/** 
 * This method generate the container -> instance map
 */
public static Map<Integer,List<InstanceId>> RoundRobinSchedulingAlgorithm(Set<Vertex> taskVertexSet,int numberOfContainers){
  int taskIndex=1;
  int globalTaskIndex=1;
  TaskAttributes taskAttributes=new TaskAttributes();
  Map<Integer,List<InstanceId>> roundrobinAllocation=new HashMap<>();
  try {
    int totalInstances=taskAttributes.getTotalNumberOfInstances(taskVertexSet);
    Map<String,Integer> parallelTaskMap=taskAttributes.getParallelTaskMap(taskVertexSet);
    LOG.info(String.format("String_Node_Str" + numberOfContainers + "String_Node_Str"+ "String_Node_Str"+ totalInstances));
    for (int i=1; i <= numberOfContainers; i++) {
      roundrobinAllocation.put(i,new ArrayList<InstanceId>());
    }
    LOG.info(String.format("String_Node_Str" + roundrobinAllocation));
    System.out.println();
    for (    String task : parallelTaskMap.keySet()) {
      int numberOfInstances=parallelTaskMap.get(task);
      for (int i=0; i < numberOfInstances; i++) {
        roundrobinAllocation.get(taskIndex).add(new InstanceId(task,globalTaskIndex,i));
        if (taskIndex != numberOfContainers) {
          taskIndex=taskIndex + 1;
        }
 else {
          taskIndex=1;
        }
        globalTaskIndex+=1;
      }
    }
    LOG.info(String.format("String_Node_Str" + roundrobinAllocation));
    LOG.info("String_Node_Str");
  }
 catch (  NullPointerException ne) {
    ne.printStackTrace();
  }
  return roundrobinAllocation;
}

Fixed version (ground truth):
/** 
 * This method generate the container -> instance map
 */
public static Map<Integer,List<InstanceId>> RoundRobinSchedulingAlgorithm(Set<Vertex> taskVertexSet,int numberOfContainers){
  int taskIndex=1;
  int globalTaskIndex=1;
  TaskAttributes taskAttributes=new TaskAttributes();
  Map<Integer,List<InstanceId>> roundrobinAllocation=new HashMap<>();
  try {
    int totalInstances=taskAttributes.getTotalNumberOfInstances(taskVertexSet);
    Map<String,Integer> parallelTaskMap=taskAttributes.getParallelTaskMap(taskVertexSet);
    LOG.info(String.format("String_Node_Str" + numberOfContainers + "String_Node_Str"+ "String_Node_Str"+ totalInstances));
    for (int i=0; i < numberOfContainers; i++) {
      roundrobinAllocation.put(i,new ArrayList<InstanceId>());
    }
    LOG.info(String.format("String_Node_Str" + roundrobinAllocation));
    System.out.println();
    for (    String task : parallelTaskMap.keySet()) {
      int numberOfInstances=parallelTaskMap.get(task);
      for (int i=0; i < numberOfInstances; i++) {
        roundrobinAllocation.get(taskIndex).add(new InstanceId(task,globalTaskIndex,i));
        if (taskIndex != numberOfContainers) {
          taskIndex=taskIndex + 1;
        }
 else {
          taskIndex=1;
        }
        globalTaskIndex+=1;
      }
    }
    LOG.info(String.format("String_Node_Str" + roundrobinAllocation));
    LOG.info("String_Node_Str");
  }
 catch (  NullPointerException ne) {
    ne.printStackTrace();
  }
  return roundrobinAllocation;
}
Program: 173009
Project: 173009
Buggy source:
private void init(List<KeyValue> inMemoryValues){
  for (int i=0; i < noOfFiles; i++) {
    String fileName=folder + "String_Node_Str" + i;
    Triple<List<KeyValue>,Long,Long> fileParts=FileLoader.openFilePart(fileName,0,openBytes,keyType,dataType,deserializer);
    openList.add(new FilePart(fileParts));
  }
  openList.add(new FilePart(new ImmutableTriple<>(inMemoryValues,0l,0l)));
  for (int i=0; i < openList.size(); i++) {
    FilePart p=openList.get(i);
    List<KeyValue> list=p.keyValues.getLeft();
    if (list.size() > p.currentIndex) {
      heap.insert(list.get(p.currentIndex),i);
      p.currentIndex++;
    }
  }
}

Fixed version (ground truth):
private void init(List<KeyValue> inMemoryValues){
  for (int i=0; i < noOfFiles; i++) {
    String fileName=folder + "String_Node_Str" + i;
    Triple<List<KeyValue>,Long,Long> fileParts=FileLoader.openFilePart(fileName,0,openBytes,keyType,dataType,deserializer);
    openList.add(new FilePart(fileParts));
  }
  openList.add(new FilePart(new ImmutableTriple<>(inMemoryValues,0L,0L)));
  for (int i=0; i < openList.size(); i++) {
    FilePart p=openList.get(i);
    List<KeyValue> list=p.keyValues.getLeft();
    if (list.size() > p.currentIndex) {
      heap.insert(list.get(p.currentIndex),i);
      p.currentIndex++;
    }
  }
}
Program: 173010
Project: 173010
Buggy source:
public FilePart(Triple<List<KeyValue>,Long,Long> keyValues){
  this.keyValues=keyValues;
}

Fixed version (ground truth):
FilePart(Triple<List<KeyValue>,Long,Long> keyValues){
  this.keyValues=keyValues;
}
Program: 173011
Project: 173011
Buggy source:
@Override public void init(Config config,int id,ResourcePlan resourcePlan){
  Generator g=new Generator();
  Receiver r=new Receiver();
  GraphBuilder builder=GraphBuilder.newBuilder();
  builder.addSource("String_Node_Str",g);
  builder.setParallelism("String_Node_Str",4);
  builder.addSink("String_Node_Str",r);
  builder.setParallelism("String_Node_Str",4);
  builder.addConfiguration("String_Node_Str","String_Node_Str",512);
  builder.addConfiguration("String_Node_Str","String_Node_Str",1000);
  builder.addConfiguration("String_Node_Str","String_Node_Str",2);
  builder.addConfiguration("String_Node_Str","String_Node_Str",300);
  builder.addConfiguration("String_Node_Str","String_Node_Str",1000);
  builder.addConfiguration("String_Node_Str","String_Node_Str",2);
  builder.connect("String_Node_Str","String_Node_Str",Operations.PARTITION);
  DataFlowTaskGraph graph=builder.build();
  RoundRobinTaskScheduling roundRobinTaskScheduling=new RoundRobinTaskScheduling();
  roundRobinTaskScheduling.initialize(config);
  WorkerPlan workerPlan=createWorkerPlan(resourcePlan);
  TaskSchedulePlan taskSchedulePlan=roundRobinTaskScheduling.schedule(graph,workerPlan);
  TWSNetwork network=new TWSNetwork(config,resourcePlan.getThisId());
  DefaultExecutor defaultExecutor=new DefaultExecutor(resourcePlan,network);
  ExecutionPlan plan=defaultExecutor.schedule(config,graph,taskSchedulePlan);
  while (true) {
    network.getChannel().progress();
  }
}

Fixed version (ground truth):
@Override public void init(Config config,int id,ResourcePlan resourcePlan){
  Generator g=new Generator();
  Receiver r=new Receiver();
  GraphBuilder builder=GraphBuilder.newBuilder();
  builder.addSource("String_Node_Str",g);
  builder.setParallelism("String_Node_Str",4);
  builder.addSink("String_Node_Str",r);
  builder.setParallelism("String_Node_Str",4);
  builder.addConfiguration("String_Node_Str","String_Node_Str",512);
  builder.addConfiguration("String_Node_Str","String_Node_Str",1000);
  builder.addConfiguration("String_Node_Str","String_Node_Str",2);
  builder.addConfiguration("String_Node_Str","String_Node_Str",300);
  builder.addConfiguration("String_Node_Str","String_Node_Str",1000);
  builder.addConfiguration("String_Node_Str","String_Node_Str",2);
  builder.connect("String_Node_Str","String_Node_Str","String_Node_Str",Operations.PARTITION);
  DataFlowTaskGraph graph=builder.build();
  RoundRobinTaskScheduling roundRobinTaskScheduling=new RoundRobinTaskScheduling();
  roundRobinTaskScheduling.initialize(config);
  WorkerPlan workerPlan=createWorkerPlan(resourcePlan);
  TaskSchedulePlan taskSchedulePlan=roundRobinTaskScheduling.schedule(graph,workerPlan);
  TWSNetwork network=new TWSNetwork(config,resourcePlan.getThisId());
  DefaultExecutor defaultExecutor=new DefaultExecutor(resourcePlan,network);
  ExecutionPlan plan=defaultExecutor.schedule(config,graph,taskSchedulePlan);
  while (true) {
    network.getChannel().progress();
  }
}
Program: 173012
Project: 173012
Buggy source:
/** 
 * Create an instance of a task,
 * @param cfg the configuration
 * @param ip instance plan
 * @param vertex vertex
 */
private void createInstances(Config cfg,TaskSchedulePlan.TaskInstancePlan ip,Vertex vertex){
  byte[] taskBytes=kryoMemorySerializer.serialize(vertex.getTask());
  INode newInstance=(INode)kryoMemorySerializer.deserialize(taskBytes);
  int taskId=taskIdGenerator.generateGlobalTaskId(vertex.getName(),ip.getTaskId(),ip.getTaskIndex());
  if (newInstance instanceof ITask) {
    taskInstances.put(vertex.getName(),taskId,new TaskInstance((ITask)newInstance,new ArrayBlockingQueue<>(1024),new ArrayBlockingQueue<>(1024),cfg,edgeGenerator));
  }
 else   if (newInstance instanceof ISource) {
    sourceInstances.put(vertex.getName(),taskId,new SourceInstance((ISource)newInstance,new ArrayBlockingQueue<>(1024),cfg));
  }
 else   if (newInstance instanceof ISink) {
    sinkInstances.put(vertex.getName(),taskId,new SinkInstance((ISink)newInstance,new ArrayBlockingQueue<>(1024),cfg));
  }
 else {
    throw new RuntimeException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Create an instance of a task,
 * @param cfg the configuration
 * @param ip instance plan
 * @param vertex vertex
 */
private INodeInstance createInstances(Config cfg,TaskSchedulePlan.TaskInstancePlan ip,Vertex vertex){
  byte[] taskBytes=kryoMemorySerializer.serialize(vertex.getTask());
  INode newInstance=(INode)kryoMemorySerializer.deserialize(taskBytes);
  int taskId=taskIdGenerator.generateGlobalTaskId(vertex.getName(),ip.getTaskId(),ip.getTaskIndex());
  if (newInstance instanceof ITask) {
    TaskInstance v=new TaskInstance((ITask)newInstance,new ArrayBlockingQueue<>(1024),new ArrayBlockingQueue<>(1024),cfg,edgeGenerator);
    taskInstances.put(vertex.getName(),taskId,v);
    return v;
  }
 else   if (newInstance instanceof ISource) {
    SourceInstance v=new SourceInstance((ISource)newInstance,new ArrayBlockingQueue<>(1024),cfg);
    sourceInstances.put(vertex.getName(),taskId,v);
    return v;
  }
 else   if (newInstance instanceof ISink) {
    SinkInstance v=new SinkInstance((ISink)newInstance,new ArrayBlockingQueue<>(1024),cfg);
    sinkInstances.put(vertex.getName(),taskId,v);
    return v;
  }
 else {
    throw new RuntimeException("String_Node_Str");
  }
}
Program: 173014
Project: 173014
Buggy source:
public Vertex getParentOfTask(Vertex task,String edge){
  Set<Edge> edges=inEdges(task);
  Edge taskEdge=null;
  for (  Edge e : edges) {
    if (e.getName().equals(edge)) {
      taskEdge=e;
    }
  }
  if (taskEdge != null) {
    return connectedChildTask(task,taskEdge);
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public Vertex getParentOfTask(Vertex task,String edge){
  Set<Edge> edges=inEdges(task);
  Edge taskEdge=null;
  for (  Edge e : edges) {
    if (e.getName().equals(edge)) {
      taskEdge=e;
    }
  }
  if (taskEdge != null) {
    return connectedParentTask(task,taskEdge);
  }
 else {
    return null;
  }
}
Program: 173015
Project: 173015
Buggy source:
public static List<Object> readFile(String fileName,MessageType dataType,KryoMemorySerializer deserializer){
  String outFileName=Paths.get(fileName).toString();
  FileChannel rwChannel;
  try {
    rwChannel=new RandomAccessFile(outFileName,"String_Node_Str").getChannel();
    ByteBuffer os=rwChannel.map(FileChannel.MapMode.READ_ONLY,0,rwChannel.size());
    List<Object> values=new ArrayList<>();
    int totalRead=0;
    while (totalRead < rwChannel.size()) {
      int keySize=os.getInt();
      Object value=null;
      int dataSize=os.getInt();
      value=deserialize(dataType,deserializer,os,dataSize);
      values.add(value);
    }
    rwChannel.close();
    return values;
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
public static List<Object> readFile(String fileName,MessageType dataType,KryoMemorySerializer deserializer){
  String outFileName=Paths.get(fileName).toString();
  FileChannel rwChannel;
  try {
    rwChannel=new RandomAccessFile(outFileName,"String_Node_Str").getChannel();
    ByteBuffer os=rwChannel.map(FileChannel.MapMode.READ_ONLY,0,rwChannel.size());
    List<Object> values=new ArrayList<>();
    int totalRead=0;
    while (totalRead < rwChannel.size()) {
      Object value;
      int dataSize=os.getInt();
      value=deserialize(dataType,deserializer,os,dataSize);
      values.add(value);
    }
    rwChannel.close();
    return values;
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 173016
Project: 173016
Buggy source:
public OpenFile(FileChannel rwChannel,ByteBuffer buffer){
  this.rwChannel=rwChannel;
  this.byteBuffer=buffer;
}

Fixed version (ground truth):
public OpenFile(FileChannel rwChannel,ByteBuffer byteBuffer,List<KeyValue> kValues,int total){
  this.rwChannel=rwChannel;
  this.byteBuffer=byteBuffer;
  this.keyValues=kValues;
  this.totalBytes=total;
}
Program: 173017
Project: 173017
Buggy source:
/** 
 * This method initialize the config values received from the user and set the default instance value and container maximum value.
 * @param cfg1
 */
public void initialize(Config cfg1){
  this.cfg=cfg1;
  this.instanceRAM=1024.0;
  this.instanceDisk=1000.0;
  this.instanceCPU=5.0;
  LOG.info("String_Node_Str" + "String_Node_Str" + instanceRAM + "String_Node_Str"+ "String_Node_Str"+ instanceDisk+ "String_Node_Str"+ "String_Node_Str"+ instanceCPU);
  this.defaultResourceValue=new Resource(this.instanceRAM,this.instanceDisk,this.instanceCPU);
  this.instanceRAM=this.defaultResourceValue.getRam() * DEFAULT_NUMBER_INSTANCES_PER_CONTAINER;
  this.instanceDisk=this.defaultResourceValue.getDisk() * DEFAULT_NUMBER_INSTANCES_PER_CONTAINER;
  this.instanceCPU=this.defaultResourceValue.getCpu() * DEFAULT_NUMBER_INSTANCES_PER_CONTAINER;
  this.paddingPercentage=DEFAULT_CONTAINER_PADDING_PERCENTAGE;
  this.maximumContainerResourceValue=new Resource((double)Math.round(TaskScheduleUtils.increaseBy(instanceRAM,paddingPercentage)),(double)Math.round(TaskScheduleUtils.increaseBy(instanceDisk,paddingPercentage)),(double)Math.round(TaskScheduleUtils.increaseBy(instanceCPU,paddingPercentage)));
  LOG.info("String_Node_Str" + "String_Node_Str" + this.maximumContainerResourceValue.getRam() + "String_Node_Str"+ "String_Node_Str"+ this.maximumContainerResourceValue.getDisk()+ "String_Node_Str"+ "String_Node_Str"+ this.maximumContainerResourceValue.getCpu());
}

Fixed version (ground truth):
/** 
 * This method initialize the config values received from the user and set the default instance value and container maximum value.
 * @param cfg1
 */
public void initialize(Config cfg1){
  this.cfg=cfg1;
  this.instanceRAM=1024.0;
  this.instanceDisk=1000.0;
  this.instanceCPU=5.0;
  this.defaultResourceValue=new Resource(this.instanceRAM,this.instanceDisk,this.instanceCPU);
  this.instanceRAM=this.defaultResourceValue.getRam() * DEFAULT_NUMBER_INSTANCES_PER_CONTAINER;
  this.instanceDisk=this.defaultResourceValue.getDisk() * DEFAULT_NUMBER_INSTANCES_PER_CONTAINER;
  this.instanceCPU=this.defaultResourceValue.getCpu() * DEFAULT_NUMBER_INSTANCES_PER_CONTAINER;
  this.paddingPercentage=DEFAULT_CONTAINER_PADDING_PERCENTAGE;
  this.maximumContainerResourceValue=new Resource((double)Math.round(TaskScheduleUtils.increaseBy(instanceRAM,paddingPercentage)),(double)Math.round(TaskScheduleUtils.increaseBy(instanceDisk,paddingPercentage)),(double)Math.round(TaskScheduleUtils.increaseBy(instanceCPU,paddingPercentage)));
  LOG.info("String_Node_Str" + "String_Node_Str" + instanceRAM + "String_Node_Str"+ "String_Node_Str"+ instanceDisk+ "String_Node_Str"+ "String_Node_Str"+ instanceCPU);
  LOG.info("String_Node_Str" + "String_Node_Str" + this.maximumContainerResourceValue.getRam() + "String_Node_Str"+ "String_Node_Str"+ this.maximumContainerResourceValue.getDisk()+ "String_Node_Str"+ "String_Node_Str"+ this.maximumContainerResourceValue.getCpu());
}
Program: 173018
Project: 173018
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.executor);
    this.memoryManager=new LMDBMemoryManager(dataPath);
    if (!isKeyed) {
      this.operationMemoryManager=memoryManager.addOperation(opertionID,MessageTypeUtils.toDataMessageType(type));
    }
 else {
      this.operationMemoryManager=memoryManager.addOperation(opertionID,MessageTypeUtils.toDataMessageType(type),MessageTypeUtils.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(MPIContext.networkStoragePath(config) + "String_Node_Str" + this.executor);
    this.memoryManager=new LMDBMemoryManager(dataPath);
    if (!isKeyed) {
      this.operationMemoryManager=memoryManager.addOperation(opertionID,MessageTypeUtils.toDataMessageType(type));
    }
 else {
      this.operationMemoryManager=memoryManager.addOperation(opertionID,MessageTypeUtils.toDataMessageType(type),MessageTypeUtils.toDataMessageType(keyType));
    }
  }
}
Program: 173021
Project: 173021
Buggy source:
public void init(Config cfg,DataFlowOperation op,Map<Integer,List<Integer>> expectedIds){
  for (  Map.Entry<Integer,List<Integer>> e : expectedIds.entrySet()) {
    LOG.info(String.format("String_Node_Str",id,e.getKey(),e.getValue().toString()));
  }
}

Fixed version (ground truth):
public void init(Config cfg,DataFlowOperation op,Map<Integer,List<Integer>> expectedIds){
  for (  Map.Entry<Integer,List<Integer>> e : expectedIds.entrySet()) {
    LOG.info(String.format("String_Node_Str",id,e.getKey(),e.getValue().toString()));
    receiveIds.put(e.getKey(),new ArrayList<>());
  }
}
Program: 173022
Project: 173022
Buggy source:
@Override public boolean onMessage(int source,int path,int target,int flags,Object object){
  count++;
  if (count % 1 == 0) {
    LOG.info("String_Node_Str" + source + "String_Node_Str"+ target+ "String_Node_Str"+ count);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onMessage(int source,int path,int target,int flags,Object object){
  try {
    count++;
    if (count % 1 == 0) {
      LOG.info("String_Node_Str" + source + "String_Node_Str"+ target+ "String_Node_Str"+ count);
    }
    IntData data=(IntData)object;
    int sequence=data.getId();
    List<Integer> list=receiveIds.get(target);
    list.add(sequence);
    Set<Integer> r=new HashSet<>(list);
    if (list.size() != r.size()) {
      LOG.log(Level.INFO,"String_Node_Str",new RuntimeException("String_Node_Str"));
    }
  }
 catch (  NullPointerException e) {
    LOG.log(Level.INFO,"String_Node_Str" + source + "String_Node_Str"+ target+ "String_Node_Str"+ count+ "String_Node_Str"+ receiveIds,e);
  }
  return true;
}
Program: 173023
Project: 173023
Buggy source:
@Override public void run(){
  LOG.log(Level.INFO,"String_Node_Str");
  for (int i=0; i < 1000; i++) {
    IntData data=generateData();
    while (!broadcast.send(NO_OF_TASKS,data,0)) {
      try {
        Thread.sleep(1);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
    sendCount++;
    Thread.yield();
  }
  status=Status.MAP_FINISHED;
}

Fixed version (ground truth):
@Override public void run(){
  LOG.log(Level.INFO,"String_Node_Str");
  for (int i=0; i < 1000; i++) {
    IntData data=generateData();
    data.setId(i);
    while (!broadcast.send(NO_OF_TASKS,data,0)) {
      broadcast.progress();
    }
    sendCount++;
    Thread.yield();
  }
  status=Status.MAP_FINISHED;
}
Program: 173024
Project: 173024
Buggy source:
protected void releaseTheBuffers(int id,MPIMessage message){
  if (MPIMessageDirection.IN == message.getMessageDirection()) {
    Queue<MPIBuffer> list=receiveBuffers.get(id);
    for (    MPIBuffer buffer : message.getBuffers()) {
      buffer.getByteBuffer().clear();
      if (!list.offer(buffer)) {
        throw new RuntimeException("String_Node_Str");
      }
      receiveBufferReleaseCount++;
    }
    if (completionListener != null) {
      completionListener.completed(message.getOriginatingId());
    }
  }
 else   if (MPIMessageDirection.OUT == message.getMessageDirection()) {
    Queue<MPIBuffer> queue=sendBuffers;
    for (    MPIBuffer buffer : message.getBuffers()) {
      buffer.getByteBuffer().clear();
      if (!queue.offer(buffer)) {
        throw new RuntimeException("String_Node_Str");
      }
      sendBufferReleaseCount++;
    }
  }
}

Fixed version (ground truth):
protected void releaseTheBuffers(int id,MPIMessage message){
  if (MPIMessageDirection.IN == message.getMessageDirection()) {
    Queue<MPIBuffer> list=receiveBuffers.get(id);
    for (    MPIBuffer buffer : message.getBuffers()) {
      buffer.getByteBuffer().clear();
      if (!list.offer(buffer)) {
        throw new RuntimeException(String.format("String_Node_Str",executor,message.getHeader().getDestinationIdentifier()));
      }
      receiveBufferReleaseCount++;
    }
    if (completionListener != null) {
      completionListener.completed(message.getOriginatingId());
    }
  }
 else   if (MPIMessageDirection.OUT == message.getMessageDirection()) {
    ArrayBlockingQueue<MPIBuffer> queue=(ArrayBlockingQueue<MPIBuffer>)sendBuffers;
    for (    MPIBuffer buffer : message.getBuffers()) {
      buffer.getByteBuffer().clear();
      if (!queue.offer(buffer)) {
        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);
        throw new RuntimeException(String.format("String_Node_Str",executor,message.getOriginatingId(),queue.size(),queue.remainingCapacity()));
      }
      sendBufferReleaseCount++;
    }
  }
}
Program: 173026
Project: 173026
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,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);
  }
}

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);
  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));
      countsPerTask.put(i,0);
      totalCountsPerTask.put(i,0);
    }
    LOG.fine(String.format("String_Node_Str",executor,e.getKey(),e.getValue().toString()));
    reducedValuesMap.put(e.getKey(),new ArrayBlockingQueue<>(sendPendingMax));
    messages.put(e.getKey(),messagesPerTask);
    counts.put(e.getKey(),countsPerTask);
    totalCounts.put(e.getKey(),totalCountsPerTask);
  }
}
Program: 173027
Project: 173027
Buggy source:
@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;
}

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) {
    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: 173029
Project: 173029
Buggy source:
@Override public void init(Config cfg,DataFlowOperation op,Map<Integer,List<Integer>> expectedIds){
  executor=op.getTaskPlan().getThisExecutor();
  sendPendingMax=MPIContext.sendPendingMax(cfg);
  isStoreBased=false;
  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);
    finalMessages.put(e.getKey(),new ArrayList<>());
    counts.put(e.getKey(),countsPerTask);
    batchDone.put(e.getKey(),false);
  }
  this.memoryManagers=new HashMap<>();
  this.dataFlowOperation=op;
  this.executor=dataFlowOperation.getTaskPlan().getThisExecutor();
  this.gatherBatchReceiver.init(cfg,op,expectedIds);
}

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);
  isStoreBased=false;
  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);
    finalMessages.put(e.getKey(),new ArrayList<>());
    counts.put(e.getKey(),countsPerTask);
    batchDone.put(e.getKey(),false);
  }
  this.memoryManagers=new HashMap<>();
  this.dataFlowOperation=op;
  this.executor=dataFlowOperation.getTaskPlan().getThisExecutor();
  this.gatherBatchReceiver.init(cfg,op,expectedIds);
}
Program: 173030
Project: 173030
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);
  Map<Integer,Boolean> finishedMessages=finished.get(target);
  if (m.size() > sendPendingMax) {
    canAdd=false;
  }
 else {
    if (object instanceof MPIMessage) {
      ((MPIMessage)object).incrementRefCount();
    }
 else     if (object instanceof OperationMemoryManager) {
      isStoreBased=true;
      memoryManagers.put(target,(OperationMemoryManager)object);
    }
    Integer c=counts.get(target).get(source);
    counts.get(target).put(source,c + 1);
    if (!isStoreBased) {
      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;
  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();
    }
 else     if (object instanceof OperationMemoryManager) {
      isStoreBased=true;
      memoryManagers.put(target,(OperationMemoryManager)object);
    }
    Integer c=counts.get(target).get(source);
    counts.get(target).put(source,c + 1);
    if (!isStoreBased) {
      m.add(object);
    }
    if ((flags & MessageFlags.FLAGS_LAST) == MessageFlags.FLAGS_LAST) {
      finishedMessages.put(source,true);
    }
  }
  return canAdd;
}