nus-yam/ex-repair huggingface dataset:
Program: 172897
Project: 172897
Buggy source:
/** 
 * Create the job master client to get information about the workers
 */
private static JobMasterClient createMasterClient(Config cfg,int workerId,String host,int port) throws UnknownHostException {
  JobMasterClient jobMasterClient=new JobMasterClient(cfg,new WorkerNetworkInfo(InetAddress.getByName(host),port,workerId));
  LOG.log(Level.INFO,String.format("String_Node_Str",host,port));
  jobMasterClient.init();
  jobMasterClient.sendWorkerStartingMessage();
  return jobMasterClient;
}

Fixed version (ground truth):
/** 
 * Create the job master client to get information about the workers
 */
private static JobMasterClient createMasterClient(Config cfg,int workerId,String host,int workerPort,int masterPort,String masterHost) throws UnknownHostException {
  JobMasterClient jobMasterClient=new JobMasterClient(cfg,new WorkerNetworkInfo(InetAddress.getByName(host),workerPort,workerId),masterHost,masterPort);
  LOG.log(Level.INFO,String.format("String_Node_Str",host,workerPort));
  jobMasterClient.init();
  jobMasterClient.sendWorkerStartingMessage();
  return jobMasterClient;
}
Program: 172900
Project: 172900
Buggy source:
private void listWorkersMessageReceived(RequestID id,Network.ListWorkersRequest listMessage){
  if (listMessage.getRequestType() == Network.ListWorkersRequest.RequestType.IMMEDIATE_RESPONSE) {
    sendListWorkersResponse(listMessage.getWorkerID(),id);
    LOG.log(Level.INFO,String.format("String_Node_Str",numberOfWorkers,workers.size()));
  }
 else   if (listMessage.getRequestType() == Network.ListWorkersRequest.RequestType.RESPONSE_AFTER_ALL_JOINED) {
    if (workers.size() == numberOfWorkers) {
      sendListWorkersResponse(listMessage.getWorkerID(),id);
    }
 else {
      waitList.put(listMessage.getWorkerID(),id);
    }
    LOG.log(Level.INFO,String.format("String_Node_Str",numberOfWorkers,workers.size()));
  }
  LOG.log(Level.INFO,String.format("String_Node_Str",numberOfWorkers,workers.size()));
}

Fixed version (ground truth):
private void listWorkersMessageReceived(RequestID id,Network.ListWorkersRequest listMessage){
  if (listMessage.getRequestType() == Network.ListWorkersRequest.RequestType.IMMEDIATE_RESPONSE) {
    sendListWorkersResponse(listMessage.getWorkerID(),id);
    LOG.log(Level.INFO,String.format("String_Node_Str",numberOfWorkers,workers.size()));
  }
 else   if (listMessage.getRequestType() == Network.ListWorkersRequest.RequestType.RESPONSE_AFTER_ALL_JOINED) {
    waitList.put(listMessage.getWorkerID(),id);
    if (workers.size() == numberOfWorkers) {
      sendListWorkersResponseToWaitList();
    }
    LOG.log(Level.INFO,String.format("String_Node_Str",numberOfWorkers,workers.size()));
  }
  LOG.log(Level.INFO,String.format("String_Node_Str",numberOfWorkers,workers.size()));
}
Program: 172901
Project: 172901
Buggy source:
@Override public void onMessage(RequestID id,int workerId,Message message){
  if (message instanceof Network.Ping) {
    Network.Ping ping=(Network.Ping)message;
    pingMessageReceived(id,ping);
  }
 else   if (message instanceof Network.WorkerStateChange) {
    Network.WorkerStateChange wscMessage=(Network.WorkerStateChange)message;
    stateChangeMessageReceived(id,wscMessage);
  }
 else   if (message instanceof Network.ListWorkersRequest) {
    Network.ListWorkersRequest listMessage=(Network.ListWorkersRequest)message;
    listWorkersMessageReceived(id,listMessage);
  }
}

Fixed version (ground truth):
@Override public void onMessage(RequestID id,int workerId,Message message){
  if (message instanceof Network.Ping) {
    LOG.log(Level.INFO,"String_Node_Str" + message.toString());
    Network.Ping ping=(Network.Ping)message;
    pingMessageReceived(id,ping);
  }
 else   if (message instanceof Network.WorkerStateChange) {
    LOG.log(Level.INFO,"String_Node_Str" + message.toString());
    Network.WorkerStateChange wscMessage=(Network.WorkerStateChange)message;
    stateChangeMessageReceived(id,wscMessage);
  }
 else   if (message instanceof Network.ListWorkersRequest) {
    LOG.log(Level.INFO,"String_Node_Str" + message.toString());
    Network.ListWorkersRequest listMessage=(Network.ListWorkersRequest)message;
    listWorkersMessageReceived(id,listMessage);
  }
}
Program: 172902
Project: 172902
Buggy source:
public JobMasterClient(Config config,WorkerNetworkInfo thisWorker,String masterHost,int masterPort){
  this.config=config;
  this.thisWorker=thisWorker;
  this.masterAddress=masterHost;
  this.masterPort=masterPort;
}

Fixed version (ground truth):
public JobMasterClient(Config config,WorkerNetworkInfo thisWorker,String masterHost,int masterPort,int numberOfWorkers){
  this.config=config;
  this.thisWorker=thisWorker;
  this.masterAddress=masterHost;
  this.masterPort=masterPort;
  this.numberOfWorkers=numberOfWorkers;
}
Program: 172904
Project: 172904
Buggy source:
public WorkerController(Config config,WorkerNetworkInfo thisWorker,RRClient rrClient){
  this.config=config;
  this.numberOfWorkers=JobMasterContext.workerInstances(config);
  this.thisWorker=thisWorker;
  this.rrClient=rrClient;
  workerList=new ArrayList<>();
  workerList.add(thisWorker);
}

Fixed version (ground truth):
public WorkerController(Config config,WorkerNetworkInfo thisWorker,RRClient rrClient,int numberOfWorkers){
  this.config=config;
  this.numberOfWorkers=numberOfWorkers;
  this.thisWorker=thisWorker;
  this.rrClient=rrClient;
  workerList=new ArrayList<>();
  workerList.add(thisWorker);
}
Program: 172905
Project: 172905
Buggy source:
/** 
 * Create the job master client to get information about the workers
 */
