nus-yam/ex-repair huggingface dataset:
Program: 173102
Project: 173102
Buggy source:
/** 
 * Send messages to the particular id
 * @param id id to be used for sending messages
 * @param message the message
 * @return true if the message is accepted to be sent
 */
public boolean sendMessage(int id,MPIMessage message,MPIMessageListener callback){
  boolean offer=pendingSends.offer(new MPISendRequests(id,message.getHeader().getEdge(),message,callback));
  if (offer) {
    pendingSendCount++;
  }
  return offer;
}

Fixed version (ground truth):
/** 
 * Send messages to the particular id
 * @param id id to be used for sending messages
 * @param message the message
 * @return true if the message is accepted to be sent
 */
public boolean sendMessage(int id,MPIMessage message,MPIMessageListener callback){
  boolean offer=pendingSends.offer(new MPISendRequests(id,message.getHeader().getEdge(),message,callback));
  return offer;
}
Program: 173104
Project: 173104
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);
    finalMessages.put(e.getKey(),new ArrayList<>());
    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,List<Object>> messagesPerTask=new HashMap<>();
    Map<Integer,Boolean> finishedPerTask=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>());
      finishedPerTask.put(i,false);
      countsPerTask.put(i,0);
      totalCountsPerTask.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);
    totalCounts.put(e.getKey(),totalCountsPerTask);
  }
  this.dataFlowOperation=op;
  this.executor=dataFlowOperation.getTaskPlan().getThisExecutor();
}
Program: 173105
Project: 173105
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;
    LOG.info(String.format("String_Node_Str",executor,target,source,counts.get(target),finalMessages.size()));
  }
 else {
    LOG.info(String.format("String_Node_Str",executor,target,source,finishedMessages.size()));
    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) {
      LOG.info(String.format("String_Node_Str",executor,target,source));
      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;
  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);
    Integer tc=totalCounts.get(target).get(source);
    totalCounts.get(target).put(source,tc + 1);
    m.add(object);
    if ((flags & MessageFlags.FLAGS_LAST) == MessageFlags.FLAGS_LAST) {
      LOG.info(String.format("String_Node_Str",executor,target,source));
      finishedMessages.put(source,true);
    }
  }
  return canAdd;
}
Program: 173107
Project: 173107
Buggy source:
@Override public void init(Config cfg,DataFlowOperation op,Map<Integer,List<Integer>> expectedIds){
  executor=op.getTaskPlan().getThisExecutor();
  sendPendingMax=MPIContext.sendPendingMax(cfg);
  this.dataFlowOperation=op;
  this.executor=dataFlowOperation.getTaskPlan().getThisExecutor();
  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 task : e.getValue()) {
      messagesPerTask.put(task,new ArrayList<Object>());
      finishedPerTask.put(task,false);
      countsPerTask.put(task,0);
    }
    messages.put(e.getKey(),messagesPerTask);
    finished.put(e.getKey(),finishedPerTask);
    counts.put(e.getKey(),countsPerTask);
    batchDone.put(e.getKey(),false);
  }
}

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);
  this.dataFlowOperation=op;
  this.executor=dataFlowOperation.getTaskPlan().getThisExecutor();
  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<>();
    Map<Integer,Integer> totalCountsPerTask=new HashMap<>();
    for (    int task : e.getValue()) {
      messagesPerTask.put(task,new ArrayList<Object>());
      finishedPerTask.put(task,false);
      countsPerTask.put(task,0);
      totalCountsPerTask.put(task,0);
    }
    messages.put(e.getKey(),messagesPerTask);
    finished.put(e.getKey(),finishedPerTask);
    counts.put(e.getKey(),countsPerTask);
    batchDone.put(e.getKey(),false);
    totalCounts.put(e.getKey(),totalCountsPerTask);
  }
}
Program: 173108
Project: 173108
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));
  }
  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);
    Integer tc=totalCounts.get(target).get(source);
    totalCounts.get(target).put(source,tc + 1);
    m.add(object);
    if ((flags & MessageFlags.FLAGS_LAST) == MessageFlags.FLAGS_LAST) {
      finishedMessages.put(source,true);
    }
  }
  return canAdd;
}
Program: 173110
Project: 173110
Buggy source:
public void progress(){
  for (  int t : messages.keySet()) {
    boolean canProgress=true;
    while (canProgress) {
      Map<Integer,List<Object>> map=messages.get(t);
      boolean found=true;
      Object o=null;
      for (      Map.Entry<Integer,List<Object>> e : map.entrySet()) {
        if (e.getValue().size() == 0) {
          found=false;
          canProgress=false;
        }
 else {
          o=e.getValue().get(0);
        }
      }
      if (found) {
        for (        Map.Entry<Integer,List<Object>> e : map.entrySet()) {
          o=e.getValue().remove(0);
        }
        if (o != null) {
          count++;
          if (count % 1000 == 0) {
            LOG.info(String.format("String_Node_Str",id,t,count,counts));
          }
          if (count >= 11000) {
            LOG.info("String_Node_Str" + (System.nanoTime() - start) / 1000000 + "String_Node_Str" + count);
          }
        }
 else {
          LOG.severe("String_Node_Str");
        }
      }
    }
  }
}

Fixed version (ground truth):
public void progress(){
  for (  int t : messages.keySet()) {
    boolean canProgress=true;
    while (canProgress) {
      Map<Integer,List<Object>> map=messages.get(t);
      boolean found=true;
      Object o=null;
      for (      Map.Entry<Integer,List<Object>> e : map.entrySet()) {
        if (e.getValue().size() == 0) {
          found=false;
          canProgress=false;
        }
 else {
          o=e.getValue().get(0);
        }
      }
      if (found) {
        for (        Map.Entry<Integer,List<Object>> e : map.entrySet()) {
          o=e.getValue().remove(0);
        }
        if (o != null) {
          count++;
          if (count % 10 == 0) {
            LOG.info(String.format("String_Node_Str",id,t,count,counts));
          }
          if (count >= 11000) {
            LOG.info("String_Node_Str" + (System.nanoTime() - start) / 1000000 + "String_Node_Str" + count);
          }
        }
 else {
          LOG.severe("String_Node_Str");
        }
      }
    }
  }
}
Program: 173111
Project: 173111
Buggy source:
public MPIDirectDataFlowCommunication(TWSMPIChannel channel,Set<Integer> srcs,int dest,MessageReceiver finalRcvr){
  this.sources=srcs;
  this.destination=dest;
  this.finalReceiver=finalRcvr;
}

