nus-yam/ex-repair huggingface dataset:
Program: 175702
Project: 175702
Buggy source:
public BrokerMessage.MessageContent read(long offset){
  lock.lock();
  try {
    Map.Entry<Long,Segment> entry=startOffsetSegmentMap.floorEntry(offset);
    if (entry == null) {
      LOG.warn("String_Node_Str",offset);
      return null;
    }
    Segment segment=entry.getValue();
    return segment.read(offset);
  }
  finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
public BrokerMessage.MessageContent read(long offset){
  lock.lock();
  try {
    if (startOffsetSegmentMap.size() > 0) {
      long firstOffset=startOffsetSegmentMap.firstKey();
      if (offset < firstOffset) {
        offset=firstOffset;
      }
    }
    Map.Entry<Long,Segment> entry=startOffsetSegmentMap.floorEntry(offset);
    if (entry == null) {
      LOG.warn("String_Node_Str",offset);
      return null;
    }
    Segment segment=entry.getValue();
    return segment.read(offset);
  }
  finally {
    lock.unlock();
  }
}
Program: 175703
Project: 175703
Buggy source:
private void readSegments(){
  try {
    List<String> fileNames=RaftFileUtils.getSortedFilesInDirectory(segmentDir,segmentDir);
    for (    String fileName : fileNames) {
      Segment segment=new Segment(segmentDir,fileName);
      startOffsetSegmentMap.put(segment.getStartOffset(),segment);
    }
  }
 catch (  IOException ex) {
    LOG.warn("String_Node_Str",ex);
    throw new RuntimeException("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
private void readSegments(){
  try {
    List<String> fileNames=RaftFileUtils.getSortedFilesInDirectory(segmentDir,segmentDir);
    for (    String fileName : fileNames) {
      LOG.info("String_Node_Str",fileName);
      Segment segment=new Segment(segmentDir,fileName);
      startOffsetSegmentMap.put(segment.getStartOffset(),segment);
    }
  }
 catch (  IOException ex) {
    LOG.warn("String_Node_Str",ex);
    throw new RuntimeException("String_Node_Str",ex);
  }
}
Program: 175705
Project: 175705
Buggy source:
@Test public void testClearExpiredLog(){
  Snapshot snapshot=Mockito.mock(Snapshot.class);
  Mockito.when(snapshot.getIsInstallSnapshot()).thenReturn(new AtomicBoolean(false));
  Mockito.when(snapshot.getIsTakeSnapshot()).thenReturn(new AtomicBoolean(false));
  RaftNode raftNode=Mockito.mock(RaftNode.class);
  Mockito.when(raftNode.getSnapshot()).thenReturn(snapshot);
  Mockito.doNothing().when(raftNode).takeSnapshot();
  BrokerStateMachine stateMachine=new BrokerStateMachine();
  stateMachine.setRaftNode(raftNode);
  GlobalConf conf=GlobalConf.getInstance();
  conf.setMaxSegmentSize(128);
  conf.setExpiredLogDuration(1);
  LogManager logManager=new LogManager(conf.getDataDir(),stateMachine);
  String topic="String_Node_Str";
  Integer queue=0;
  SegmentedLog log=logManager.getOrCreateQueueLog(topic,queue);
  for (int i=0; i < 1000; i++) {
    log.append(createMessage(topic,queue));
  }
  try {
    Thread.sleep(2000);
  }
 catch (  InterruptedException ex) {
    ex.printStackTrace();
  }
  System.out.println("String_Node_Str" + log.getStartOffsetSegmentMap().size());
  logManager.run();
  System.out.println("String_Node_Str" + log.getStartOffsetSegmentMap().size());
  Assert.assertTrue(log.getStartOffsetSegmentMap().size() == 1);
  File file=new File(conf.getDataDir());
  try {
    FileUtils.deleteDirectory(file);
  }
 catch (  IOException ex) {
    ex.printStackTrace();
  }
}

Fixed version (ground truth):
@Test public void testClearExpiredLog() throws IOException {
  GlobalConf conf=GlobalConf.getInstance();
  conf.setMaxSegmentSize(128);
  conf.setExpiredLogDuration(1);
  Snapshot snapshot=Mockito.mock(Snapshot.class);
  Mockito.when(snapshot.getIsInstallSnapshot()).thenReturn(new AtomicBoolean(false));
  Mockito.when(snapshot.getIsTakeSnapshot()).thenReturn(new AtomicBoolean(false));
  RaftNode raftNode=Mockito.mock(RaftNode.class);
  Mockito.when(raftNode.getSnapshot()).thenReturn(snapshot);
  Mockito.doNothing().when(raftNode).takeSnapshot();
  BrokerStateMachine stateMachine=new BrokerStateMachine(conf.getDataDir());
  stateMachine.setRaftNode(raftNode);
  LogManager logManager=new LogManager(conf.getDataDir(),stateMachine);
  String topic="String_Node_Str";
  Integer queue=0;
  SegmentedLog log=logManager.getOrCreateQueueLog(topic,queue);
  for (int i=0; i < 1000; i++) {
    log.append(createMessage(topic,queue));
  }
  try {
    Thread.sleep(2000);
  }
 catch (  InterruptedException ex) {
    ex.printStackTrace();
  }
  System.out.println("String_Node_Str" + log.getStartOffsetSegmentMap().size());
  logManager.run();
  System.out.println("String_Node_Str" + log.getStartOffsetSegmentMap().size());
  Assert.assertTrue(log.getStartOffsetSegmentMap().size() == 1);
  File file=new File(conf.getDataDir());
  try {
    FileUtils.deleteDirectory(file);
  }
 catch (  IOException ex) {
    ex.printStackTrace();
  }
}
Program: 175706
Project: 175706
Buggy source:
public Map<Integer,Integer> readTopicInfo(String topic){
  Map<Integer,Integer> queueMap=new HashMap<>();
  String topicPath=zkConf.getZKBasePath() + "String_Node_Str" + topic;
  try {
    List<String> queues=zkClient.getChildren().forPath(topicPath);
    for (    String queue : queues) {
      String queuePath=topicPath + "String_Node_Str" + queue;
      String queueData=new String(zkClient.getData().forPath(queuePath));
      Integer shardingId=Integer.valueOf(queueData);
      Integer queueId=Integer.valueOf(queue);
      queueMap.put(queueId,shardingId);
    }
  }
 catch (  Exception ex) {
    LOG.info("String_Node_Str",ex);
  }
  return queueMap;
}

Fixed version (ground truth):
public Map<Integer,Integer> readTopicInfo(String topic){
  Map<Integer,Integer> queueMap=new HashMap<>();
  String topicPath=zkConf.getZKBasePath() + "String_Node_Str" + topic;
  try {
    List<String> queues=zkClient.getChildren().forPath(topicPath);
    for (    String queue : queues) {
      String queuePath=topicPath + "String_Node_Str" + queue;
      String queueData=new String(zkClient.getData().forPath(queuePath));
      Integer shardingId=Integer.valueOf(queueData);
      Integer queueId=Integer.valueOf(queue);
      queueMap.put(queueId,shardingId);
    }
  }
 catch (  Exception ex) {
    LOG.warn("String_Node_Str",ex);
  }
  return queueMap;
}
Program: 175707
Project: 175707
Buggy source:
public BrokerAPIImpl(RaftNode raftNode,BrokerStateMachine stateMachine){
  this.raftNode=raftNode;
  this.stateMachine=stateMachine;
}

Fixed version (ground truth):
public BrokerAPIImpl(RaftNode raftNode,BrokerStateMachine stateMachine,ZKClient zkClient){
  this.raftNode=raftNode;
  this.stateMachine=stateMachine;
  this.zkClient=zkClient;
}
Program: 175709
Project: 175709
Buggy source:
public static void main(String[] args){
  GlobalConf conf=GlobalConf.getInstance();
  RaftMessage.Server localServer=conf.getLocalServer();
  List<RaftMessage.Server> servers=conf.getServers();
  String dataDir=conf.getDataDir();
  RPCServer server=new RPCServer(localServer.getEndPoint().getPort());
  BrokerStateMachine stateMachine=new BrokerStateMachine();
  RaftOptions.dataDir=dataDir;
  RaftNode raftNode=new RaftNode(servers,localServer,stateMachine);
  RaftConsensusService raftConsensusService=new RaftConsensusServiceImpl(raftNode);
  server.registerService(raftConsensusService);
  RaftClientService raftClientService=new RaftClientServiceImpl(raftNode);
  server.registerService(raftClientService);
  BrokerAPIImpl brokerAPI=new BrokerAPIImpl(raftNode,stateMachine);
  server.registerService(brokerAPI);
  server.start();
  raftNode.init();
  ZKConf zkConf=conf.getZkConf();
  ZKClient zkClient=new ZKClient(zkConf);
  zkClient.subscribeBroker();
  zkClient.subscribeTopic();
  while (ConfigurationUtils.containsServer(raftNode.getConfiguration(),conf.getLocalServer().getServerId())) {
    try {
      Thread.sleep(1000);
    }
 catch (    InterruptedException ex) {
      ex.printStackTrace();
    }
  }
  zkClient.registerBroker(conf.getShardingId(),conf.getLocalServer().getEndPoint().getHost(),conf.getLocalServer().getEndPoint().getPort());
}

Fixed version (ground truth):
public static void main(String[] args){
  GlobalConf conf=GlobalConf.getInstance();
  RaftMessage.Server localServer=conf.getLocalServer();
  List<RaftMessage.Server> servers=conf.getServers();
  String dataDir=conf.getDataDir();
  ZKConf zkConf=conf.getZkConf();
  ZKClient zkClient=new ZKClient(zkConf);
  RPCServer server=new RPCServer(localServer.getEndPoint().getPort());
  BrokerStateMachine stateMachine=new BrokerStateMachine();
  RaftOptions.dataDir=dataDir;
  RaftNode raftNode=new RaftNode(servers,localServer,stateMachine);
  RaftConsensusService raftConsensusService=new RaftConsensusServiceImpl(raftNode);
  server.registerService(raftConsensusService);
  RaftClientService raftClientService=new RaftClientServiceImpl(raftNode);
  server.registerService(raftClientService);
  BrokerAPIImpl brokerAPI=new BrokerAPIImpl(raftNode,stateMachine,zkClient);
  server.registerService(brokerAPI);
  server.start();
  raftNode.init();
  zkClient.subscribeBroker();
  zkClient.subscribeTopic();
  while (!ConfigurationUtils.containsServer(raftNode.getConfiguration(),conf.getLocalServer().getServerId())) {
    try {
      Thread.sleep(1000);
    }
 catch (    InterruptedException ex) {
      ex.printStackTrace();
    }
  }
  zkClient.registerBroker(conf.getShardingId(),conf.getLocalServer().getEndPoint().getHost(),conf.getLocalServer().getEndPoint().getPort());
}
Program: 175710
Project: 175710
Buggy source:
private ZKConf readZKConf(){
  zkConf=new ZKConf();
  zkConf.setServers(toml.getString("String_Node_Str"));
  zkConf.setConnectTimeoutMs(toml.getLong("String_Node_Str").intValue());
  zkConf.setSessionTimeoutMs(toml.getLong("String_Node_Str").intValue());
  zkConf.setRetryCount(toml.getLong("String_Node_Str").intValue());
  zkConf.setRetryIntervalMs(toml.getLong("String_Node_Str").intValue());
  zkConf.setBasePath(toml.getString("String_Node_Str"));
  return zkConf;
}

Fixed version (ground truth):
private ZKConf readZKConf(){
  Toml zookeeperToml=toml.getTable("String_Node_Str");
  zkConf=new ZKConf();
  zkConf.setServers(zookeeperToml.getString("String_Node_Str"));
  zkConf.setConnectTimeoutMs(zookeeperToml.getLong("String_Node_Str").intValue());
  zkConf.setSessionTimeoutMs(zookeeperToml.getLong("String_Node_Str").intValue());
  zkConf.setRetryCount(zookeeperToml.getLong("String_Node_Str").intValue());
  zkConf.setRetryIntervalMs(zookeeperToml.getLong("String_Node_Str").intValue());
  zkConf.setBasePath(zookeeperToml.getString("String_Node_Str"));
  return zkConf;
}
Program: 175711
Project: 175711
Buggy source:
public byte[] read(long offset){
  if (offset >= startOffset + fileSize) {
    LOG.warn("String_Node_Str",offset);
    return null;
  }
  try {
    channel.position(offset - startOffset);
    ByteBuffer headerBuffer=ByteBuffer.allocate(MESSAGE_HEADER_LENGTH);
    int readLen=channel.read(headerBuffer);
    if (readLen < MESSAGE_HEADER_LENGTH) {
      LOG.warn("String_Node_Str");
      return null;
    }
    long crc32=headerBuffer.getLong();
    int messageLen=headerBuffer.getInt();
    ByteBuffer messageContentBuffer=ByteBuffer.allocate(messageLen);
    readLen=channel.read(messageContentBuffer);
    if (readLen < messageLen) {
      LOG.warn("String_Node_Str");
      return null;
    }
    if (BrokerUtils.getCRC32(messageContentBuffer.array()) != crc32) {
      LOG.warn("String_Node_Str");
      return null;
    }
    return messageContentBuffer.array();
  }
 catch (  IOException ex) {
    LOG.warn("String_Node_Str",dirName,fileName,offset);
    return null;
  }
}

Fixed version (ground truth):
public byte[] read(long offset){
  if (offset >= startOffset + fileSize) {
    LOG.warn("String_Node_Str",offset);
    return null;
  }
  try {
    channel.position(offset - startOffset);
    ByteBuffer headerBuffer=ByteBuffer.allocate(MESSAGE_HEADER_LENGTH);
    int readLen=channel.read(headerBuffer);
    if (readLen < MESSAGE_HEADER_LENGTH) {
      LOG.warn("String_Node_Str");
      return null;
    }
    headerBuffer.flip();
    long crc32=headerBuffer.getLong();
    int messageLen=headerBuffer.getInt();
    ByteBuffer messageContentBuffer=ByteBuffer.allocate(messageLen);
    readLen=channel.read(messageContentBuffer);
    if (readLen != messageLen) {
      LOG.warn("String_Node_Str");
      return null;
    }
    if (BrokerUtils.getCRC32(messageContentBuffer.array()) != crc32) {
      LOG.warn("String_Node_Str");
      return null;
    }
    return messageContentBuffer.array();
  }
 catch (  IOException ex) {
    LOG.warn("String_Node_Str",dirName,fileName,offset);
    return null;
  }
}
Program: 175712
Project: 175712
Buggy source:
public long append(byte[] messageContent){
  long offset=0;
  try {
    int writeSize;
    ByteBuffer byteBuffer=ByteBuffer.allocate(Segment.SEGMENT_HEADER_LENGTH + Segment.MESSAGE_HEADER_LENGTH + +messageContent.length);
    if (fileSize == 0) {
      byteBuffer.putLong(System.currentTimeMillis());
      byteBuffer.putLong(BrokerUtils.getCRC32(messageContent));
      byteBuffer.putInt(messageContent.length);
      byteBuffer.put(messageContent);
      writeSize=channel.write(byteBuffer);
      offset=startOffset;
      endOffset=startOffset + writeSize;
    }
 else {
      byteBuffer.putLong(BrokerUtils.getCRC32(messageContent));
      byteBuffer.putInt(messageContent.length);
      byteBuffer.put(messageContent);
      writeSize=channel.write(byteBuffer);
      offset=endOffset;
      endOffset+=writeSize;
    }
    fileSize+=writeSize;
  }
 catch (  IOException ex) {
    LOG.warn("String_Node_Str",ex);
  }
  return offset;
}

Fixed version (ground truth):
public long append(byte[] messageContent){
  long offset=0;
  try {
    int writeSize;
    ByteBuffer byteBuffer=ByteBuffer.allocate(Segment.SEGMENT_HEADER_LENGTH + Segment.MESSAGE_HEADER_LENGTH + +messageContent.length);
    if (fileSize == 0) {
      byteBuffer.putLong(System.currentTimeMillis());
      byteBuffer.putLong(BrokerUtils.getCRC32(messageContent));
      byteBuffer.putInt(messageContent.length);
      byteBuffer.put(messageContent);
      byteBuffer.flip();
      writeSize=channel.write(byteBuffer);
      channel.force(true);
      offset=startOffset;
      endOffset=startOffset + writeSize;
    }
 else {
      byteBuffer.putLong(BrokerUtils.getCRC32(messageContent));
      byteBuffer.putInt(messageContent.length);
      byteBuffer.put(messageContent);
      byteBuffer.flip();
      channel.position(endOffset);
      writeSize=channel.write(byteBuffer);
      channel.force(true);
      offset=endOffset;
      endOffset+=writeSize;
    }
    fileSize+=writeSize;
  }
 catch (  IOException ex) {
    LOG.warn("String_Node_Str",ex);
  }
  return offset;
}
Program: 175715
Project: 175715
Buggy source:
public BrokerMessage.PullMessageResponse pullMessage(BrokerMessage.PullMessageRequest request){
  BrokerMessage.PullMessageResponse.Builder responseBuilder=BrokerMessage.PullMessageResponse.newBuilder();
  SegmentedLog segmentedLog=logManager.getOrCreateQueueLog(request.getTopic(),request.getQueue());
  int readCount=0;
  long offset=request.getOffset();
  if (offset == 0) {
    offset=Segment.SEGMENT_HEADER_LENGTH;
  }
  while (readCount < request.getMessageCount()) {
    byte[] messageBytes=segmentedLog.read(offset);
    if (messageBytes == null) {
      break;
    }
    BrokerMessage.MessageContent message=BrokerMessage.MessageContent.newBuilder().setTopic(request.getTopic()).setQueue(request.getQueue()).setOffset(offset).setContent(ByteString.copyFrom(messageBytes)).build();
    responseBuilder.addContents(message);
    offset+=messageBytes.length + Segment.MESSAGE_HEADER_LENGTH;
  }
  return responseBuilder.build();
}

Fixed version (ground truth):
public BrokerMessage.PullMessageResponse pullMessage(BrokerMessage.PullMessageRequest request){
  BrokerMessage.PullMessageResponse.Builder responseBuilder=BrokerMessage.PullMessageResponse.newBuilder();
  SegmentedLog segmentedLog=logManager.getOrCreateQueueLog(request.getTopic(),request.getQueue());
  int readCount=0;
  long offset=request.getOffset();
  while (readCount < request.getMessageCount()) {
    BrokerMessage.MessageContent message=segmentedLog.read(offset);
    if (message == null) {
      break;
    }
    responseBuilder.addContents(message);
    offset=message.getOffset() + message.getSize();
    readCount++;
  }
  return responseBuilder.build();
}
Program: 175716
Project: 175716
Buggy source:
@Override public void apply(byte[] dataBytes){
  try {
    BrokerMessage.SendMessageRequest request=BrokerMessage.SendMessageRequest.parseFrom(dataBytes);
    SegmentedLog segmentedLog=logManager.getOrCreateQueueLog(request.getTopic(),request.getQueue());
    segmentedLog.append(request.getContent().toByteArray());
  }
 catch (  Exception ex) {
    LOG.warn("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
@Override public void apply(byte[] dataBytes){
  try {
    BrokerMessage.SendMessageRequest request=BrokerMessage.SendMessageRequest.parseFrom(dataBytes);
    BrokerMessage.MessageContent.Builder message=BrokerMessage.MessageContent.newBuilder().setTopic(request.getTopic()).setQueue(request.getQueue()).setContent(request.getContent());
    SegmentedLog segmentedLog=logManager.getOrCreateQueueLog(request.getTopic(),request.getQueue());
    segmentedLog.append(message);
  }
 catch (  Exception ex) {
    LOG.warn("String_Node_Str",ex);
  }
}
Program: 175717
Project: 175717
Buggy source:
public byte[] read(long offset){
  if (offset >= startOffset + fileSize) {
    LOG.warn("String_Node_Str",offset);
    return null;
  }
  try {
    channel.position(offset - startOffset);
    ByteBuffer headerBuffer=ByteBuffer.allocate(MESSAGE_HEADER_LENGTH);
    int readLen=channel.read(headerBuffer);
    if (readLen < MESSAGE_HEADER_LENGTH) {
      LOG.warn("String_Node_Str");
      return null;
    }
    headerBuffer.flip();
    long crc32=headerBuffer.getLong();
    int messageLen=headerBuffer.getInt();
    ByteBuffer messageContentBuffer=ByteBuffer.allocate(messageLen);
    readLen=channel.read(messageContentBuffer);
    if (readLen != messageLen) {
      LOG.warn("String_Node_Str");
      return null;
    }
    if (BrokerUtils.getCRC32(messageContentBuffer.array()) != crc32) {
      LOG.warn("String_Node_Str");
      return null;
    }
    return messageContentBuffer.array();
  }
 catch (  IOException ex) {
    LOG.warn("String_Node_Str",dirName,fileName,offset);
    return null;
  }
}

Fixed version (ground truth):
public BrokerMessage.MessageContent read(long offset){
  if (offset >= startOffset + fileSize) {
    LOG.warn("String_Node_Str",offset);
    return null;
  }
  try {
    channel.position(offset - startOffset);
    ByteBuffer headerBuffer=ByteBuffer.allocate(MESSAGE_HEADER_LENGTH);
    int readLen=channel.read(headerBuffer);
    if (readLen != MESSAGE_HEADER_LENGTH) {
      LOG.warn("String_Node_Str");
      return null;
    }
    headerBuffer.flip();
    long crc32=headerBuffer.getLong();
    int messageLen=headerBuffer.getInt();
    LOG.info("String_Node_Str",messageLen);
    ByteBuffer messageContentBuffer=ByteBuffer.allocate(messageLen);
    readLen=channel.read(messageContentBuffer);
    if (readLen != messageLen) {
      LOG.warn("String_Node_Str");
      return null;
    }
    if (BrokerUtils.getCRC32(messageContentBuffer.array()) != crc32) {
      LOG.warn("String_Node_Str");
      return null;
    }
    BrokerMessage.MessageContent message=BrokerMessage.MessageContent.parseFrom(messageContentBuffer.array());
    BrokerMessage.MessageContent result=BrokerMessage.MessageContent.newBuilder().mergeFrom(message).setSize(MESSAGE_HEADER_LENGTH + messageLen).build();
    return result;
  }
 catch (  IOException ex) {
    LOG.warn("String_Node_Str",dirName,fileName,offset);
    return null;
  }
}
Program: 175718
Project: 175718
Buggy source:
public long append(byte[] messageContent){
  long offset=0;
  try {
    int writeSize;
    ByteBuffer byteBuffer=ByteBuffer.allocate(Segment.SEGMENT_HEADER_LENGTH + Segment.MESSAGE_HEADER_LENGTH + +messageContent.length);
    if (fileSize == 0) {
      byteBuffer.putLong(System.currentTimeMillis());
      byteBuffer.putLong(BrokerUtils.getCRC32(messageContent));
      byteBuffer.putInt(messageContent.length);
      byteBuffer.put(messageContent);
      byteBuffer.flip();
      writeSize=channel.write(byteBuffer);
      channel.force(true);
      offset=startOffset;
      endOffset=startOffset + writeSize;
    }
 else {
      byteBuffer.putLong(BrokerUtils.getCRC32(messageContent));
      byteBuffer.putInt(messageContent.length);
      byteBuffer.put(messageContent);
      byteBuffer.flip();
      channel.position(endOffset);
      writeSize=channel.write(byteBuffer);
      channel.force(true);
      offset=endOffset;
      endOffset+=writeSize;
    }
    fileSize+=writeSize;
  }
 catch (  IOException ex) {
    LOG.warn("String_Node_Str",ex);
  }
  return offset;
}

Fixed version (ground truth):
public boolean append(BrokerMessage.MessageContent.Builder messageBuilder){
  try {
    if (fileSize == 0) {
      messageBuilder.setOffset(startOffset);
    }
 else {
      messageBuilder.setOffset(endOffset);
    }
    messageBuilder.setCreateTime(System.currentTimeMillis());
    BrokerMessage.MessageContent message=messageBuilder.build();
    byte[] messageBytes=message.toByteArray();
    int totalSize=Segment.MESSAGE_HEADER_LENGTH + messageBytes.length;
    ByteBuffer byteBuffer=ByteBuffer.allocate(totalSize);
    byteBuffer.putLong(BrokerUtils.getCRC32(messageBytes));
    byteBuffer.putInt(messageBytes.length);
    byteBuffer.put(messageBytes);
    byteBuffer.flip();
    int writeSize=channel.write(byteBuffer);
    channel.force(true);
    if (writeSize != totalSize) {
      LOG.warn("String_Node_Str");
      return false;
    }
    if (fileSize == 0) {
      endOffset=startOffset + writeSize;
    }
 else {
      endOffset+=writeSize;
    }
    fileSize+=writeSize;
  }
 catch (  IOException ex) {
    LOG.warn("String_Node_Str",ex);
    return false;
  }
  return true;
}
Program: 175719
Project: 175719
Buggy source:
public byte[] read(long offset){
  Map.Entry<Long,Segment> entry=startOffsetSegmentMap.floorEntry(offset);
  if (entry == null) {
    LOG.warn("String_Node_Str",offset);
    return null;
  }
  Segment segment=entry.getValue();
  return segment.read(offset);
}

Fixed version (ground truth):
public BrokerMessage.MessageContent read(long offset){
  Map.Entry<Long,Segment> entry=startOffsetSegmentMap.floorEntry(offset);
  if (entry == null) {
    LOG.warn("String_Node_Str",offset);
    return null;
  }
  Segment segment=entry.getValue();
  return segment.read(offset);
}
Program: 175720
Project: 175720
Buggy source:
private void validateSegments(){
  long lastEndOffset=0;
  for (  Segment segment : startOffsetSegmentMap.values()) {
    if (lastEndOffset > 0 && segment.getStartOffset() != lastEndOffset + Segment.SEGMENT_HEADER_LENGTH) {
      throw new RuntimeException("String_Node_Str" + segmentDir);
    }
    lastEndOffset=segment.getEndOffset();
  }
}

Fixed version (ground truth):
private void validateSegments(){
  long lastEndOffset=0;
  for (  Segment segment : startOffsetSegmentMap.values()) {
    if (lastEndOffset > 0 && segment.getStartOffset() != lastEndOffset) {
      throw new RuntimeException("String_Node_Str" + segmentDir);
    }
    lastEndOffset=segment.getEndOffset();
  }
}
Program: 175723
Project: 175723
Buggy source:
public void setDefaultCameraParameters(Camera camera,Camera.CameraInfo cameraInfo){
  Camera.Parameters parameters=camera.getParameters();
  parameters.setPictureFormat(ImageFormat.JPEG);
  List<Camera.Size> supportedSizes=parameters.getSupportedPictureSizes();
  Camera.Size pictureSize=getBestSize(supportedSizes,0);
  parameters.setPictureSize(pictureSize.width,pictureSize.height);
  float whRatio=(float)pictureSize.width / pictureSize.height;
  List<Camera.Size> previewSupportedSizes=parameters.getSupportedPreviewSizes();
  Camera.Size previewSize=getBestSize(previewSupportedSizes,whRatio);
  parameters.setPreviewSize(previewSize.width,previewSize.height);
  parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
  if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
    parameters.setFlashMode(Camera.Parameters.FLASH_MODE_AUTO);
  }
  parameters.setColorEffect(Camera.Parameters.EFFECT_NONE);
  parameters.setSceneMode(Camera.Parameters.SCENE_MODE_AUTO);
  int orientation=cameraInfo.orientation;
  parameters.setRotation(orientation);
  camera.setParameters(parameters);
}

Fixed version (ground truth):
public void setDefaultCameraParameters(Camera camera,Camera.CameraInfo cameraInfo){
  Camera.Parameters parameters=camera.getParameters();
  parameters.setPictureFormat(ImageFormat.JPEG);
  List<Camera.Size> supportedSizes=parameters.getSupportedPictureSizes();
  Camera.Size pictureSize=getBestSize(supportedSizes,0);
  parameters.setPictureSize(pictureSize.width,pictureSize.height);
  float whRatio=(float)pictureSize.width / pictureSize.height;
  List<Camera.Size> previewSupportedSizes=parameters.getSupportedPreviewSizes();
  Camera.Size previewSize=getBestSize(previewSupportedSizes,whRatio);
  parameters.setPreviewSize(previewSize.width,previewSize.height);
  List<String> supportedFocusModes=camera.getParameters().getSupportedFocusModes();
  boolean hasAutoFocus=supportedFocusModes != null && supportedFocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO);
  if (hasAutoFocus) {
    parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
  }
  if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
    parameters.setFlashMode(Camera.Parameters.FLASH_MODE_AUTO);
  }
  List<String> supportedScreenModes=camera.getParameters().getSupportedSceneModes();
  boolean hasAutoScene=supportedScreenModes != null && supportedFocusModes.contains(Camera.Parameters.SCENE_MODE_AUTO);
  if (hasAutoScene) {
    parameters.setSceneMode(Camera.Parameters.SCENE_MODE_AUTO);
  }
  parameters.setColorEffect(Camera.Parameters.EFFECT_NONE);
  int orientation=cameraInfo.orientation;
  parameters.setRotation(orientation);
  camera.setParameters(parameters);
}
Program: 175724
Project: 175724
Buggy source:
@Override public void onPictureTaken(byte[] data,Camera camera){
  FileOutputStream fos=null;
  try {
    File outputFile=ImageFileUtils.getImageOutputFile();
    Log.d(TAG,outputFile.getAbsolutePath());
    fos=new FileOutputStream(outputFile);
    fos.write(data);
    ImageFileUtils.addToGalleryAndNotify(getReactApplicationContext(),outputFile,promise);
  }
 catch (  IOException e) {
    e.printStackTrace();
    promise.reject(e);
  }
 finally {
    try {
      fos.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
@Override public void onPictureTaken(byte[] data,Camera camera){
  FileOutputStream fos=null;
  try {
    File outputFile=ImageFileUtils.getImageOutputFile();
    Log.d(TAG,outputFile.getAbsolutePath());
    fos=new FileOutputStream(outputFile);
    fos.write(data);
    ImageFileUtils.addToGalleryAndNotify(getReactApplicationContext(),outputFile,promise);
  }
 catch (  IOException e) {
    e.printStackTrace();
    promise.reject(e);
  }
 finally {
    try {
      fos.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
    camera.startPreview();
  }
}
Program: 175725
Project: 175725
Buggy source:
private void takePicture(Camera camera,final Promise promise){
  if (camera == null) {
    promise.reject("String_Node_Str");
  }
  camera.takePicture(null,null,new Camera.PictureCallback(){
    @Override public void onPictureTaken(    byte[] data,    Camera camera){
      FileOutputStream fos=null;
      try {
        File outputFile=ImageFileUtils.getImageOutputFile();
        Log.d(TAG,outputFile.getAbsolutePath());
        fos=new FileOutputStream(outputFile);
        fos.write(data);
        ImageFileUtils.addToGalleryAndNotify(getReactApplicationContext(),outputFile,promise);
      }
 catch (      IOException e) {
        e.printStackTrace();
        promise.reject(e);
      }
 finally {
        try {
          fos.close();
        }
 catch (        IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
);
}

Fixed version (ground truth):
private void takePicture(Camera camera,final Promise promise){
  if (camera == null) {
    promise.reject("String_Node_Str");
  }
  camera.takePicture(null,null,new Camera.PictureCallback(){
    @Override public void onPictureTaken(    byte[] data,    Camera camera){
      FileOutputStream fos=null;
      try {
        File outputFile=ImageFileUtils.getImageOutputFile();
        Log.d(TAG,outputFile.getAbsolutePath());
        fos=new FileOutputStream(outputFile);
        fos.write(data);
        ImageFileUtils.addToGalleryAndNotify(getReactApplicationContext(),outputFile,promise);
      }
 catch (      IOException e) {
        e.printStackTrace();
        promise.reject(e);
      }
 finally {
        try {
          fos.close();
        }
 catch (        IOException e) {
          e.printStackTrace();
        }
        camera.startPreview();
      }
    }
  }
);
}
Program: 175726
Project: 175726
Buggy source:
@Override public void onRender(float partialTicks){
  GL11.glEnable(GL11.GL_BLEND);
  GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
  GL11.glEnable(GL11.GL_LINE_SMOOTH);
  GL11.glLineWidth(2);
  GL11.glDisable(GL11.GL_TEXTURE_2D);
  GL11.glEnable(GL11.GL_CULL_FACE);
  GL11.glDisable(GL11.GL_DEPTH_TEST);
  GL11.glPushMatrix();
  GL11.glTranslated(-mc.getRenderManager().renderPosX,-mc.getRenderManager().renderPosY,-mc.getRenderManager().renderPosZ);
  float alpha=0.5F + 0.25F * WMath.sin(System.currentTimeMillis() % 1000 / 500F * (float)Math.PI);
  GL11.glColor4f(1,0,0,alpha);
  for (  Entity entity : WMinecraft.getWorld().loadedEntityList) {
    if (!(entity instanceof EntityLiving))     continue;
    if (!entity.isInvisible())     continue;
    if (WMinecraft.getPlayer().getDistanceSqToEntity(entity) < 0.25)     continue;
    GL11.glPushMatrix();
    GL11.glTranslated(entity.posX,entity.posY,entity.posZ);
    RenderUtils.drawOutlinedBox(FAKE_BLOCK_BOX);
    RenderUtils.drawSolidBox(FAKE_BLOCK_BOX);
    GL11.glPopMatrix();
  }
  GL11.glPopMatrix();
  GL11.glEnable(GL11.GL_DEPTH_TEST);
  GL11.glEnable(GL11.GL_TEXTURE_2D);
  GL11.glDisable(GL11.GL_BLEND);
  GL11.glDisable(GL11.GL_LINE_SMOOTH);
}

Fixed version (ground truth):
@Override public void onRender(float partialTicks){
  GL11.glEnable(GL11.GL_BLEND);
  GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
  GL11.glEnable(GL11.GL_LINE_SMOOTH);
  GL11.glLineWidth(2);
  GL11.glDisable(GL11.GL_TEXTURE_2D);
  GL11.glEnable(GL11.GL_CULL_FACE);
  GL11.glDisable(GL11.GL_DEPTH_TEST);
  GL11.glPushMatrix();
  GL11.glTranslated(-mc.getRenderManager().renderPosX,-mc.getRenderManager().renderPosY,-mc.getRenderManager().renderPosZ);
  float alpha=0.5F + 0.25F * WMath.sin(System.currentTimeMillis() % 1000 / 500F * (float)Math.PI);
  GL11.glColor4f(1,0,0,alpha);
  for (  Entity entity : WMinecraft.getWorld().loadedEntityList) {
    if (!(entity instanceof EntityLiving))     continue;
    if (!entity.isInvisible())     continue;
    if (WMinecraft.getPlayer().getDistanceSqToEntity(entity) < 0.25)     continue;
    GL11.glPushMatrix();
    GL11.glTranslated(entity.posX,entity.posY,entity.posZ);
    RenderUtils.drawOutlinedBox(FAKE_BLOCK_BOX);
    RenderUtils.drawSolidBox(FAKE_BLOCK_BOX);
    GL11.glPopMatrix();
  }
  GL11.glPopMatrix();
  GL11.glColor4f(1,1,1,1);
  GL11.glEnable(GL11.GL_DEPTH_TEST);
  GL11.glEnable(GL11.GL_TEXTURE_2D);
  GL11.glDisable(GL11.GL_BLEND);
  GL11.glDisable(GL11.GL_LINE_SMOOTH);
}
Program: 175727
Project: 175727
Buggy source:
@Override public void onRender(float partialTicks){
  GL11.glEnable(GL11.GL_BLEND);
  GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
  GL11.glEnable(GL11.GL_LINE_SMOOTH);
  GL11.glLineWidth(2);
  GL11.glDisable(GL11.GL_TEXTURE_2D);
  GL11.glEnable(GL11.GL_CULL_FACE);
  GL11.glDisable(GL11.GL_DEPTH_TEST);
  GL11.glDisable(GL11.GL_LIGHTING);
  GL11.glPushMatrix();
  GL11.glTranslated(-mc.getRenderManager().renderPosX,-mc.getRenderManager().renderPosY,-mc.getRenderManager().renderPosZ);
  ArrayList<AxisAlignedBB> minecartBoxes=new ArrayList<>(minecarts.size());
  minecarts.forEach(e -> {
    double offsetX=-(e.posX - e.lastTickPosX) + (e.posX - e.lastTickPosX) * partialTicks;
    double offsetY=-(e.posY - e.lastTickPosY) + (e.posY - e.lastTickPosY) * partialTicks;
    double offsetZ=-(e.posZ - e.lastTickPosZ) + (e.posZ - e.lastTickPosZ) * partialTicks;
    minecartBoxes.add(e.boundingBox.offset(offsetX,offsetY,offsetZ));
  }
);
  GL11.glCallList(normalChests);
  GL11.glColor4f(0,1,0,0.25F);
  renderBoxes(minecartBoxes,solidBox);
  GL11.glColor4f(0,1,0,0.5F);
  renderBoxes(minecartBoxes,outlinedBox);
  GL11.glPopMatrix();
  GL11.glColor4f(1,1,1,1);
  GL11.glEnable(GL11.GL_DEPTH_TEST);
  GL11.glEnable(GL11.GL_TEXTURE_2D);
  GL11.glDisable(GL11.GL_BLEND);
  GL11.glDisable(GL11.GL_LINE_SMOOTH);
  GL11.glEnable(GL11.GL_LIGHTING);
}

Fixed version (ground truth):
@Override public void onRender(float partialTicks){
  GL11.glEnable(GL11.GL_BLEND);
  GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
  GL11.glEnable(GL11.GL_LINE_SMOOTH);
  GL11.glLineWidth(2);
  GL11.glDisable(GL11.GL_TEXTURE_2D);
  GL11.glEnable(GL11.GL_CULL_FACE);
  GL11.glDisable(GL11.GL_DEPTH_TEST);
  GL11.glPushMatrix();
  GL11.glTranslated(-mc.getRenderManager().renderPosX,-mc.getRenderManager().renderPosY,-mc.getRenderManager().renderPosZ);
  ArrayList<AxisAlignedBB> minecartBoxes=new ArrayList<>(minecarts.size());
  minecarts.forEach(e -> {
    double offsetX=-(e.posX - e.lastTickPosX) + (e.posX - e.lastTickPosX) * partialTicks;
    double offsetY=-(e.posY - e.lastTickPosY) + (e.posY - e.lastTickPosY) * partialTicks;
    double offsetZ=-(e.posZ - e.lastTickPosZ) + (e.posZ - e.lastTickPosZ) * partialTicks;
    minecartBoxes.add(e.boundingBox.offset(offsetX,offsetY,offsetZ));
  }
);
  GL11.glCallList(normalChests);
  GL11.glColor4f(0,1,0,0.25F);
  renderBoxes(minecartBoxes,solidBox);
  GL11.glColor4f(0,1,0,0.5F);
  renderBoxes(minecartBoxes,outlinedBox);
  GL11.glPopMatrix();
  GL11.glColor4f(1,1,1,1);
  GL11.glEnable(GL11.GL_DEPTH_TEST);
  GL11.glEnable(GL11.GL_TEXTURE_2D);
  GL11.glDisable(GL11.GL_BLEND);
  GL11.glDisable(GL11.GL_LINE_SMOOTH);
}
Program: 175728
Project: 175728
Buggy source:
@Override public void onRender(float partialTicks){
  GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
  GL11.glEnable(GL11.GL_LINE_SMOOTH);
  GL11.glLineWidth(2);
  for (  EntityItem e : items) {
    float x=(float)(e.prevPosX + (e.posX - e.prevPosX) * partialTicks - mc.getRenderManager().renderPosX);
    float y=(float)(e.prevPosY + (e.posY - e.prevPosY) * partialTicks - mc.getRenderManager().renderPosY);
    float z=(float)(e.prevPosZ + (e.posZ - e.prevPosZ) * partialTicks - mc.getRenderManager().renderPosZ);
    GL11.glPushMatrix();
    GL11.glTranslatef(x,y,z);
    GL11.glCallList(itemBox);
    GL11.glPopMatrix();
    if (names != null && names.isChecked()) {
      ItemStack stack=e.getEntityItem();
      WEntityRenderer.drawNameplate(mc.fontRendererObj,WItem.getStackSize(stack) + "String_Node_Str" + stack.getDisplayName(),x,y + 1,z,0,mc.getRenderManager().playerViewY,mc.getRenderManager().playerViewX,mc.gameSettings.thirdPersonView == 2,false);
    }
  }
  GL11.glColor4f(1,1,1,1);
  GL11.glEnable(GL11.GL_DEPTH_TEST);
  GL11.glEnable(GL11.GL_TEXTURE_2D);
  GL11.glDisable(GL11.GL_BLEND);
  GL11.glDisable(GL11.GL_LINE_SMOOTH);
}

Fixed version (ground truth):
@Override public void onRender(float partialTicks){
  GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
  GL11.glEnable(GL11.GL_LINE_SMOOTH);
  GL11.glLineWidth(2);
  for (  EntityItem e : items) {
    float x=(float)(e.prevPosX + (e.posX - e.prevPosX) * partialTicks - mc.getRenderManager().renderPosX);
    float y=(float)(e.prevPosY + (e.posY - e.prevPosY) * partialTicks - mc.getRenderManager().renderPosY);
    float z=(float)(e.prevPosZ + (e.posZ - e.prevPosZ) * partialTicks - mc.getRenderManager().renderPosZ);
    GL11.glPushMatrix();
    GL11.glTranslatef(x,y,z);
    GL11.glCallList(itemBox);
    GL11.glPopMatrix();
    if (names != null && names.isChecked()) {
      ItemStack stack=e.getEntityItem();
      WEntityRenderer.drawNameplate(mc.fontRendererObj,WItem.getStackSize(stack) + "String_Node_Str" + stack.getDisplayName(),x,y + 1,z,0,mc.getRenderManager().playerViewY,mc.getRenderManager().playerViewX,mc.gameSettings.thirdPersonView == 2,false);
      GL11.glDisable(GL11.GL_LIGHTING);
    }
  }
  GL11.glColor4f(1,1,1,1);
  GL11.glEnable(GL11.GL_DEPTH_TEST);
  GL11.glEnable(GL11.GL_TEXTURE_2D);
  GL11.glDisable(GL11.GL_BLEND);
  GL11.glDisable(GL11.GL_LINE_SMOOTH);
}
Program: 175729
Project: 175729
Buggy source:
@SuppressWarnings("String_Node_Str") public <T extends Event>void fire(T event){
  if (!WurstClient.INSTANCE.isEnabled())   return;
  try {
    event.fire(listenerMap.get(event.getListenerType()));
  }
 catch (  Throwable e) {
    e.printStackTrace();
    CrashReport report=CrashReport.makeCrashReport(e,"String_Node_Str");
    CrashReportCategory category=report.makeCategory("String_Node_Str");
    category.setDetail("String_Node_Str",() -> event.getClass().getName());
    throw new ReportedException(report);
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public <T extends Event>void fire(T event){
  if (!WurstClient.INSTANCE.isEnabled())   return;
  try {
    ArrayList<? extends Listener> listeners=listenerMap.get(event.getListenerType());
    event.fire(new ArrayList<>(listeners));
  }
 catch (  Throwable e) {
    e.printStackTrace();
    CrashReport report=CrashReport.makeCrashReport(e,"String_Node_Str");
    CrashReportCategory category=report.makeCategory("String_Node_Str");
    category.setDetail("String_Node_Str",() -> event.getClass().getName());
    throw new ReportedException(report);
  }
}
Program: 175730
Project: 175730
Buggy source:
@Override public void fire(ArrayList<ChatInputListener> listeners){
  for (int i=0; i < listeners.size(); i++) {
    listeners.get(i).onReceivedMessage(this);
    if (isCancelled())     break;
  }
}

Fixed version (ground truth):
@Override public void fire(ArrayList<ChatInputListener> listeners){
  for (  ChatInputListener listener : listeners) {
    listener.onReceivedMessage(this);
    if (isCancelled())     break;
  }
}
Program: 175731
Project: 175731
Buggy source:
@Override public void fire(ArrayList<ChatOutputListener> listeners){
  for (int i=0; i < listeners.size(); i++) {
    listeners.get(i).onSentMessage(this);
    if (isCancelled())     break;
  }
}

Fixed version (ground truth):
@Override public void fire(ArrayList<ChatOutputListener> listeners){
  for (  ChatOutputListener listener : listeners) {
    listener.onSentMessage(this);
    if (isCancelled())     break;
  }
}
Program: 175732
Project: 175732
Buggy source:
@Override public void fire(ArrayList<DeathListener> listeners){
  for (int i=0; i < listeners.size(); i++)   listeners.get(i).onDeath();
}

Fixed version (ground truth):
@Override public void fire(ArrayList<DeathListener> listeners){
  for (  DeathListener listener : listeners)   listener.onDeath();
}
Program: 175733
Project: 175733
Buggy source:
@Override public void fire(ArrayList<GUIRenderListener> listeners){
  for (int i=0; i < listeners.size(); i++)   listeners.get(i).onRenderGUI();
}

Fixed version (ground truth):
@Override public void fire(ArrayList<GUIRenderListener> listeners){
  for (  GUIRenderListener listener : listeners)   listener.onRenderGUI();
}
Program: 175734
Project: 175734
Buggy source:
@Override public void fire(ArrayList<LeftClickListener> listeners){
  for (int i=0; i < listeners.size(); i++) {
    listeners.get(i).onLeftClick(this);
    if (isCancelled())     break;
  }
}

Fixed version (ground truth):
@Override public void fire(ArrayList<LeftClickListener> listeners){
  for (  LeftClickListener listener : listeners) {
    listener.onLeftClick(this);
    if (isCancelled())     break;
  }
}
Program: 175735
Project: 175735
Buggy source:
@Override public void fire(ArrayList<PacketInputListener> listeners){
  for (int i=0; i < listeners.size(); i++) {
    listeners.get(i).onReceivedPacket(this);
    if (isCancelled())     break;
  }
}

Fixed version (ground truth):
@Override public void fire(ArrayList<PacketInputListener> listeners){
  for (  PacketInputListener listener : listeners) {
    listener.onReceivedPacket(this);
    if (isCancelled())     break;
  }
}
Program: 175736
Project: 175736
Buggy source:
@Override public void fire(ArrayList<PacketOutputListener> listeners){
  for (int i=0; i < listeners.size(); i++) {
    listeners.get(i).onSentPacket(this);
    if (isCancelled())     break;
  }
}

Fixed version (ground truth):
@Override public void fire(ArrayList<PacketOutputListener> listeners){
  for (  PacketOutputListener listener : listeners) {
    listener.onSentPacket(this);
    if (isCancelled())     break;
  }
}
Program: 175737
Project: 175737
Buggy source:
@Override public void fire(ArrayList<PostUpdateListener> listeners){
  for (int i=0; i < listeners.size(); i++)   listeners.get(i).afterUpdate();
}

Fixed version (ground truth):
@Override public void fire(ArrayList<PostUpdateListener> listeners){
  for (  PostUpdateListener listener : listeners)   listener.afterUpdate();
}
Program: 175738
Project: 175738
Buggy source:
@Override public void fire(ArrayList<RenderListener> listeners){
  for (int i=0; i < listeners.size(); i++)   listeners.get(i).onRender(partialTicks);
}

Fixed version (ground truth):
@Override public void fire(ArrayList<RenderListener> listeners){
  for (  RenderListener listener : listeners)   listener.onRender(partialTicks);
}
Program: 175739
Project: 175739
Buggy source:
@Override public void fire(ArrayList<RightClickListener> listeners){
  for (int i=0; i < listeners.size(); i++) {
    listeners.get(i).onRightClick(this);
    if (isCancelled())     break;
  }
}

Fixed version (ground truth):
@Override public void fire(ArrayList<RightClickListener> listeners){
  for (  RightClickListener listener : listeners) {
    listener.onRightClick(this);
    if (isCancelled())     break;
  }
}
Program: 175740
Project: 175740
Buggy source:
@Override public void fire(ArrayList<UpdateListener> listeners){
  for (int i=0; i < listeners.size(); i++)   listeners.get(i).onUpdate();
}

Fixed version (ground truth):
@Override public void fire(ArrayList<UpdateListener> listeners){
  for (  UpdateListener listener : listeners)   listener.onUpdate();
}
Program: 175741
Project: 175741
Buggy source:
@Test public void testApply_Basic(){
  int numGames=3;
  int numCards=12;
  int maxCard=numCards;
  Strategy strategy=new NextCard();
  List<Player> players=new ArrayList<>();
  Player p1=new Player("String_Node_Str",strategy,maxCard,new Hand());
  Player p2=new Player("String_Node_Str",strategy,maxCard,new Hand());
  Player p3=new Player("String_Node_Str",strategy,maxCard,new Hand());
  players.add(p1);
  players.add(p2);
  players.add(p3);
  List<Player> newPlayers=new Tourney(numCards,numGames,false).apply(players);
  assertEquals(3,newPlayers.size());
  assertEquals(0,newPlayers.get(0).getNumCardsInHand());
  assertEquals(0,newPlayers.get(1).getNumCardsInHand());
  assertEquals(0,newPlayers.get(2).getNumCardsInHand());
  assertEquals(3,newPlayers.stream().map(p -> p.getPlayerStats().getNumGamesWon()).mapToInt(i -> i).sum());
}

Fixed version (ground truth):
@Test public void testApply_Basic(){
  int numGames=3;
  int numCards=12;
  int maxCard=numCards;
  List<Player> players=new ArrayList<>();
  Player p1=new Player("String_Node_Str",strategy,maxCard,new Hand());
  Player p2=new Player("String_Node_Str",strategy,maxCard,new Hand());
  Player p3=new Player("String_Node_Str",strategy,maxCard,new Hand());
  players.add(p1);
  players.add(p2);
  players.add(p3);
  List<Player> newPlayers=new Tourney(numCards,numGames,false).apply(players);
  assertEquals(3,newPlayers.size());
  assertEquals(0,newPlayers.get(0).getNumCardsInHand());
  assertEquals(0,newPlayers.get(1).getNumCardsInHand());
  assertEquals(0,newPlayers.get(2).getNumCardsInHand());
  assertEquals(3,newPlayers.stream().map(p -> p.getPlayerStats().getNumGamesWon()).mapToInt(i -> i).sum());
}
Program: 175742
Project: 175742
Buggy source:
@Test public void testApply_Basic(){
  int numCards=12;
  int maxCard=numCards;
  Strategy strategy=new NextCard();
  List<Player> players=new ArrayList<>();
  Player p1=new Player("String_Node_Str",strategy,maxCard,new Hand());
  Player p2=new Player("String_Node_Str",strategy,maxCard,new Hand());
  Player p3=new Player("String_Node_Str",strategy,maxCard,new Hand());
  players.add(p1);
  players.add(p2);
  players.add(p3);
  List<Player> newPlayers=new Game(numCards,false).apply(players);
  assertEquals(3,newPlayers.size());
  assertEquals(0,newPlayers.get(0).getNumCardsInHand());
  assertEquals(0,newPlayers.get(1).getNumCardsInHand());
  assertEquals(0,newPlayers.get(2).getNumCardsInHand());
  assertEquals(1,newPlayers.stream().filter(p -> p.getPlayerStats().getNumGamesWon() == 1).count());
  assertEquals(2,newPlayers.stream().filter(p -> p.getPlayerStats().getNumGamesWon() == 0).count());
  int maxTotal=maxCard + (maxCard - 1) + (maxCard - 2);
  assertEquals(3,newPlayers.stream().filter(p -> p.getPlayerStats().getTotal() <= maxTotal).count());
  assertEquals(3,newPlayers.stream().map(p -> p.getPlayerStats().getNumRoundsWon()).mapToInt(i -> i).sum());
}

Fixed version (ground truth):
@Test public void testApply_Basic(){
  int numCards=12;
  int maxCard=numCards;
  List<Player> players=new ArrayList<>();
  Player p1=new Player("String_Node_Str",strategy,maxCard,new Hand());
  Player p2=new Player("String_Node_Str",strategy,maxCard,new Hand());
  Player p3=new Player("String_Node_Str",strategy,maxCard,new Hand());
  players.add(p1);
  players.add(p2);
  players.add(p3);
  List<Player> newPlayers=new Game(numCards,false).apply(players);
  assertEquals(3,newPlayers.size());
  assertEquals(0,newPlayers.get(0).getNumCardsInHand());
  assertEquals(0,newPlayers.get(1).getNumCardsInHand());
  assertEquals(0,newPlayers.get(2).getNumCardsInHand());
  assertEquals(1,newPlayers.stream().filter(p -> p.getPlayerStats().getNumGamesWon() == 1).count());
  assertEquals(2,newPlayers.stream().filter(p -> p.getPlayerStats().getNumGamesWon() == 0).count());
  int maxTotal=maxCard + (maxCard - 1) + (maxCard - 2);
  assertEquals(3,newPlayers.stream().filter(p -> p.getPlayerStats().getTotal() <= maxTotal).count());
  assertEquals(3,newPlayers.stream().map(p -> p.getPlayerStats().getNumRoundsWon()).mapToInt(i -> i).sum());
}