private static JobMasterClient createMasterClient(Config cfg,int workerId,String host,int workerPort,int masterPort,String masterHost) throws UnknownHostException {
  JobMasterClient jobMasterClient=new JobMasterClient(cfg,new WorkerNetworkInfo(InetAddress.getByName(host),workerPort,workerId),masterHost,masterPort);
  LOG.log(Level.INFO,String.format("String_Node_Str",host,workerPort));
  jobMasterClient.init();
  jobMasterClient.sendWorkerStartingMessage();
  return jobMasterClient;
}

Fixed version (ground truth):
/** 
 * Create the job master client to get information about the workers
 */
private static JobMasterClient createMasterClient(Config cfg,int workerId,String host,int workerPort,int masterPort,String masterHost) throws UnknownHostException {
  JobMasterClient jobMasterClient=new JobMasterClient(cfg,new WorkerNetworkInfo(InetAddress.getByName(host),workerPort,workerId),masterHost,masterPort,4);
  LOG.log(Level.INFO,String.format("String_Node_Str",host,workerPort));
  jobMasterClient.init();
  jobMasterClient.sendWorkerStartingMessage();
  return jobMasterClient;
}
Program: 172906
Project: 172906
Buggy source:
/** 
 * Start the connections to the servers
 * @param workerInfo
 * @param updatedThisInfo
 */
public void startConnections(List<NetworkInfo> workerInfo,NetworkInfo updatedThisInfo){
  this.networkInfos=workerInfo;
  for (  NetworkInfo ni : workerInfo) {
    networkInfoMap.put(ni.getProcId(),ni);
    helloSendByteBuffers.add(ByteBuffer.allocate(4));
    helloReceiveByteBuffers.add(ByteBuffer.allocate(4));
    helloSendByteBuffers.add(ByteBuffer.allocate(4));
    helloReceiveByteBuffers.add(ByteBuffer.allocate(4));
  }
  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 ClientChannelChannelHandler());
    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.FINEST,"String_Node_Str" + clientsConnected + "String_Node_Str"+ clientsCompleted);
}

Fixed version (ground truth):
/** 
 * Start the connections to the servers
 * @param workerInfo
 * @param updatedThisInfo
 */
public void startConnections(List<NetworkInfo> workerInfo,NetworkInfo updatedThisInfo){
  this.networkInfos=workerInfo;
  for (  NetworkInfo ni : workerInfo) {
    networkInfoMap.put(ni.getProcId(),ni);
    helloSendByteBuffers.add(ByteBuffer.allocate(4));
    helloReceiveByteBuffers.add(ByteBuffer.allocate(4));
    helloSendByteBuffers.add(ByteBuffer.allocate(4));
    helloReceiveByteBuffers.add(ByteBuffer.allocate(4));
  }
  for (  NetworkInfo info : networkInfos) {
    if (info.getProcId() == thisInfo.getProcId()) {
      continue;
    }
    try {
      String remoteHost=TCPContext.getHostName(info);
      int remotePort=TCPContext.getPort(info);
      Client client=new Client(remoteHost,remotePort,config,looper,new ClientChannelChannelHandler());
      client.connect();
      clients.put(info.getProcId(),client);
      invertedClientChannels.put(client.getSocketChannel(),info.getProcId());
    }
 catch (    UnresolvedAddressException e) {
    }
  }
  while (clientsConnected != (networkInfos.size() - 1) || (clientsCompleted != networkInfos.size() - 1)) {
    looper.loop();
  }
  LOG.log(Level.FINEST,"String_Node_Str" + clientsConnected + "String_Node_Str"+ clientsCompleted);
}
Program: 172907
Project: 172907
Buggy source:
public static String getHostName(NetworkInfo networkInfo){
  return networkInfo.getProperties().get(NETWORK_HOSTNAME).toString();
}

Fixed version (ground truth):
public static String getHostName(NetworkInfo networkInfo){
  return (String)networkInfo.getProperties().get(NETWORK_HOSTNAME);
}
Program: 172908
Project: 172908
Buggy source:
/** 
 * Create the job master client to get information about the workers
 */
private static JobMasterClient createMasterClient(Config cfg,int workerId,String host,int workerPort,int masterPort,String masterHost) throws UnknownHostException {
  String jobName=StandaloneContext.jobName(cfg);
  String jobDescFile=JobUtils.getJobDescriptionFilePath(jobName,cfg);
  JobAPI.Job job=JobUtils.readJobFile(null,jobDescFile);
  int numberContainers=job.getJobResources().getNoOfContainers();
  JobMasterClient jobMasterClient=new JobMasterClient(cfg,new WorkerNetworkInfo(InetAddress.getByName(host),workerPort,workerId),masterHost,masterPort,numberContainers);
  LOG.log(Level.INFO,String.format("String_Node_Str",host,workerPort));
  jobMasterClient.init();
  jobMasterClient.sendWorkerStartingMessage();
  return jobMasterClient;
}

Fixed version (ground truth):
/** 
 * Create the job master client to get information about the workers
 */
private static JobMasterClient createMasterClient(Config cfg,int workerId,String workerHost,int workerPort,int masterPort,String masterHost) throws UnknownHostException {
  String jobName=StandaloneContext.jobName(cfg);
  String jobDescFile=JobUtils.getJobDescriptionFilePath(jobName,cfg);
  JobAPI.Job job=JobUtils.readJobFile(null,jobDescFile);
  int numberContainers=job.getJobResources().getNoOfContainers();
  JobMasterClient jobMasterClient=new JobMasterClient(cfg,new WorkerNetworkInfo(InetAddress.getByName(workerHost),workerPort,workerId),masterHost,masterPort,numberContainers);
  LOG.log(Level.INFO,String.format("String_Node_Str",workerHost,workerPort));
  jobMasterClient.init();
  jobMasterClient.sendWorkerStartingMessage();
  return jobMasterClient;
}
Program: 172910
Project: 172910
Buggy source:
public boolean addWriteRequest(TCPMessage request){
  ByteBuffer byteBuffer=request.getByteBuffer();
  byteBuffer.position(request.getLength());
  return pendingSends.offer(request);
}