Fixed version (ground truth):
public MPIDirectDataFlowCommunication(TWSMPIChannel channel,Set<Integer> srcs,int dest,MessageReceiver finalRcvr){
  this.sources=srcs;
  this.destination=dest;
  this.finalReceiver=finalRcvr;
  this.delegete=new MPIDataFlowOperation(channel);
}
Program: 173112
Project: 173112
Buggy source:
public MPIDataFlowAllGather(TWSMPIChannel chnl,Set<Integer> sources,Set<Integer> destination,int middleTask,MessageReceiver finalRecv,MessageReceiver partialRecv,int redEdge,int broadEdge){
  this.channel=chnl;
  this.sources=sources;
  this.destinations=destination;
  this.partialReceiver=partialRecv;
  this.finalReceiver=finalRecv;
  this.reduceEdge=redEdge;
  this.broadCastEdge=broadEdge;
  this.middleTask=middleTask;
}

Fixed version (ground truth):
public MPIDataFlowAllGather(TWSChannel chnl,Set<Integer> sources,Set<Integer> destination,int middleTask,MessageReceiver finalRecv,MessageReceiver partialRecv,int redEdge,int broadEdge){
  this.channel=chnl;
  this.sources=sources;
  this.destinations=destination;
  this.partialReceiver=partialRecv;
  this.finalReceiver=finalRecv;
  this.reduceEdge=redEdge;
  this.broadCastEdge=broadEdge;
  this.middleTask=middleTask;
}
Program: 173113
Project: 173113
Buggy source:
public MPIDataFlowAllReduce(TWSMPIChannel chnl,Set<Integer> sources,Set<Integer> destination,int middleTask,MessageReceiver finalRecv,MessageReceiver partialRecv,int redEdge,int broadEdge){
  this.channel=chnl;
  this.sources=sources;
  this.destinations=destination;
  this.partialReceiver=partialRecv;
  this.finalReceiver=finalRecv;
  this.reduceEdge=redEdge;
  this.broadCastEdge=broadEdge;
  this.middleTask=middleTask;
}

Fixed version (ground truth):
public MPIDataFlowAllReduce(TWSChannel chnl,Set<Integer> sources,Set<Integer> destination,int middleTask,MessageReceiver finalRecv,MessageReceiver partialRecv,int redEdge,int broadEdge){
  this.channel=chnl;
  this.sources=sources;
  this.destinations=destination;
  this.partialReceiver=partialRecv;
  this.finalReceiver=finalRecv;
  this.reduceEdge=redEdge;
  this.broadCastEdge=broadEdge;
  this.middleTask=middleTask;
}
Program: 173114
Project: 173114
Buggy source:
public MPIDataFlowBroadcast(TWSMPIChannel channel,int src,Set<Integer> dests,MessageReceiver finalRcvr){
  this.source=src;
  this.destinations=dests;
  this.finalReceiver=finalRcvr;
  this.delegete=new MPIDataFlowOperation(channel);
}

Fixed version (ground truth):
public MPIDataFlowBroadcast(TWSChannel channel,int src,Set<Integer> dests,MessageReceiver finalRcvr){
  this.source=src;
  this.destinations=dests;
  this.finalReceiver=finalRcvr;
  this.delegete=new MPIDataFlowOperation(channel);
}
Program: 173115
Project: 173115
Buggy source:
public MPIDataFlowGather(TWSMPIChannel channel,Set<Integer> sources,int destination,MessageReceiver finalRcvr,MessageReceiver partialRcvr,int indx,int p,Config cfg,MessageType t,MessageType kt,TaskPlan taskPlan,int edge){
  this.index=indx;
  this.sources=sources;
  this.destination=destination;
  this.finalReceiver=finalRcvr;
  this.partialReceiver=partialRcvr;
  this.pathToUse=p;
  this.keyType=kt;
  this.instancePlan=taskPlan;
  this.isKeyed=true;
  this.delegete=new MPIDataFlowOperation(channel);
}

Fixed version (ground truth):
public MPIDataFlowGather(TWSChannel channel,Set<Integer> sources,int destination,MessageReceiver finalRcvr,MessageReceiver partialRcvr,int indx,int p,Config cfg,MessageType t,MessageType kt,TaskPlan taskPlan,int edge){
  this.index=indx;
  this.sources=sources;
  this.destination=destination;
  this.finalReceiver=finalRcvr;
  this.partialReceiver=partialRcvr;
  this.pathToUse=p;
  this.keyType=kt;
  this.instancePlan=taskPlan;
  this.isKeyed=true;
  this.delegete=new MPIDataFlowOperation(channel);
}
Program: 173116
Project: 173116
Buggy source:
public MPIDataFlowLoadBalance(TWSMPIChannel channel,Set<Integer> srcs,Set<Integer> dests,MessageReceiver finalRcvr){
  this.sources=srcs;
  this.destinations=dests;
  this.destinationIndex=new HashMap<>();
  this.destinationsList=new ArrayList<>(destinations);
  this.delegete=new MPIDataFlowOperation(channel);
  for (  int s : sources) {
    destinationIndex.put(s,0);
  }
  this.finalReceiver=finalRcvr;
}