Fixed version (ground truth):
public boolean addWriteRequest(TCPMessage request){
  ByteBuffer byteBuffer=request.getByteBuffer();
  if (request.getLength() == 0) {
    throw new RuntimeException("String_Node_Str");
  }
  if (byteBuffer.remaining() == 0) {
    throw new RuntimeException("String_Node_Str");
  }
  return pendingSends.offer(request);
}
Program: 172911
Project: 172911
Buggy source:
private int writeRequest(SocketChannel channel,TCPMessage message){
  ByteBuffer buffer=message.getByteBuffer();
  int written=0;
  if (writeStatus == DataStatus.INIT) {
    writeHeader.clear();
    writeStatus=DataStatus.HEADER;
    writeHeader.putInt(message.getLength());
    writeHeader.putInt(message.getEdge());
    writeHeader.flip();
    LOG.finest(String.format("String_Node_Str",message.getLength(),message.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) {
    buffer.flip();
    written=writeToChannel(channel,buffer);
    if (written < 0) {
      return written;
    }
 else     if (written == 0) {
      LOG.finest(String.format("String_Node_Str",buffer.limit()));
      writeStatus=DataStatus.INIT;
      return written;
    }
  }
  return written;
}

Fixed version (ground truth):
private int writeRequest(SocketChannel channel,TCPMessage message){
  ByteBuffer buffer=message.getByteBuffer();
  int written=0;
  if (writeStatus == DataStatus.INIT) {
    writeHeader.clear();
    writeStatus=DataStatus.HEADER;
    writeHeader.putInt(message.getLength());
    writeHeader.putInt(message.getEdge());
    writeHeader.flip();
    LOG.finest(String.format("String_Node_Str",message.getLength(),message.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,buffer);
    if (written < 0) {
      return written;
    }
 else     if (written == 0) {
      LOG.finest(String.format("String_Node_Str",buffer.limit()));
      writeStatus=DataStatus.INIT;
      return written;
    }
  }
  return written;
}
Program: 172912
Project: 172912
Buggy source:
public TCPMessage send(SocketChannel sc,ByteBuffer buffer,int size,int edge){
  if (sc != socketChannel) {
    return null;
  }
  if (!isConnected) {
    return null;
  }
  channel.enableWriting();
  TCPMessage request=new TCPMessage(buffer,edge,size);
  if (channel.addWriteRequest(request)) {
    return request;
  }
  return null;
}

Fixed version (ground truth):
public TCPMessage send(SocketChannel sc,ByteBuffer buffer,int size,int edge){
  if (sc != socketChannel) {
    return null;
  }
  if (!isConnected) {
    return null;
  }
  buffer.limit(size);
  buffer.position(0);
  channel.enableWriting();
  TCPMessage request=new TCPMessage(buffer,edge,size);
  if (channel.addWriteRequest(request)) {
    return request;
  }
  return null;
}
Program: 172913
Project: 172913
Buggy source:
public TCPMessage send(SocketChannel sc,ByteBuffer buffer,int size,int edge){
  BaseNetworkChannel channel=connectedChannels.get(sc);
  if (channel == null) {
    return null;
  }
  channel.enableWriting();
  TCPMessage request=new TCPMessage(buffer,edge,size);
  channel.addWriteRequest(request);
  return request;
}

Fixed version (ground truth):
public TCPMessage send(SocketChannel sc,ByteBuffer buffer,int size,int edge){
  BaseNetworkChannel channel=connectedChannels.get(sc);
  if (channel == null) {
    return null;
  }
  buffer.limit(size);
  buffer.position(0);
  channel.enableWriting();
  TCPMessage request=new TCPMessage(buffer,edge,size);
  channel.addWriteRequest(request);
  return request;
}
Program: 172914
Project: 172914
Buggy source:
/** 
 * Start listening
 */
public void startListening(){
  String hostName=TCPContext.getHostName(thisInfo);
  int port=TCPContext.getPort(thisInfo);
  looper=new Progress();
  server=new Server(config,hostName,port,looper,new ChannelServerChannelHandler());
  server.start();
}

Fixed version (ground truth):
/** 
 * Start listening
 */
public void startListening(){
  String hostName=TCPContext.getHostName(thisInfo);
  int port=TCPContext.getPort(thisInfo);
  looper=new Progress();
  server=new Server(config,hostName,port,looper,new ServerChannelHandler(),true);
  server.start();
}
Program: 172915
Project: 172915
Buggy source:
public void waitForConnections(){
  while (clientsConnected != (networkInfos.size() - 1) || (clientsCompleted != networkInfos.size() - 1)) {
    looper.loop();
  }
  while (serverChannel.size() != networkInfos.size() - 1) {
    looper.loop();
  }
  LOG.log(Level.FINEST,"String_Node_Str" + clientsConnected + "String_Node_Str"+ clientsCompleted);
}

Fixed version (ground truth):
/** 
 * Wait for handshakes to happen between servers and clients
 */
public void waitForConnections(){
  while (clientsConnected != (networkInfos.size() - 1) || (clientsCompleted != networkInfos.size() - 1)) {
    looper.loop();
  }
  while (serverChannel.size() != networkInfos.size() - 1) {
    looper.loop();
  }
  LOG.log(Level.FINEST,"String_Node_Str" + clientsConnected + "String_Node_Str"+ clientsCompleted);
}
Program: 172916
Project: 172916
Buggy source:
private void sendHelloMessage(int destProcId,SocketChannel sc){
  ByteBuffer buffer=helloSendByteBuffers.remove(0);
  buffer.putInt(thisInfo.getProcId());
  Client client=clients.get(destProcId);
  client.send(sc,buffer,4,-1);
}

Fixed version (ground truth):
private void sendHelloMessage(int destProcId,SocketChannel sc){
  ByteBuffer buffer=helloSendByteBuffers.remove(0);
  buffer.clear();
  buffer.putInt(thisInfo.getProcId());
  Client client=clients.get(destProcId);
  client.send(sc,buffer,4,-1);
}
Program: 172917
Project: 172917
Buggy source:
@Test public void sendMessages(){
  List<TCPMessage> sends=new ArrayList<>();
  List<TCPMessage> recvs=new ArrayList<>();
  for (int i=0; i < NO_OF_CHANNELS; i++) {
    TCPChannel channel=channels.get(i);
    for (int j=0; j < NO_OF_CHANNELS; j++) {
      if (j != i) {
        TCPMessage message=channel.iRecv(buffers.get(j),10,j,1);
        recvs.add(message);
      }
    }
  }
  for (int i=0; i < NO_OF_CHANNELS; i++) {
    TCPChannel channel=channels.get(i);
    for (int j=0; j < NO_OF_CHANNELS; j++) {
      if (j != i) {
        TCPMessage message=channel.iSend(buffers.get(j),10,j,1);
        sends.add(message);
      }
    }
  }
  List<Integer> completedSends=new ArrayList<>();
  List<Integer> completedRcvs=new ArrayList<>();
  while (completedRcvs.size() != NO_OF_CHANNELS || completedSends.size() != NO_OF_CHANNELS) {
    for (int i=0; i < NO_OF_CHANNELS; i++) {
      TCPMessage sendMsg=sends.get(i);
      TCPMessage rcvMsg=recvs.get(i);
      if (sendMsg.isComplete()) {
        if (!completedSends.contains(i)) {
          completedSends.add(i);
        }
      }
      if (rcvMsg.isComplete()) {
        if (!completedRcvs.contains(i)) {
          completedRcvs.add(i);
        }
      }
      TCPChannel ch=channels.get(i);
      ch.progress();
    }
  }
}

Fixed version (ground truth):
@Test public void sendMessages(){
  List<TCPMessage> sends=new ArrayList<>();
  List<TCPMessage> recvs=new ArrayList<>();
  for (int i=0; i < NO_OF_CHANNELS; i++) {
    TCPChannel channel=channels.get(i);
    for (int j=0; j < NO_OF_CHANNELS; j++) {
      if (j != i) {
        ByteBuffer buffer=buffers.get(j);
        buffer.clear();
        TCPMessage message=channel.iRecv(buffer,10,j,1);
        recvs.add(message);
      }
    }
  }
  for (int i=0; i < NO_OF_CHANNELS; i++) {
    TCPChannel channel=channels.get(i);
    for (int j=0; j < NO_OF_CHANNELS; j++) {
      if (j != i) {
        ByteBuffer buffer=buffers.get(j);
        buffer.clear();
        buffer.put(new byte[10]);
        TCPMessage message=channel.iSend(buffer,10,j,1);
        sends.add(message);
      }
    }
  }
  List<Integer> completedSends=new ArrayList<>();
  List<Integer> completedRcvs=new ArrayList<>();
  while (completedRcvs.size() != NO_OF_CHANNELS || completedSends.size() != NO_OF_CHANNELS) {
    for (int i=0; i < NO_OF_CHANNELS; i++) {
      TCPMessage sendMsg=sends.get(i);
      TCPMessage rcvMsg=recvs.get(i);
      if (sendMsg.isComplete()) {
        if (!completedSends.contains(i)) {
          completedSends.add(i);
        }
      }
      if (rcvMsg.isComplete()) {
        if (!completedRcvs.contains(i)) {
          completedRcvs.add(i);
        }
      }
      TCPChannel ch=channels.get(i);
      ch.progress();
    }
  }
}
Program: 172918
Project: 172918
Buggy source:
@After public void tearDown() throws Exception {
  for (  TCPChannel channel : channels) {
    channel.stop();
  }
}

Fixed version (ground truth):
@After public void tearDown() throws Exception {
}
Program: 172919
Project: 172919
Buggy source:
private static ResourcePlan createResourcePlan(Config config){
  return null;
}

Fixed version (ground truth):
private static ResourcePlan createResourcePlan(Config config){
  Map<String,Integer> ports=getPorts(config);
  JobMasterClient client=createMasterClient(config,0,new InetSocketAddress(0).getAddress(),ports);
  WorkerController workerController=client.getWorkerController();
  workerController.waitForAllWorkersToJoin(30000);
  return null;
}
Program: 172921
Project: 172921
Buggy source:
public void init(Config cfg,DataFlowOperation op,Map<Integer,List<Integer>> expectedIds){
  int maxBytesInMemory=DataFlowContext.getShuffleMaxBytesInMemory(cfg);
  int maxRecordsInMemory=DataFlowContext.getShuffleMaxRecordsInMemory(cfg);
  String path=DataFlowContext.getShuffleDirectoryPath(cfg);
  executor=op.getTaskPlan().getThisExecutor();
  finishedSources=new HashMap<>();
  partition=(DataFlowPartition)op;
  keyed=partition.getKeyType() != null;
  for (  Integer target : expectedIds.keySet()) {
    Map<Integer,Boolean> perTarget=new ConcurrentHashMap<>();
    for (    Integer exp : expectedIds.get(target)) {
      perTarget.put(exp,false);
    }
    Shuffle sortedMerger;
    if (partition.getKeyType() == null) {
      sortedMerger=new FSMerger(maxBytesInMemory,maxRecordsInMemory,path,getOperationName(target),partition.getDataType());
    }
 else {
      if (sorted) {
        sortedMerger=new FSKeyedSortedMerger(maxBytesInMemory,maxRecordsInMemory,path,getOperationName(target),partition.getKeyType(),partition.getDataType(),comparator,target);
      }
 else {
        sortedMerger=new FSKeyedMerger(maxBytesInMemory,maxRecordsInMemory,path,getOperationName(target),partition.getKeyType(),partition.getDataType());
      }
    }
    sortedMergers.put(target,sortedMerger);
    totalReceives.put(target,0);
    finishedSources.put(target,new HashSet<>());
  }
}

Fixed version (ground truth):
public void init(Config cfg,DataFlowOperation op,Map<Integer,List<Integer>> expectedIds){
  int maxBytesInMemory=DataFlowContext.getShuffleMaxBytesInMemory(cfg);
  int maxRecordsInMemory=DataFlowContext.getShuffleMaxRecordsInMemory(cfg);
  String path=DataFlowContext.getShuffleDirectoryPath(cfg);
  worker=op.getTaskPlan().getThisExecutor();
  finishedSources=new HashMap<>();
  partition=(DataFlowPartition)op;
  keyed=partition.getKeyType() != null;
  for (  Integer target : expectedIds.keySet()) {
    Map<Integer,Boolean> perTarget=new ConcurrentHashMap<>();
    for (    Integer exp : expectedIds.get(target)) {
      perTarget.put(exp,false);
    }
    Shuffle sortedMerger;
    if (partition.getKeyType() == null) {
      sortedMerger=new FSMerger(maxBytesInMemory,maxRecordsInMemory,path,getOperationName(target),partition.getDataType());
    }
 else {
      if (sorted) {
        sortedMerger=new FSKeyedSortedMerger(maxBytesInMemory,maxRecordsInMemory,path,getOperationName(target),partition.getKeyType(),partition.getDataType(),comparator,target);
      }
 else {
        sortedMerger=new FSKeyedMerger(maxBytesInMemory,maxRecordsInMemory,path,getOperationName(target),partition.getKeyType(),partition.getDataType());
      }
    }
    sortedMergers.put(target,sortedMerger);
    totalReceives.put(target,0);
    finishedSources.put(target,new HashSet<>());
  }
}
Program: 172922
Project: 172922
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public boolean onMessage(int source,int destination,int target,int flags,Object object){
  Shuffle sortedMerger=sortedMergers.get(target);
  if (sortedMerger == null) {
    throw new RuntimeException("String_Node_Str" + target);
  }
  if ((flags & MessageFlags.EMPTY) == MessageFlags.EMPTY) {
    Set<Integer> finished=finishedSources.get(target);
    if (finished.contains(source)) {
      LOG.log(Level.WARNING,String.format("String_Node_Str",executor,source));
    }
 else {
      finished.add(source);
    }
    if (finished.size() == partition.getSources().size()) {
      finishedTargets.add(target);
    }
    return true;
  }
  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);
    }
    int total=totalReceives.get(target);
    total+=keyedContents.size();
    totalReceives.put(target,total);
  }
 else {
    List<Object> contents=(List<Object>)object;
    for (    Object kc : contents) {
      byte[] d=kryoSerializer.serialize(kc);
      sortedMerger.add(d,d.length);
    }
    int total=totalReceives.get(target);
    total+=contents.size();
    totalReceives.put(target,total);
  }
  return true;
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public boolean onMessage(int source,int destination,int target,int flags,Object object){
  Shuffle sortedMerger=sortedMergers.get(target);
  if (sortedMerger == null) {
    throw new RuntimeException("String_Node_Str" + target);
  }
  if ((flags & MessageFlags.EMPTY) == MessageFlags.EMPTY) {
    Set<Integer> finished=finishedSources.get(target);
    if (finished.contains(source)) {
      LOG.log(Level.WARNING,String.format("String_Node_Str",worker,source));
    }
 else {
      finished.add(source);
    }
    if (finished.size() == partition.getSources().size()) {
      finishedTargets.add(target);
    }
    return true;
  }
  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);
    }
    int total=totalReceives.get(target);
    total+=keyedContents.size();
    totalReceives.put(target,total);
  }
 else {
    List<Object> contents=(List<Object>)object;
    for (    Object kc : contents) {
      byte[] d=kryoSerializer.serialize(kc);
      sortedMerger.add(d,d.length);
    }
    int total=totalReceives.get(target);
    total+=contents.size();
    totalReceives.put(target,total);
  }
  return true;
}
Program: 172923
Project: 172923
Buggy source:
@Override public void onFinish(int target){
  Shuffle sortedMerger=sortedMergers.get(target);
  sortedMerger.switchToReading();
  Iterator<Object> itr=sortedMerger.readIterator();
  try {
    batchReceiver.receive(target,itr);
  }
 catch (  RuntimeException e) {
    LOG.log(Level.INFO,"String_Node_Str" + executor + "String_Node_Str"+ target,e);
  }
}