Fixed version (ground truth):
public MPIDataFlowLoadBalance(TWSChannel channel,Set<Integer> srcs,Set<Integer> dests,MessageReceiver finalRcvr){
  this.sources=srcs;
  this.destinations=dests;
  this.destinationIndex=new HashMap<>();
  this.destinationsList=new ArrayList<>(destinations);
  this.delegete=new MPIDataFlowOperation(channel);
  for (  int s : sources) {
    destinationIndex.put(s,0);
  }
  this.finalReceiver=finalRcvr;
}
Program: 173117
Project: 173117
Buggy source:
public MPIDataFlowMultiGather(TWSMPIChannel chnl,Set<Integer> sources,Set<Integer> destination,MultiMessageReceiver finalRecv,MultiMessageReceiver partialRecv,Set<Integer> es){
  this.channel=chnl;
  this.sources=sources;
  this.destinations=destination;
  this.finalReceiver=finalRecv;
  this.edges=es;
  this.gatherMap=new HashMap<>();
  this.partialReceiver=partialRecv;
}

Fixed version (ground truth):
public MPIDataFlowMultiGather(TWSChannel chnl,Set<Integer> sources,Set<Integer> destination,MultiMessageReceiver finalRecv,MultiMessageReceiver partialRecv,Set<Integer> es){
  this.channel=chnl;
  this.sources=sources;
  this.destinations=destination;
  this.finalReceiver=finalRecv;
  this.edges=es;
  this.gatherMap=new HashMap<>();
  this.partialReceiver=partialRecv;
}
Program: 173118
Project: 173118
Buggy source:
public MPIDataFlowMultiReduce(TWSMPIChannel chnl,Set<Integer> sources,Set<Integer> destination,MultiMessageReceiver finalRecv,MultiMessageReceiver partialRecv,Set<Integer> es){
  this.channel=chnl;
  this.sources=sources;
  this.destinations=destination;
  this.partialReceiver=partialRecv;
  this.finalReceiver=finalRecv;
  this.edges=es;
  this.reduceMap=new HashMap<>();
}

Fixed version (ground truth):
public MPIDataFlowMultiReduce(TWSChannel chnl,Set<Integer> sources,Set<Integer> destination,MultiMessageReceiver finalRecv,MultiMessageReceiver partialRecv,Set<Integer> es){
  this.channel=chnl;
  this.sources=sources;
  this.destinations=destination;
  this.partialReceiver=partialRecv;
  this.finalReceiver=finalRecv;
  this.edges=es;
  this.reduceMap=new HashMap<>();
}
Program: 173119
Project: 173119
Buggy source:
public MPIDataFlowOperation(TWSMPIChannel channel){
  this.channel=channel;
}

Fixed version (ground truth):
public MPIDataFlowOperation(TWSChannel channel){
  this.channel=channel;
}
Program: 173120
Project: 173120
Buggy source:
public MPIDataFlowPartition(TWSMPIChannel channel,Set<Integer> srcs,Set<Integer> dests,MessageReceiver finalRcvr,PartitionStratergy stratergy){
  this.sources=srcs;
  this.destinations=dests;
  this.destinationIndex=new HashMap<>();
  this.destinationsList=new ArrayList<>(destinations);
  this.delegete=new MPIDataFlowOperation(channel);
  this.partitionStratergy=stratergy;
  for (  int s : sources) {
    destinationIndex.put(s,0);
  }
  this.finalReceiver=finalRcvr;
}

Fixed version (ground truth):
public MPIDataFlowPartition(TWSChannel channel,Set<Integer> srcs,Set<Integer> dests,MessageReceiver finalRcvr,PartitionStratergy stratergy){
  this.sources=srcs;
  this.destinations=dests;
  this.destinationIndex=new HashMap<>();
  this.destinationsList=new ArrayList<>(destinations);
  this.delegete=new MPIDataFlowOperation(channel);
  this.partitionStratergy=stratergy;
  for (  int s : sources) {
    destinationIndex.put(s,0);
  }
  this.finalReceiver=finalRcvr;
}
Program: 173121
Project: 173121
Buggy source:
public MPIDataFlowReduce(TWSMPIChannel channel,Set<Integer> sources,int destination,MessageReceiver finalRcvr,MessageReceiver partialRcvr){
  this(channel,sources,destination,finalRcvr,partialRcvr,0,0);
}

Fixed version (ground truth):
public MPIDataFlowReduce(TWSChannel channel,Set<Integer> sources,int destination,MessageReceiver finalRcvr,MessageReceiver partialRcvr){
  this(channel,sources,destination,finalRcvr,partialRcvr,0,0);
}
Program: 173122
Project: 173122
Buggy source:
public MPIDirectDataFlowCommunication(TWSMPIChannel 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);
}
Program: 173123
Project: 173123
Buggy source:
public void clear(){
}