Fixed version (ground truth):
@Override public void onFinish(int target){
  Shuffle sortedMerger=sortedMergers.get(target);
  sortedMerger.switchToReading();
  Iterator<Object> itr=sortedMerger.readIterator();
  batchReceiver.receive(target,itr);
}
Program: 172924
Project: 172924
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(object);
  if (dests.size() > lowWaterMark) {
    lock.lock();
    try {
      readyToSend.put(destination,new ArrayList<>(dests));
      dests.clear();
    }
  finally {
      lock.unlock();
    }
  }
  totals++;
  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: 172925
Project: 172925
Buggy source:
@Override public void progress(){
  lock.lock();
  try {
    if (finish && readyToSend.isEmpty() && finishedDestinations.size() != destinations.size()) {
      for (      int dest : destinations) {
        if (!finishedDestinations.contains(dest)) {
          if (operation.sendPartial(source,new byte[1],MessageFlags.EMPTY,dest)) {
            finishedDestinations.add(dest);
          }
        }
      }
      return;
    }
    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();
  }
}

Fixed version (ground truth):
@Override public void progress(){
  lock.lock();
  try {
    if (finish && readyToSend.isEmpty() && finishedDestinations.size() != destinations.size()) {
      for (      int dest : destinations) {
        if (!finishedDestinations.contains(dest)) {
          if (operation.sendPartial(source,new byte[1],MessageFlags.EMPTY,dest)) {
            finishedDestinations.add(dest);
          }
 else {
            break;
          }
        }
      }
      return;
    }
    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: 172928
Project: 172928
Buggy source:
private Object buildMessage(MPIMessage mpiMessage,List<MPIBuffer> message,int length){
  MessageType type=mpiMessage.getType();
  if (keyed) {
    Pair<Integer,Object> keyPair=KeyDeserializer.deserializeKey(mpiMessage.getKeyType(),message,serializer);
    if (MessageTypeUtils.isMultiMessageType(mpiMessage.getKeyType())) {
      return DataDeserializer.deserializeData(message,length - keyPair.getKey(),serializer,type,((List)keyPair.getValue()).size());
    }
 else {
      return DataDeserializer.deserializeData(message,length - keyPair.getKey(),serializer,type);
    }
  }
 else {
    return DataDeserializer.deserializeData(message,length,serializer,type);
  }
}

Fixed version (ground truth):
private Object buildMessage(MPIMessage mpiMessage,List<MPIBuffer> message,int length){
  MessageType type=mpiMessage.getType();
  if (keyed) {
    Pair<Integer,Object> keyPair=KeyDeserializer.deserializeKey(mpiMessage.getKeyType(),message,serializer);
    Object data;
    if (MessageTypeUtils.isMultiMessageType(mpiMessage.getKeyType())) {
      data=DataDeserializer.deserializeData(message,length - keyPair.getKey(),serializer,type,((List)keyPair.getValue()).size());
    }
 else {
      data=DataDeserializer.deserializeData(message,length - keyPair.getKey(),serializer,type);
    }
    return new KeyedContent(keyPair.getValue(),data,mpiMessage.getKeyType(),mpiMessage.getType());
  }
 else {
    return DataDeserializer.deserializeData(message,length,serializer,type);
  }
}
Program: 172930
Project: 172930
Buggy source:
public void init(Config cfg,DataFlowOperation op,Map<Integer,List<Integer>> expectedIds){
  int maxBytesInMemory=MPIContext.getShuffleMaxBytesInMemory(cfg);
  int maxRecordsInMemory=MPIContext.getShuffleMaxRecordsInMemory(cfg);
  String path=MPIContext.getShuffleDirectoryPath(cfg);
  finished=new ConcurrentHashMap<>();
  partition=(MPIDataFlowPartition)op;
  keyed=partition.getKeyType() != null;
  for (  Integer target : expectedIds.keySet()) {
    Map<Integer,Boolean> perTarget=new ConcurrentHashMap<>();
    for (    Integer exp : expectedIds.get(target)) {
      perTarget.put(exp,false);
    }
    finished.put(target,perTarget);
    Shuffle sortedMerger;
    if (partition.getKeyType() == null) {
      sortedMerger=new FSMerger(maxBytesInMemory,maxRecordsInMemory,path,getOperationName(target),partition.getDataType());
    }
 else {
      if (sorted) {
        sortedMerger=new FSKeyedSortedMerger(maxBytesInMemory,maxRecordsInMemory,path,getOperationName(target),partition.getKeyType(),partition.getDataType(),comparator);
      }
 else {
        sortedMerger=new FSKeyedMerger(maxBytesInMemory,maxRecordsInMemory,path,getOperationName(target),partition.getKeyType(),partition.getDataType());
      }
    }
    sortedMergers.put(target,sortedMerger);
  }
}

Fixed version (ground truth):
public void init(Config cfg,DataFlowOperation op,Map<Integer,List<Integer>> expectedIds){
  int maxBytesInMemory=MPIContext.getShuffleMaxBytesInMemory(cfg);
  int maxRecordsInMemory=MPIContext.getShuffleMaxRecordsInMemory(cfg);
  String path=MPIContext.getShuffleDirectoryPath(cfg);
  finished=new ConcurrentHashMap<>();
  partition=(MPIDataFlowPartition)op;
  keyed=partition.getKeyType() != null;
  for (  Integer target : expectedIds.keySet()) {
    Map<Integer,Boolean> perTarget=new ConcurrentHashMap<>();
    for (    Integer exp : expectedIds.get(target)) {
      perTarget.put(exp,false);
    }
    finished.put(target,perTarget);
    Shuffle sortedMerger;
    if (partition.getKeyType() == null) {
      sortedMerger=new FSMerger(maxBytesInMemory,maxRecordsInMemory,path,getOperationName(target),partition.getDataType());
    }
 else {
      if (sorted) {
        sortedMerger=new FSKeyedSortedMerger(maxBytesInMemory,maxRecordsInMemory,path,getOperationName(target),partition.getKeyType(),partition.getDataType(),comparator,target);
      }
 else {
        sortedMerger=new FSKeyedMerger(maxBytesInMemory,maxRecordsInMemory,path,getOperationName(target),partition.getKeyType(),partition.getDataType());
      }
    }
    sortedMergers.put(target,sortedMerger);
  }
}
Program: 172931
Project: 172931
Buggy source:
public PartitionBatchFinalReceiver(GatherBatchReceiver receiver,boolean srt,boolean d){
  this.batchReceiver=receiver;
  this.sorted=srt;
  this.disk=d;
  this.kryoSerializer=new KryoSerializer();
}

Fixed version (ground truth):
public PartitionBatchFinalReceiver(GatherBatchReceiver receiver,boolean srt,boolean d,Comparator<Object> com){
  this.batchReceiver=receiver;
  this.sorted=srt;
  this.disk=d;
  this.kryoSerializer=new KryoSerializer();
  this.comparator=com;
}
Program: 172932
Project: 172932
Buggy source:
/** 
 * Add the data to the file
 * @param data
 * @param length
 */
public void add(Object key,byte[] data,int length){
  if (status == FSStatus.READING) {
    throw new RuntimeException("String_Node_Str");
  }
  lock.lock();
  try {
    recordsInMemory.add(new KeyValue(key,data,keyComparator));
    bytesLength.add(length);
    numOfBytesInMemory+=length;
    if (numOfBytesInMemory > maxBytesToKeepInMemory || recordsInMemory.size() > maxRecordsInMemory) {
      notFull.signal();
    }
  }
  finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
/** 
 * Add the data to the file
 * @param data
 * @param length
 */
public void add(Object key,byte[] data,int length){
  if (status == FSStatus.READING) {
    throw new RuntimeException("String_Node_Str");
  }
  lock.lock();
  try {
    recordsInMemory.add(new KeyValue(convertKeyToArray(key),data,keyComparator));
    bytesLength.add(length);
    numOfBytesInMemory+=length;
    if (numOfBytesInMemory > maxBytesToKeepInMemory || recordsInMemory.size() > maxRecordsInMemory) {
      notFull.signal();
    }
  }
  finally {
    lock.unlock();
  }
}
Program: 172933
Project: 172933
Buggy source:
FSIterator(){
  heap=new Heap(noOfFileWritten + 1,keyComparator);
  maxMemoryPerFile=maxBytesToKeepInMemory / noOfFileWritten;
  for (int i=0; i < noOfFileWritten; i++) {
    OpenFilePart part=FileLoader.openPart(getSaveFileName(i),0,maxMemoryPerFile,keyType,dataType,kryoSerializer);
    openFiles.put(i,part);
  }
  openFiles.put(-1,new OpenFilePart(objectsInMemory,0,0,null));
  for (  Map.Entry<Integer,OpenFilePart> e : openFiles.entrySet()) {
    OpenFilePart part=e.getValue();
    if (part.hasNext()) {
      KeyValue keyValue=part.next();
      heap.insert(keyValue,e.getKey());
      numValuesInHeap++;
    }
 else {
      LOG.log(Level.WARNING,"String_Node_Str" + part.getFileName());
    }
  }
}

Fixed version (ground truth):
FSIterator(){
  heap=new Heap(noOfFileWritten + 1,keyComparator);
  if (noOfFileWritten > 0) {
    maxMemoryPerFile=maxBytesToKeepInMemory / noOfFileWritten;
  }
 else {
    maxMemoryPerFile=maxBytesToKeepInMemory;
  }
  for (int i=0; i < noOfFileWritten; i++) {
    OpenFilePart part=FileLoader.openPart(getSaveFileName(i),0,maxMemoryPerFile,keyType,dataType,kryoSerializer);
    openFiles.put(i,part);
  }
  openFiles.put(-1,new OpenFilePart(objectsInMemory,0,0,null));
  for (  Map.Entry<Integer,OpenFilePart> e : openFiles.entrySet()) {
    OpenFilePart part=e.getValue();
    if (part.hasNext()) {
      KeyValue keyValue=part.next();
      heap.insert(keyValue,e.getKey());
      numValuesInHeap++;
    }
 else {
      LOG.log(Level.WARNING,String.format("String_Node_Str",part.getFileName(),target));
    }
  }
}
Program: 172934
Project: 172934
Buggy source:
public FSKeyedSortedMerger(int maxBytesInMemory,int maxRecsInMemory,String dir,String opName,MessageType kType,MessageType dType,Comparator<Object> kComparator){
  this.maxBytesToKeepInMemory=maxBytesInMemory;
  this.maxRecordsInMemory=maxRecsInMemory;
  this.folder=dir;
  this.operationName=opName;
  this.keyType=kType;
  this.dataType=dType;
  this.keyComparator=kComparator;
  this.kryoSerializer=new KryoMemorySerializer();
}

Fixed version (ground truth):
public FSKeyedSortedMerger(int maxBytesInMemory,int maxRecsInMemory,String dir,String opName,MessageType kType,MessageType dType,Comparator<Object> kComparator,int tar){
  this.maxBytesToKeepInMemory=maxBytesInMemory;
  this.maxRecordsInMemory=maxRecsInMemory;
  this.folder=dir;
  this.operationName=opName;
  this.keyType=kType;
  this.dataType=dType;
  this.keyComparator=kComparator;
  this.kryoSerializer=new KryoMemorySerializer();
  this.target=tar;
}
Program: 172935
Project: 172935
Buggy source:
@Before public void before() throws Exception {
  fsMerger=new FSKeyedSortedMerger(1000,100,"String_Node_Str","String_Node_Str",MessageType.INTEGER,MessageType.OBJECT,new KeyComparator());
  random=new Random();
  serializer=new KryoSerializer();
}

Fixed version (ground truth):
@Before public void before() throws Exception {
  fsMerger=new FSKeyedSortedMerger(1000,100,"String_Node_Str","String_Node_Str",MessageType.INTEGER,MessageType.OBJECT,new KeyComparator(),0);
  random=new Random();
  serializer=new KryoSerializer();
}
Program: 172936
Project: 172936
Buggy source:
@Override public void init(Config cfg,int containerId,ResourcePlan plan){
  this.config=cfg;
  this.resourcePlan=plan;
  this.id=containerId;
  this.noOfTasksPerExecutor=NO_OF_TASKS / plan.noOfContainers();
  setupTasks();
  setupNetwork();
  partition=new MPIDataFlowPartition(config,channel,taskPlan,sources,destinations,new PartitionBatchFinalReceiver(new RecordSave(),true,true),new PartitionPartialReceiver(),MPIDataFlowPartition.PartitionStratergy.DIRECT,MessageType.BYTE,MessageType.BYTE,MessageType.INTEGER,MessageType.INTEGER,OperationSemantics.STREAMING_BATCH,new EdgeGenerator(0));
  scheduleTasks();
  progress();
}

Fixed version (ground truth):
@Override public void init(Config cfg,int containerId,ResourcePlan plan){
  this.config=cfg;
  this.resourcePlan=plan;
  this.id=containerId;
  this.noOfTasksPerExecutor=NO_OF_TASKS / plan.noOfContainers();
  setupTasks();
  setupNetwork();
  partition=new MPIDataFlowPartition(config,channel,taskPlan,sources,destinations,new PartitionBatchFinalReceiver(new RecordSave(),true,true,new IntegerComparator()),new PartitionPartialReceiver(),MPIDataFlowPartition.PartitionStratergy.DIRECT,MessageType.BYTE,MessageType.BYTE,MessageType.INTEGER,MessageType.INTEGER,OperationSemantics.STREAMING_BATCH,new EdgeGenerator(0));
  scheduleTasks();
  progress();
}
Program: 172937
Project: 172937
Buggy source:
@Override public void init(Config cfg,DataFlowOperation op,Map<Integer,Map<Integer,List<Integer>>> exp){
  Map<Integer,List<Integer>> expectedIds=exp.get(0);
  for (  Map.Entry<Integer,List<Integer>> e : expectedIds.entrySet()) {
    Map<Integer,List<Object>> messagesPerTask=new HashMap<>();
    Map<Integer,Integer> countsPerTask=new HashMap<>();
    for (    int i : e.getValue()) {
      messagesPerTask.put(i,new ArrayList<Object>());
      countsPerTask.put(i,0);
    }
    messages.put(e.getKey(),messagesPerTask);
    counts.put(e.getKey(),countsPerTask);
  }
  LOG.info(String.format("String_Node_Str",expectedIds));
}

Fixed version (ground truth):
@Override public void init(Config cfg,DataFlowOperation operation,Map<Integer,Map<Integer,List<Integer>>> exp){
  Map<Integer,List<Integer>> expectedIds=exp.get(0);
  for (  Map.Entry<Integer,List<Integer>> e : expectedIds.entrySet()) {
    Map<Integer,List<Object>> messagesPerTask=new HashMap<>();
    Map<Integer,Integer> countsPerTask=new HashMap<>();
    for (    int i : e.getValue()) {
      messagesPerTask.put(i,new ArrayList<Object>());
      countsPerTask.put(i,0);
    }
    messages.put(e.getKey(),messagesPerTask);
    counts.put(e.getKey(),countsPerTask);
  }
  LOG.info(String.format("String_Node_Str",expectedIds));
}
Program: 172938
Project: 172938
Buggy source:
public void prepare(Set<Integer> srcs,int dest,EdgeGenerator e,DataType dataType,String edgeName,Config config,TaskPlan taskPlan){
  LOG.info("String_Node_Str" + edgeName);
  this.edge=e;
  communicationEdge=e.generate(edgeName);
  op=new MPIDataFlowGather(channel,srcs,dest,new GatherReceiver(),0,0,config,MessageType.INTEGER,taskPlan,e.getIntegerMapping(edgeName));
  LOG.info("String_Node_Str" + e.getIntegerMapping(edgeName));
  op.init(config,Utils.dataTypeToMessageType(dataType),taskPlan,communicationEdge);
}

Fixed version (ground truth):
public void prepare(Set<Integer> srcs,int dest,EdgeGenerator e,DataType dataType,String edgeName,Config config,TaskPlan taskPlan){
  this.edge=e;
  op=new MPIDataFlowGather(channel,srcs,dest,new GatherReceiver(),0,0,config,MessageType.INTEGER,taskPlan,0);
  communicationEdge=e.generate(edgeName);
  op.init(config,Utils.dataTypeToMessageType(dataType),taskPlan,communicationEdge);
}
Program: 172939
Project: 172939
Buggy source:
@Override public boolean onMessage(int source,int destination,int target,int flags,Object object){
  TaskMessage msg=new TaskMessage(object,edge.getStringMapping(communicationEdge),target);
  LOG.info("String_Node_Str" + msg.getContent());
  return outMessages.get(target).offer(msg);
}

Fixed version (ground truth):
@Override public boolean onMessage(int source,int destination,int target,int flags,Object object){
  TaskMessage msg=new TaskMessage(object,edge.getStringMapping(communicationEdge),target);
  LOG.info("String_Node_Str" + object.getClass().getName());
  boolean status=outMessages.get(target).offer(msg);
  LOG.info("String_Node_Str" + status);
  return status;
}
Program: 172940
Project: 172940
Buggy source:
@Override public boolean receive(int target,Object object){
  count++;
  if (count > 5900 || count % 10 == 0) {
  }
  TaskMessage msg=new TaskMessage(object,edge.getStringMapping(communicationEdge),target);
  outMessages.get(target).offer(msg);
  return true;
}

Fixed version (ground truth):
@Override public boolean receive(int target,Object object){
  TaskMessage msg=new TaskMessage(object,edge.getStringMapping(communicationEdge),target);
  outMessages.get(target).offer(msg);
  return true;
}
Program: 172941
Project: 172941
Buggy source:
@Override public void init(Config cfg,DataFlowOperation operation,Map<Integer,Map<Integer,List<Integer>>> exp){
  Map<Integer,List<Integer>> expectedIds=exp.get(0);
  for (  Map.Entry<Integer,List<Integer>> e : expectedIds.entrySet()) {
    Map<Integer,List<Object>> messagesPerTask=new HashMap<>();
    Map<Integer,Integer> countsPerTask=new HashMap<>();
    for (    int i : e.getValue()) {
      messagesPerTask.put(i,new ArrayList<Object>());
      countsPerTask.put(i,0);
    }
    messages.put(e.getKey(),messagesPerTask);
    counts.put(e.getKey(),countsPerTask);
  }
  LOG.info(String.format("String_Node_Str",expectedIds));
}

Fixed version (ground truth):
@Override public void init(Config cfg,DataFlowOperation operation,Map<Integer,Map<Integer,List<Integer>>> exp){
  Map<Integer,List<Integer>> expectedIds=exp.get(8);
  for (  Map.Entry<Integer,List<Integer>> e : expectedIds.entrySet()) {
    Map<Integer,List<Object>> messagesPerTask=new HashMap<>();
    Map<Integer,Integer> countsPerTask=new HashMap<>();
    for (    int i : e.getValue()) {
      messagesPerTask.put(i,new ArrayList<Object>());
      countsPerTask.put(i,0);
    }
    messages.put(e.getKey(),messagesPerTask);
    counts.put(e.getKey(),countsPerTask);
  }
  LOG.info(String.format("String_Node_Str",expectedIds));
}
Program: 172942
Project: 172942
Buggy source:
@Override public void onFinish(int target){
}

Fixed version (ground truth):
@Override public void onFinish(int target){
  lock.lock();
  try {
    for (    Map.Entry<Integer,List<Object>> e : destinationMessages.entrySet()) {
      List<Object> messages=new ArrayList<>();
      Integer key=e.getKey();
      if (readyToSend.containsKey(key)) {
        messages=readyToSend.get(key);
      }
 else {
        readyToSend.put(key,messages);
      }
      messages.addAll(e.getValue());
    }
  }
  finally {
    lock.unlock();
  }
}
Program: 172943
Project: 172943
Buggy source:
/** 
 * Add the data to the file
 * @param data
 * @param length
 */
public void add(Object key,byte[] data,int length){
  if (status == FSStatus.READING) {
    throw new RuntimeException("String_Node_Str");
  }
  lock.lock();
  try {
    recordsInMemory.add(new KeyValue(key,data));
    bytesLength.add(length);
    numOfBytesInMemory+=length;
    if (numOfBytesInMemory > maxBytesToKeepInMemory || recordsInMemory.size() > maxRecordsInMemory) {
      notFull.signal();
    }
  }
  finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
/** 
 * Add the data to the file
 * @param data
 * @param length
 */
public void add(Object key,byte[] data,int length){
  if (status == FSStatus.READING) {
    throw new RuntimeException("String_Node_Str");
  }
  lock.lock();
  Object k1=FileLoader.convertKeyToArray(keyType,key);
  try {
    recordsInMemory.add(new KeyValue(k1,data));
    bytesLength.add(length);
    numOfBytesInMemory+=length;
    if (numOfBytesInMemory > maxBytesToKeepInMemory || recordsInMemory.size() > maxRecordsInMemory) {
      notFull.signal();
    }
  }
  finally {
    lock.unlock();
  }
}
Program: 172944
Project: 172944
Buggy source:
public void switchToReading(){
  status=FSStatus.READING;
  deserializeObjects();
}

Fixed version (ground truth):
public void switchToReading(){
  lock.lock();
  try {
    status=FSStatus.READING;
    deserializeObjects();
  }
  finally {
    lock.unlock();
  }
}