Fixed version (ground truth):
public void clear(){
  pendingReceives.clear();
  pendingSends.clear();
}
Program: 173124
Project: 173124
Buggy source:
public void disconnect(){
  if (!isConnected) {
    return;
  }
  try {
    socketChannel.close();
  }
 catch (  IOException e) {
    LOG.log(Level.SEVERE,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void disconnect(){
  if (!isConnected) {
    return;
  }
  channel.forceFlush();
  try {
    socketChannel.close();
  }
 catch (  IOException e) {
    LOG.log(Level.SEVERE,"String_Node_Str",e);
  }
}
Program: 173125
Project: 173125
Buggy source:
public void stop(){
  if (serverSocketChannel == null || !serverSocketChannel.isOpen()) {
    LOG.info("String_Node_Str");
    return;
  }
  for (  Map.Entry<SocketChannel,Channel> connections : connectedChannels.entrySet()) {
    SocketChannel channel=connections.getKey();
    connections.getValue().clear();
  }
  try {
    serverSocketChannel.close();
  }
 catch (  IOException e) {
    LOG.log(Level.SEVERE,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void stop(){
  if (serverSocketChannel == null || !serverSocketChannel.isOpen()) {
    LOG.info("String_Node_Str");
    return;
  }
  for (  Map.Entry<SocketChannel,Channel> connections : connectedChannels.entrySet()) {
    SocketChannel channel=connections.getKey();
    progress.removeAllInterest(channel);
    connections.getValue().clear();
  }
  try {
    serverSocketChannel.close();
  }
 catch (  IOException e) {
    LOG.log(Level.SEVERE,"String_Node_Str",e);
  }
}
Program: 173127
Project: 173127
Buggy source:
@Override public void onSendComplete(SocketChannel channel,TCPWriteRequest writeRequest){
  LOG.log(Level.INFO,"String_Node_Str");
  writeRequest.setComplete(true);
  if (writeRequest.getEdge() == -1) {
    ByteBuffer buffer=writeRequest.getByteBuffer();
    buffer.clear();
    helloSendByteBuffers.add(buffer);
    clientsConnected++;
  }
}

Fixed version (ground truth):
@Override public void onSendComplete(SocketChannel channel,TCPWriteRequest writeRequest){
  LOG.log(Level.INFO,"String_Node_Str");
  writeRequest.setComplete(true);
  if (writeRequest.getEdge() == -1) {
    ByteBuffer buffer=writeRequest.getByteBuffer();
    buffer.clear();
    helloSendByteBuffers.add(buffer);
    clientsCompleted++;
  }
}
Program: 173128
Project: 173128
Buggy source:
public void setKeyType(MessageType keyType){
  this.keyType=keyType;
  operationMemoryManager.setKeyType(MessageTypeConverter.toDataMessageType(keyType));
}

Fixed version (ground truth):
public void setKeyType(MessageType keyType){
  this.keyType=keyType;
  if (isStoreBased) {
    operationMemoryManager.setKeyType(MessageTypeConverter.toDataMessageType(keyType));
  }
}
Program: 173129
Project: 173129
Buggy source:
@Override public void onSendComplete(SocketChannel channel,TCPWriteRequest writeRequest){
}

Fixed version (ground truth):
@Override public void onSendComplete(SocketChannel channel,TCPRequest writeRequest){
}
Program: 173130
Project: 173130
Buggy source:
@Override public void onReceiveComplete(SocketChannel channel,TCPReadRequest readRequest){
  ByteBuffer buffer=readRequest.getByteBuffer();
  int processNo=buffer.getInt();
  LOG.log(Level.INFO,"String_Node_Str" + processNo);
  if (channelIntegerMap.containsKey(processNo)) {
    LOG.log(Level.WARNING,String.format("String_Node_Str",processNo));
  }
  channelIntegerMap.put(processNo,channel);
  if (channelIntegerMap.keySet().size() == workerInfoList.size()) {
    LOG.log(Level.INFO,"String_Node_Str");
    sendHelloResponse();
  }
}

Fixed version (ground truth):
@Override public void onReceiveComplete(SocketChannel channel,TCPRequest readRequest){
  ByteBuffer buffer=readRequest.getByteBuffer();
  int processNo=buffer.getInt();
  LOG.log(Level.INFO,"String_Node_Str" + processNo);
  if (channelIntegerMap.containsKey(processNo)) {
    LOG.log(Level.WARNING,String.format("String_Node_Str",processNo));
  }
  channelIntegerMap.put(processNo,channel);
  if (channelIntegerMap.keySet().size() == workerInfoList.size()) {
    LOG.log(Level.INFO,"String_Node_Str");
    sendHelloResponse();
  }
}
Program: 173131
Project: 173131
Buggy source:
public TCPRequest iRecv(ByteBuffer buffer,int size,int procId,int edge){
  SocketChannel ch=serverChannel.get(procId);
  if (ch == null) {
    LOG.log(Level.INFO,"String_Node_Str");
    return null;
  }
  return server.receive(ch,buffer,size,edge);
}

Fixed version (ground truth):
public TCPRequest iRecv(ByteBuffer buffer,int size,int procId,int edge){
  SocketChannel ch=serverChannel.get(procId);
  if (ch == null) {
    LOG.log(Level.INFO,"String_Node_Str" + procId);
    return null;
  }
  return server.receive(ch,buffer,size,edge);
}
Program: 173132
Project: 173132
Buggy source:
public void start(){
  String hostName=TCPContext.getHostName(thisInfo);
  int port=TCPContext.getPort(thisInfo);
  looper=new Progress();
  server=new Server(config,hostName,port,looper,new ChannelServerMessageHandler());
  server.start();
  worker=new TCPWorker(config,masterInfo);
  worker.start();
  worker.waitForSync();
  LOG.log(Level.INFO,"String_Node_Str");
  for (  NetworkInfo info : networkInfos) {
    if (info.getProcId() == thisInfo.getProcId()) {
      continue;
    }
    String remoteHost=TCPContext.getHostName(info);
    int remotePort=TCPContext.getPort(info);
    Client client=new Client(remoteHost,remotePort,config,looper,new ClientChannelMessageHandler());
    client.connect();
    clients.put(info.getProcId(),client);
    invertedClientChannels.put(client.getSocketChannel(),info.getProcId());
  }
  while (clientsConnected != (networkInfos.size() - 1) && (clientsCompleted != networkInfos.size() - 1)) {
    looper.loop();
  }
  LOG.log(Level.INFO,"String_Node_Str" + clientsConnected + "String_Node_Str"+ clientsCompleted);
}

Fixed version (ground truth):
public void start(){
  String hostName=TCPContext.getHostName(thisInfo);
  int port=TCPContext.getPort(thisInfo);
  looper=new Progress();
  server=new Server(config,hostName,port,looper,new ChannelServerMessageHandler());
  server.start();
  worker=new TCPWorker(config,masterInfo);
  worker.start();
  worker.waitForSync();
  LOG.log(Level.INFO,"String_Node_Str");
  for (  NetworkInfo info : networkInfos) {
    if (info.getProcId() == thisInfo.getProcId()) {
      continue;
    }
    String remoteHost=TCPContext.getHostName(info);
    int remotePort=TCPContext.getPort(info);
    Client client=new Client(remoteHost,remotePort,config,looper,new ClientChannelMessageHandler());
    client.connect();
    clients.put(info.getProcId(),client);
    invertedClientChannels.put(client.getSocketChannel(),info.getProcId());
  }
  while (clientsConnected != (networkInfos.size() - 1) || (clientsCompleted != networkInfos.size() - 1)) {
    looper.loop();
  }
  LOG.log(Level.INFO,"String_Node_Str" + clientsConnected + "String_Node_Str"+ clientsCompleted);
}
Program: 173133
Project: 173133
Buggy source:
public TCPRequest iSend(ByteBuffer buffer,int size,int procId,int edge){
  SocketChannel ch=clientChannel.get(procId);
  if (ch == null) {
    LOG.log(Level.INFO,"String_Node_Str");
    return null;
  }
  Client client=clients.get(procId);
  return client.send(ch,buffer,size,edge);
}

Fixed version (ground truth):
public TCPRequest iSend(ByteBuffer buffer,int size,int procId,int edge){
  SocketChannel ch=clientChannel.get(procId);
  if (ch == null) {
    LOG.log(Level.INFO,"String_Node_Str" + procId);
    return null;
  }
  Client client=clients.get(procId);
  return client.send(ch,buffer,size,edge);
}
Program: 173134
Project: 173134
Buggy source:
@Override public void onConnect(SocketChannel channel,StatusCode status){
  LOG.log(Level.INFO,"String_Node_Str" + channel);
}

Fixed version (ground truth):
@Override public void onConnect(SocketChannel channel,StatusCode status){
  LOG.log(Level.INFO,"String_Node_Str" + channel);
  connectedChannels.add(channel);
  if (connectedChannels.size() == workerInfoList.size()) {
    postReceives();
  }
}
Program: 173135
Project: 173135
Buggy source:
public void start(){
  String hostName=TCPContext.getHostName(thisNetworkInfo);
  int port=TCPContext.getPort(thisNetworkInfo);
  progress=new Progress();
  server=new Server(config,hostName,port,progress,new ServerEventHandler());
  server.start();
  postReceives();
  while (true) {
    progress.loop();
  }
}

Fixed version (ground truth):
public void start(){
  String hostName=TCPContext.getHostName(thisNetworkInfo);
  int port=TCPContext.getPort(thisNetworkInfo);
  progress=new Progress();
  server=new Server(config,hostName,port,progress,new ServerEventHandler());
  server.start();
  while (true) {
    progress.loop();
  }
}
Program: 173136
Project: 173136
Buggy source:
public void postReceives(){
  for (  NetworkInfo info : workerInfoList) {
    SocketChannel channel=channelIntegerMap.get(info.getProcId());
    ByteBuffer receiveBuffer=ByteBuffer.allocate(4);
    server.send(channel,receiveBuffer,4,0);
  }
}

Fixed version (ground truth):
public void postReceives(){
  for (  SocketChannel ch : connectedChannels) {
    ByteBuffer receiveBuffer=ByteBuffer.allocate(4);
    server.receive(ch,receiveBuffer,4,0);
  }
}
Program: 173137
Project: 173137
Buggy source:
@Override public void onReceiveComplete(SocketChannel channel,TCPReadRequest readRequest){
  ByteBuffer buffer=readRequest.getByteBuffer();
  int processNo=buffer.getInt();
  if (channelIntegerMap.containsKey(processNo)) {
    LOG.log(Level.WARNING,String.format("String_Node_Str",processNo));
  }
  channelIntegerMap.put(processNo,channel);
  if (channelIntegerMap.keySet().size() == workerInfoList.size()) {
    sendHelloResponse();
  }
}

Fixed version (ground truth):
@Override public void onReceiveComplete(SocketChannel channel,TCPReadRequest readRequest){
  ByteBuffer buffer=readRequest.getByteBuffer();
  int processNo=buffer.getInt();
  LOG.log(Level.INFO,"String_Node_Str" + processNo);
  if (channelIntegerMap.containsKey(processNo)) {
    LOG.log(Level.WARNING,String.format("String_Node_Str",processNo));
  }
  channelIntegerMap.put(processNo,channel);
  if (channelIntegerMap.keySet().size() == workerInfoList.size()) {
    sendHelloResponse();
  }
}
Program: 173138
Project: 173138
Buggy source:
public void read(){
  while (pendingReceives.size() > 0) {
    TCPReadRequest readRequest=readRequest(socketChannel);
    if (readRequest != null) {
      readRequest.setComplete(true);
      messageHandler.onReceiveComplete(socketChannel,readRequest);
    }
 else {
      break;
    }
  }
}

Fixed version (ground truth):
public void read(){
  LOG.info("String_Node_Str" + socketChannel);
  while (pendingReceives.size() > 0) {
    TCPReadRequest readRequest=readRequest(socketChannel);
    if (readRequest != null) {
      readRequest.setComplete(true);
      messageHandler.onReceiveComplete(socketChannel,readRequest);
    }
 else {
      break;
    }
  }
}
Program: 173139
Project: 173139
Buggy source:
private TCPReadRequest readRequest(SocketChannel channel){
  if (readStatus == DataStatus.INIT) {
    readHeader.clear();
    readStatus=DataStatus.HEADER;
  }
  if (readStatus == DataStatus.HEADER) {
    int retval=readFromChannel(channel,readHeader);
    if (retval != 0) {
      return null;
    }
    readHeader.flip();
    readSize=readHeader.getInt();
    readEdge=readHeader.getInt();
    readStatus=DataStatus.BODY;
  }
  if (readStatus == DataStatus.BODY) {
    ByteBuffer buffer;
    if (readingRequest == null) {
      Queue<TCPReadRequest> readRequests=getReadRequest(readEdge);
      if (readRequests.size() == 0) {
        return null;
      }
      readingRequest=readRequests.poll();
      buffer=readingRequest.getByteBuffer();
      buffer.clear();
      buffer.limit(readSize);
    }
 else {
      buffer=readingRequest.getByteBuffer();
    }
    int retVal=readFromChannel(channel,buffer);
    if (retVal < 0) {
      readSize=0;
      readEdge=0;
      TCPReadRequest ret=readingRequest;
      readingRequest=null;
      writeStatus=DataStatus.INIT;
      return null;
    }
 else     if (retVal == 0) {
      readSize=0;
      readEdge=0;
      TCPReadRequest ret=readingRequest;
      readingRequest=null;
      writeStatus=DataStatus.INIT;
      return ret;
    }
 else {
      return null;
    }
  }
  return null;
}

Fixed version (ground truth):
private TCPReadRequest readRequest(SocketChannel channel){
  LOG.log(Level.INFO,"String_Node_Str");
  if (readStatus == DataStatus.INIT) {
    readHeader.clear();
    readStatus=DataStatus.HEADER;
  }
  if (readStatus == DataStatus.HEADER) {
    int retval=readFromChannel(channel,readHeader);
    if (retval != 0) {
      return null;
    }
    readHeader.flip();
    readSize=readHeader.getInt();
    readEdge=readHeader.getInt();
    readStatus=DataStatus.BODY;
  }
  if (readStatus == DataStatus.BODY) {
    ByteBuffer buffer;
    if (readingRequest == null) {
      Queue<TCPReadRequest> readRequests=getReadRequest(readEdge);
      if (readRequests.size() == 0) {
        return null;
      }
      readingRequest=readRequests.poll();
      buffer=readingRequest.getByteBuffer();
      buffer.clear();
      buffer.limit(readSize);
    }
 else {
      buffer=readingRequest.getByteBuffer();
    }
    int retVal=readFromChannel(channel,buffer);
    if (retVal < 0) {
      readSize=0;
      readEdge=0;
      TCPReadRequest ret=readingRequest;
      readingRequest=null;
      writeStatus=DataStatus.INIT;
      return null;
    }
 else     if (retVal == 0) {
      readSize=0;
      readEdge=0;
      buffer.flip();
      TCPReadRequest ret=readingRequest;
      readingRequest=null;
      writeStatus=DataStatus.INIT;
      return ret;
    }
 else {
      return null;
    }
  }
  return null;
}
Program: 173140
Project: 173140
Buggy source:
private int writeRequest(SocketChannel channel,TCPWriteRequest request){
  ByteBuffer buffer=request.getByteBuffer();
  int written=0;
  if (writeStatus == DataStatus.INIT) {
    buffer.flip();
    writeHeader.clear();
    writeStatus=DataStatus.HEADER;
    writeHeader.putInt(request.getLength());
    writeHeader.putInt(request.getEdge());
  }
  if (writeStatus == DataStatus.HEADER) {
    written=writeToChannel(channel,writeHeader);
    if (written < 0) {
      return written;
    }
 else     if (written == 0) {
      writeStatus=DataStatus.BODY;
    }
  }
  if (writeStatus == DataStatus.BODY) {
    written=writeToChannel(channel,request.getByteBuffer());
    if (written < 0) {
      return written;
    }
 else     if (written == 0) {
      writeStatus=DataStatus.INIT;
      return written;
    }
  }
  return written;
}

Fixed version (ground truth):
private int writeRequest(SocketChannel channel,TCPWriteRequest request){
  ByteBuffer buffer=request.getByteBuffer();
  int written=0;
  if (writeStatus == DataStatus.INIT) {
    writeHeader.clear();
    writeStatus=DataStatus.HEADER;
    writeHeader.putInt(request.getLength());
    writeHeader.putInt(request.getEdge());
    writeHeader.flip();
  }
  if (writeStatus == DataStatus.HEADER) {
    written=writeToChannel(channel,writeHeader);
    if (written < 0) {
      return written;
    }
 else     if (written == 0) {
      writeStatus=DataStatus.BODY;
    }
  }
  if (writeStatus == DataStatus.BODY) {
    buffer.flip();
    written=writeToChannel(channel,buffer);
    if (written < 0) {
      return written;
    }
 else     if (written == 0) {
      writeStatus=DataStatus.INIT;
      return written;
    }
  }
  return written;
}
Program: 173141
Project: 173141
Buggy source:
public void write(){
  while (pendingSends.size() > 0) {
    TCPWriteRequest writeRequest=pendingSends.peek();
    if (writeRequest == null) {
      break;
    }
    int writeState=writeRequest(socketChannel,writeRequest);
    if (writeState > 0) {
      break;
    }
 else     if (writeState < 0) {
      LOG.severe("String_Node_Str");
      selectHandler.handleError(socketChannel);
      return;
    }
 else {
      pendingSends.poll();
      writeRequest.setComplete(true);
      messageHandler.onSendComplete(socketChannel,writeRequest);
    }
  }
  if (pendingSends.size() == 0) {
    disableWriting();
  }
}

Fixed version (ground truth):
public void write(){
  while (pendingSends.size() > 0) {
    TCPWriteRequest writeRequest=pendingSends.peek();
    if (writeRequest == null) {
      break;
    }
    int writeState=writeRequest(socketChannel,writeRequest);
    if (writeState > 0) {
      break;
    }
 else     if (writeState < 0) {
      LOG.severe("String_Node_Str");
      selectHandler.handleError(socketChannel);
      return;
    }
 else {
      LOG.log(Level.INFO,"String_Node_Str");
      pendingSends.poll();
      writeRequest.setComplete(true);
      messageHandler.onSendComplete(socketChannel,writeRequest);
    }
  }
}
Program: 173142
Project: 173142
Buggy source:
@Override public void handleConnect(SelectableChannel selectableChannel){
  try {
    if (socketChannel.finishConnect()) {
      progress.unregisterConnect(selectableChannel);
    }
  }
 catch (  IOException e) {
    LOG.log(Level.SEVERE,"String_Node_Str" + address,e);
    messageHandler.onConnect(socketChannel,StatusCode.ERROR_CONN);
    return;
  }
  channel=new Channel(config,progress,this,socketChannel,messageHandler);
  isConnected=true;
  messageHandler.onConnect(socketChannel,StatusCode.SUCCESS);
}

Fixed version (ground truth):
@Override public void handleConnect(SelectableChannel selectableChannel){
  try {
    if (socketChannel.finishConnect()) {
      progress.unregisterConnect(selectableChannel);
    }
  }
 catch (  IOException e) {
    LOG.log(Level.SEVERE,"String_Node_Str" + address,e);
    messageHandler.onConnect(socketChannel,StatusCode.ERROR_CONN);
    return;
  }
  channel=new Channel(config,progress,this,socketChannel,messageHandler);
  channel.enableReading();
  channel.enableWriting();
  isConnected=true;
  messageHandler.onConnect(socketChannel,StatusCode.SUCCESS);
}
Program: 173143
Project: 173143
Buggy source:
@Override public void handleAccept(SelectableChannel ch){
  try {
    SocketChannel socketChannel=serverSocketChannel.accept();
    if (socketChannel != null) {
      socketChannel.configureBlocking(false);
      socketChannel.socket().setSendBufferSize(TCPContext.getSocketSendBufferSize(config,1024));
      socketChannel.socket().setReceiveBufferSize(TCPContext.getSocketReceivedBufferSize(config,1024));
      socketChannel.socket().setTcpNoDelay(true);
      Channel channel=new Channel(config,progress,this,socketChannel,messageHandler);
      connectedChannels.put(socketChannel,channel);
    }
  }
 catch (  IOException e) {
    LOG.log(Level.SEVERE,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
@Override public void handleAccept(SelectableChannel ch){
  try {
    SocketChannel socketChannel=serverSocketChannel.accept();
    if (socketChannel != null) {
      socketChannel.configureBlocking(false);
      socketChannel.socket().setSendBufferSize(TCPContext.getSocketSendBufferSize(config,1024));
      socketChannel.socket().setReceiveBufferSize(TCPContext.getSocketReceivedBufferSize(config,1024));
      socketChannel.socket().setTcpNoDelay(true);
      Channel channel=new Channel(config,progress,this,socketChannel,messageHandler);
      channel.enableReading();
      channel.enableWriting();
      connectedChannels.put(socketChannel,channel);
      messageHandler.onConnect(socketChannel,StatusCode.SUCCESS);
    }
  }
 catch (  IOException e) {
    LOG.log(Level.SEVERE,"String_Node_Str",e);
  }
}
Program: 173144
Project: 173144
Buggy source:
@Override public void onConnect(SocketChannel channel,StatusCode status){
  LOG.log(Level.INFO,"String_Node_Str" + channel);
  clientSocketChannel=channel;
  send();
}

Fixed version (ground truth):
@Override public void onConnect(SocketChannel channel,StatusCode status){
  LOG.log(Level.INFO,"String_Node_Str" + channel);
  clientSocketChannel=channel;
  sendAndPost();
}
Program: 173145
Project: 173145
Buggy source:
@Override public Iterator<Object> getIterator(int opID,DataMessageType valueType,KryoMemorySerializer deSerializer){
  return memoryManager.getIterator(opID,valueType,deSerializer);
}

Fixed version (ground truth):
@Override public Iterator<Object> getIterator(int opID,DataMessageType valueType,KryoMemorySerializer deSerializer){
  flushAll(opID);
  return memoryManager.getIterator(opID,valueType,deSerializer);
}
Program: 173147
Project: 173147
Buggy source:
public static double[] deserializeDouble(List<MPIBuffer> buffers,int byteLength){
  int noOfDoubles=byteLength / 8;
  double[] returnDoubles=new double[noOfDoubles];
  int bufferIndex=0;
  for (int i=0; i < noOfDoubles; i++) {
    ByteBuffer byteBuffer=buffers.get(bufferIndex).getByteBuffer();
    int remaining=byteBuffer.remaining();
    if (remaining > 8) {
      returnDoubles[i]=byteBuffer.getDouble();
    }
 else {
      bufferIndex=getReadBuffer(buffers,8,bufferIndex);
      if (bufferIndex < 0) {
        throw new RuntimeException("String_Node_Str");
      }
    }
  }
  return returnDoubles;
}

Fixed version (ground truth):
public static double[] deserializeDouble(List<MPIBuffer> buffers,int byteLength){
  int noOfDoubles=byteLength / 8;
  double[] returnDoubles=new double[noOfDoubles];
  int bufferIndex=0;
  for (int i=0; i < noOfDoubles; i++) {
    ByteBuffer byteBuffer=buffers.get(bufferIndex).getByteBuffer();
    int remaining=byteBuffer.remaining();
    if (remaining >= 8) {
      returnDoubles[i]=byteBuffer.getDouble();
    }
 else {
      bufferIndex=getReadBuffer(buffers,8,bufferIndex);
      if (bufferIndex < 0) {
        throw new RuntimeException("String_Node_Str");
      }
    }
  }
  return returnDoubles;
}
Program: 173148
Project: 173148
Buggy source:
public static long[] deserializeLong(List<MPIBuffer> buffers,int byteLength){
  int noOfDoubles=byteLength / 8;
  long[] returnDoubles=new long[noOfDoubles];
  int bufferIndex=0;
  for (int i=0; i < noOfDoubles; i++) {
    ByteBuffer byteBuffer=buffers.get(bufferIndex).getByteBuffer();
    int remaining=byteBuffer.remaining();
    if (remaining > 8) {
      returnDoubles[i]=byteBuffer.getLong();
    }
 else {
      bufferIndex=getReadBuffer(buffers,8,bufferIndex);
      if (bufferIndex < 0) {
        throw new RuntimeException("String_Node_Str");
      }
    }
  }
  return returnDoubles;
}

Fixed version (ground truth):
public static long[] deserializeLong(List<MPIBuffer> buffers,int byteLength){
  int noOfDoubles=byteLength / 8;
  long[] returnDoubles=new long[noOfDoubles];
  int bufferIndex=0;
  for (int i=0; i < noOfDoubles; i++) {
    ByteBuffer byteBuffer=buffers.get(bufferIndex).getByteBuffer();
    int remaining=byteBuffer.remaining();
    if (remaining >= 8) {
      returnDoubles[i]=byteBuffer.getLong();
    }
 else {
      bufferIndex=getReadBuffer(buffers,8,bufferIndex);
      if (bufferIndex < 0) {
        throw new RuntimeException("String_Node_Str");
      }
    }
  }
  return returnDoubles;
}
Program: 173149
Project: 173149
Buggy source:
public static short[] deserializeShort(List<MPIBuffer> buffers,int byteLength){
  int noOfDoubles=byteLength / 2;
  short[] returnDoubles=new short[noOfDoubles];
  int bufferIndex=0;
  for (int i=0; i < noOfDoubles; i++) {
    ByteBuffer byteBuffer=buffers.get(bufferIndex).getByteBuffer();
    int remaining=byteBuffer.remaining();
    if (remaining > 2) {
      returnDoubles[i]=byteBuffer.getShort();
    }
 else {
      bufferIndex=getReadBuffer(buffers,4,bufferIndex);
      if (bufferIndex < 0) {
        throw new RuntimeException("String_Node_Str");
      }
    }
  }
  return returnDoubles;
}

Fixed version (ground truth):
public static short[] deserializeShort(List<MPIBuffer> buffers,int byteLength){
  int noOfDoubles=byteLength / 2;
  short[] returnDoubles=new short[noOfDoubles];
  int bufferIndex=0;
  for (int i=0; i < noOfDoubles; i++) {
    ByteBuffer byteBuffer=buffers.get(bufferIndex).getByteBuffer();
    int remaining=byteBuffer.remaining();
    if (remaining >= 2) {
      returnDoubles[i]=byteBuffer.getShort();
    }
 else {
      bufferIndex=getReadBuffer(buffers,4,bufferIndex);
      if (bufferIndex < 0) {
        throw new RuntimeException("String_Node_Str");
      }
    }
  }
  return returnDoubles;
}
Program: 173150
Project: 173150
Buggy source:
public static int[] deserializeInteger(List<MPIBuffer> buffers,int byteLength){
  int noOfDoubles=byteLength / 4;
  int[] returnDoubles=new int[noOfDoubles];
  int bufferIndex=0;
  for (int i=0; i < noOfDoubles; i++) {
    ByteBuffer byteBuffer=buffers.get(bufferIndex).getByteBuffer();
    int remaining=byteBuffer.remaining();
    if (remaining > 4) {
      returnDoubles[i]=byteBuffer.getInt();
    }
 else {
      bufferIndex=getReadBuffer(buffers,4,bufferIndex);
      if (bufferIndex < 0) {
        throw new RuntimeException("String_Node_Str");
      }
    }
  }
  return returnDoubles;
}

Fixed version (ground truth):
public static int[] deserializeInteger(List<MPIBuffer> buffers,int byteLength){
  int noOfDoubles=byteLength / 4;
  int[] returnDoubles=new int[noOfDoubles];
  int bufferIndex=0;
  for (int i=0; i < noOfDoubles; i++) {
    ByteBuffer byteBuffer=buffers.get(bufferIndex).getByteBuffer();
    int remaining=byteBuffer.remaining();
    if (remaining >= 4) {
      returnDoubles[i]=byteBuffer.getInt();
    }
 else {
      bufferIndex=getReadBuffer(buffers,4,bufferIndex);
      if (bufferIndex < 0) {
        throw new RuntimeException("String_Node_Str");
      }
    }
  }
  return returnDoubles;
}
Program: 173151
Project: 173151
Buggy source:
private static int getReadBuffer(List<MPIBuffer> bufs,int size,int currentBufferIndex){
  for (int i=currentBufferIndex; i < bufs.size(); i++) {
    ByteBuffer byteBuffer=bufs.get(i).getByteBuffer();
    if (byteBuffer.remaining() < size) {
      byteBuffer.rewind();
      return i;
    }
  }
  return -1;
}

Fixed version (ground truth):
private static int getReadBuffer(List<MPIBuffer> bufs,int size,int currentBufferIndex){
  for (int i=currentBufferIndex; i < bufs.size(); i++) {
    ByteBuffer byteBuffer=bufs.get(i).getByteBuffer();
    if (byteBuffer.remaining() > size) {
      byteBuffer.rewind();
      return i;
    }
  }
  return -1;
}
Program: 173152
Project: 173152
Buggy source:
private static boolean copyIntegers(int[] data,ByteBuffer targetBuffer,SerializeState state){
  int totalBytes=state.getTotalBytes();
  int remainingCapacity=targetBuffer.remaining();
  int bytesCopied=state.getBytesCopied();
  int remainingToCopy=data.length - bytesCopied / 4;
  int canCopy=(remainingCapacity > remainingToCopy ? remainingToCopy : remainingCapacity) / 4;
  int offSet=bytesCopied / 4;
  for (int i=0; i < canCopy; i++) {
    targetBuffer.putInt(data[i + offSet]);
  }
  totalBytes+=canCopy * 4;
  state.setTotalBytes(totalBytes);
  if (canCopy == remainingToCopy) {
    state.setData(null);
    state.setBytesCopied(0);
    return true;
  }
 else {
    state.setBytesCopied(canCopy * 4 + bytesCopied);
    return false;
  }
}

Fixed version (ground truth):
private static boolean copyIntegers(int[] data,ByteBuffer targetBuffer,SerializeState state){
  int totalBytes=state.getTotalBytes();
  int remainingCapacity=targetBuffer.remaining();
  int bytesCopied=state.getBytesCopied();
  int remainingToCopy=data.length * 4 - bytesCopied;
  int canCopy=(remainingCapacity > remainingToCopy ? remainingToCopy : remainingCapacity) / 4;
  int offSet=bytesCopied / 4;
  for (int i=0; i < canCopy; i++) {
    targetBuffer.putInt(data[i + offSet]);
  }
  totalBytes+=canCopy * 4;
  state.setTotalBytes(totalBytes);
  if ((canCopy * 4) == remainingToCopy) {
    state.setData(null);
    state.setBytesCopied(0);
    return true;
  }
 else {
    state.setBytesCopied(canCopy * 4 + bytesCopied);
    return false;
  }
}