nus-yam/ex-repair huggingface dataset:
Program: 61730
Project: 61730
Buggy source:
public Optional<Webhook> upsert(Webhook webhook){
  webhook=webhook.withDefaults(true);
  logger.info("String_Node_Str" + webhook);
  webhookValidator.validate(webhook);
  String name=webhook.getName();
  Optional<Webhook> webhookOptional=get(name);
  if (webhookOptional.isPresent()) {
    Webhook existing=webhookOptional.get();
    if (existing.equals(webhook)) {
      return webhookOptional;
    }
 else     if (!existing.allowedToChange(webhook)) {
      throw new ConflictException("String_Node_Str");
    }
  }
  ContentPath existing=lastContentPath.getOrNull(name,WEBHOOK_LAST_COMPLETED);
  logger.info("String_Node_Str",name,existing,webhook.getStartingKey());
  ChannelConfig channel=channelService.getCachedChannelConfig(webhook.getChannelName());
  if (channel.isHistorical()) {
    ContentPath first=lastContentPath.get(channel.getName(),ContentKey.NONE,HISTORICAL_FIRST_UPDATED);
    if (first.equals(ContentKey.NONE)) {
      webhook=webhook.withPaused(true);
      webhook=webhook.withStartingKey(ContentKey.NONE);
      logger.info("String_Node_Str",webhook);
    }
 else {
      ContentPath lastUpdated=lastContentPath.get(channel.getName(),ContentKey.NONE,HISTORICAL_LAST_UPDATED);
      if (lastUpdated.equals(ContentKey.NONE)) {
        webhook=webhook.withStartingKey(new ContentKey(first.getTime().minusMillis(1)));
      }
 else       if (webhook.getStartingKey() == null || webhook.getStartingKey().compareTo(lastUpdated) > 0) {
        webhook=webhook.withStartingKey(lastUpdated);
      }
      logger.info("String_Node_Str",webhook);
      lastContentPath.update(webhook.getStartingKey(),name,WEBHOOK_LAST_COMPLETED);
    }
  }
  if (existing == null || webhook.getStartingKey() != null) {
    logger.info("String_Node_Str",name,webhook.getStartingKey());
    lastContentPath.initialize(name,webhook.getStartingKey(),WEBHOOK_LAST_COMPLETED);
  }
  webhookDao.upsert(webhook);
  webhookManager.notifyWatchers();
  return webhookOptional;
}

Fixed version (ground truth):
public Optional<Webhook> upsert(Webhook webhook){
  webhook=webhook.withDefaults(true);
  logger.info("String_Node_Str" + webhook);
  webhookValidator.validate(webhook);
  String name=webhook.getName();
  Optional<Webhook> webhookOptional=get(name);
  if (webhookOptional.isPresent()) {
    Webhook existing=webhookOptional.get();
    if (existing.equals(webhook)) {
      return webhookOptional;
    }
 else     if (!existing.allowedToChange(webhook)) {
      throw new ConflictException("String_Node_Str");
    }
  }
  ContentPath existing=lastContentPath.getOrNull(name,WEBHOOK_LAST_COMPLETED);
  logger.info("String_Node_Str",name,existing,webhook.getStartingKey());
  webhook=upsertHistorical(webhook,name);
  if (existing == null || webhook.getStartingKey() != null) {
    logger.info("String_Node_Str",name,webhook.getStartingKey());
    lastContentPath.initialize(name,webhook.getStartingKey(),WEBHOOK_LAST_COMPLETED);
  }
  webhookDao.upsert(webhook);
  webhookManager.notifyWatchers();
  return webhookOptional;
}
Program: 61731
Project: 61731
Buggy source:
@Override public SortedSet<ContentKey> queryByTime(TimeQuery query){
  return primaryAndSecondary(query.getChannelName(),() -> localChannelService.queryByTime(query),() -> query(query,spokeContentDao.queryByTime(query)));
}

Fixed version (ground truth):
@Override public SortedSet<ContentKey> queryByTime(TimeQuery query){
  return primaryAndSecondary(query.getChannelName(),() -> localChannelService.queryByTime(query),() -> query(query,localChannelService.queryByTime(query.withLocation(Location.CACHE))));
}
Program: 61732
Project: 61732
Buggy source:
@Override public SortedSet<ContentKey> getKeys(DirectionQuery query){
  query.withLiveChannel(getCachedChannelConfig(query.getChannelName()).isLive());
  return primaryAndSecondary(query.getChannelName(),() -> localChannelService.getKeys(query),() -> query(query,spokeContentDao.query(query)));
}

Fixed version (ground truth):
@Override public SortedSet<ContentKey> getKeys(DirectionQuery query){
  return primaryAndSecondary(query.getChannelName(),() -> localChannelService.getKeys(query),() -> query(query,localChannelService.getKeys(query.withLocation(Location.CACHE))));
}
Program: 61733
Project: 61733
Buggy source:
@Override public SortedSet<ContentKey> getKeys(DirectionQuery query){
  if (query.getCount() <= 0) {
    return Collections.emptySortedSet();
  }
  if (query.getCount() > DIR_COUNT_LIMIT) {
    query=query.withCount(DIR_COUNT_LIMIT);
  }
  DateTime ttlTime=getTtlTime(query.getChannelName());
  if (query.getContentKey().getTime().isBefore(ttlTime)) {
    query=query.withContentKey(new ContentKey(ttlTime,"String_Node_Str"));
  }
  query=query.withLiveChannel(getCachedChannelConfig(query.getChannelName()).isLive());
  query=query.withTtlDays(getTtlDays(query.getChannelName()));
  Traces traces=ActiveTraces.getLocal();
  traces.add(query);
  List<ContentKey> keys=new ArrayList<>(contentService.queryDirection(query));
  SortedSet<ContentKey> contentKeys=ContentKeyUtil.filter(keys,query.getContentKey(),ttlTime,query.getCount(),query.isNext(),query.isStable());
  traces.add("String_Node_Str",contentKeys);
  return contentKeys;
}

Fixed version (ground truth):
@Override public SortedSet<ContentKey> getKeys(DirectionQuery query){
  if (query.getCount() <= 0) {
    return Collections.emptySortedSet();
  }
  if (query.getCount() > DIR_COUNT_LIMIT) {
    query=query.withCount(DIR_COUNT_LIMIT);
  }
  DateTime ttlTime=getTtlTime(query.getChannelName());
  if (query.getContentKey().getTime().isBefore(ttlTime)) {
    query=query.withContentKey(new ContentKey(ttlTime,"String_Node_Str"));
  }
  query=query.withLiveChannel(getCachedChannelConfig(query.getChannelName()).isLive());
  query=query.withTtlDays(getTtlDays(query.getChannelName()));
  ContentPath lastUpdated=getLastUpdated(query.getChannelName(),new ContentKey(TimeUtil.time(query.isStable())));
  query=query.withChannelStable(lastUpdated.getTime());
  Traces traces=ActiveTraces.getLocal();
  traces.add(query);
  List<ContentKey> keys=new ArrayList<>(contentService.queryDirection(query));
  SortedSet<ContentKey> contentKeys=ContentKeyUtil.filter(keys,query.getContentKey(),ttlTime,query.getCount(),query.isNext(),query.isStable());
  traces.add("String_Node_Str",contentKeys);
  return contentKeys;
}
Program: 61734
Project: 61734
Buggy source:
private void query(String channel,List<ContentKey> keys,int count,int expected,boolean next,DateTime queryTime){
  DirectionQuery query=DirectionQuery.builder().stable(false).channelName(channel).count(count).next(next).contentKey(new ContentKey(queryTime,"String_Node_Str")).ttlDays(120).liveChannel(true).build();
  Collection<ContentKey> found=contentDao.query(query);
  logger.info("String_Node_Str",queryTime,found);
  assertEquals(expected,found.size());
  assertTrue(keys.containsAll(found));
}

Fixed version (ground truth):
private void query(String channel,List<ContentKey> keys,int count,int expected,boolean next,DateTime queryTime){
  ActiveTraces.start("String_Node_Str",channel,count,queryTime);
  DirectionQuery query=DirectionQuery.builder().stable(false).channelName(channel).count(count).next(next).contentKey(new ContentKey(queryTime,"String_Node_Str")).ttlDays(120).liveChannel(true).channelStable(TimeUtil.now()).build();
  Collection<ContentKey> found=contentDao.query(query);
  logger.info("String_Node_Str",queryTime,found);
  ActiveTraces.getLocal().log(logger);
  assertEquals(expected,found.size());
  assertTrue(keys.containsAll(found));
}
Program: 61735
Project: 61735
Buggy source:
public byte[] getData(){
  if (data == null && stream != null) {
    try {
      data=ByteStreams.toByteArray(stream);
    }
 catch (    EOFException e) {
      logger.info("String_Node_Str",contentKey);
    }
catch (    Exception e) {
      logger.warn("String_Node_Str" + contentKey,e);
    }
  }
  return data;
}

Fixed version (ground truth):
public byte[] getData(){
  if (data == null && stream != null) {
    try {
      data=ByteStreams.toByteArray(stream);
      stream=null;
    }
 catch (    EOFException e) {
      logger.info("String_Node_Str",contentKey);
    }
catch (    Exception e) {
      logger.warn("String_Node_Str" + contentKey,e);
    }
  }
  return data;
}
Program: 61736
Project: 61736
Buggy source:
public Content get(String path,ContentKey key){
  Collection<String> servers=cluster.getRandomServers();
  for (  String server : servers) {
    ClientResponse response=null;
    try {
      setThread(path);
      response=query_client.resource(HubHost.getScheme() + server + "String_Node_Str"+ path).get(ClientResponse.class);
      logger.trace("String_Node_Str",server,path,response);
      if (response.getStatus() == 200) {
        byte[] entity=response.getEntity(byte[].class);
        if (entity.length > 0) {
          Content content=ContentMarshaller.toContent(entity,key);
          byte[] data=content.getData();
          logger.trace("String_Node_Str",path,data.length);
          return content;
        }
      }
    }
 catch (    JsonMappingException e) {
      logger.info("String_Node_Str" + path);
    }
catch (    ClientHandlerException e) {
      if (e.getCause() != null && e.getCause() instanceof ConnectException) {
        logger.warn("String_Node_Str" + server);
      }
 else {
        logger.warn("String_Node_Str" + path,e);
      }
    }
catch (    Exception e) {
      logger.warn("String_Node_Str" + path,e);
    }
 finally {
      close(response);
      resetThread();
    }
  }
  return null;
}

Fixed version (ground truth):
public Content get(String path,ContentKey key){
  Collection<String> servers=cluster.getRandomServers();
  for (  String server : servers) {
    ClientResponse response=null;
    try {
      setThread(path);
      response=query_client.resource(HubHost.getScheme() + server + "String_Node_Str"+ path).get(ClientResponse.class);
      logger.trace("String_Node_Str",server,path,response);
      if (response.getStatus() == 200) {
        byte[] entity=response.getEntity(byte[].class);
        if (entity.length > 0) {
          return ContentMarshaller.toContent(entity,key);
        }
      }
    }
 catch (    JsonMappingException e) {
      logger.info("String_Node_Str" + path);
    }
catch (    ClientHandlerException e) {
      if (e.getCause() != null && e.getCause() instanceof ConnectException) {
        logger.warn("String_Node_Str" + server);
      }
 else {
        logger.warn("String_Node_Str" + path,e);
      }
    }
catch (    Exception e) {
      logger.warn("String_Node_Str" + path,e);
    }
 finally {
      close(response);
      resetThread();
    }
  }
  return null;
}
Program: 61737
Project: 61737
Buggy source:
public static String extractFromChannelUrl(String fullUrl){
  return StringUtils.substringAfter(fullUrl,"String_Node_Str");
}

Fixed version (ground truth):
public static String extractFromChannelUrl(String fullUrl){
  String after=StringUtils.substringAfter(fullUrl,"String_Node_Str");
  return StringUtils.removeEnd(after,"String_Node_Str");
}
Program: 61738
Project: 61738
Buggy source:
public static byte[] toBytes(Content content,boolean compress) throws IOException {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  ZipOutputStream zipOut=new ZipOutputStream(baos);
  if (compress) {
    zipOut.setLevel(Deflater.BEST_SPEED);
  }
 else {
    zipOut.setLevel(Deflater.NO_COMPRESSION);
  }
  zipOut.putNextEntry(new ZipEntry("String_Node_Str"));
  String meta=getMetaData(content);
  zipOut.write(meta.getBytes());
  zipOut.putNextEntry(new ZipEntry("String_Node_Str"));
  long bytesCopied=ByteStreams.copy(content.getStream(),zipOut);
  if (bytesCopied > maxBytes) {
    throw new ContentTooLargeException("String_Node_Str" + maxBytes + "String_Node_Str");
  }
  content.setSize(bytesCopied);
  zipOut.close();
  byte[] bytes=baos.toByteArray();
  logger.trace("String_Node_Str",bytes.length,content.getContentKey().get());
  return bytes;
}

Fixed version (ground truth):
public static byte[] toBytes(Content content,boolean compress) throws IOException {
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  ZipOutputStream zipOut=new ZipOutputStream(baos);
  if (compress) {
    zipOut.setLevel(Deflater.BEST_SPEED);
  }
 else {
    zipOut.setLevel(Deflater.NO_COMPRESSION);
  }
  zipOut.putNextEntry(new ZipEntry("String_Node_Str"));
  String meta=getMetaData(content);
  zipOut.write(meta.getBytes());
  zipOut.putNextEntry(new ZipEntry("String_Node_Str"));
  long bytesCopied=ByteStreams.copy(content.getStream(),zipOut);
  if (bytesCopied > maxBytes) {
    throw new ContentTooLargeException("String_Node_Str" + maxBytes + "String_Node_Str");
  }
  content.setSize(bytesCopied);
  zipOut.close();
  return baos.toByteArray();
}
Program: 61740
Project: 61740
Buggy source:
public String getLatest(String channel,String limitPath){
  logger.trace("String_Node_Str",channel,limitPath);
  String[] split=StringUtils.split(limitPath,"String_Node_Str");
  split=new String[]{split[0],split[1],split[2],split[3],split[4],split[5] + split[6] + split[7]};
  String last=recurseLatest(channel,split,0,channel);
  if (last == null) {
    return null;
  }
  String latest=spokeKeyFromPath(last);
  logger.trace("String_Node_Str",latest,limitPath);
  return latest;
}

Fixed version (ground truth):
public String getLatest(String channel,String limitPath){
  logger.trace("String_Node_Str",channel,limitPath);
  String[] split=StringUtils.split(limitPath,"String_Node_Str");
  split=new String[]{split[0],split[1],split[2],split[3],split[4],split[5] + split[6] + split[7]};
  String last=recurseLatest(channel,split,0,channel);
  if (last == null) {
    DateTime ttlTime=TimeUtil.now().minusMinutes(ttlMinutes);
    DateTime limitTime=TimeUtil.millis(StringUtils.substringBeforeLast(limitPath,"String_Node_Str") + "String_Node_Str");
    DateTime previous=limitTime.minusHours(1).withMinuteOfHour(59).withSecondOfMinute(59).withMillisOfSecond(999);
    if (previous.isBefore(ttlTime)) {
      return null;
    }
    return getLatest(channel,ContentKey.lastKey(previous).toUrl());
  }
 else {
    String latest=spokeKeyFromPath(last);
    logger.trace("String_Node_Str",latest,limitPath);
    return latest;
  }
}
Program: 61741
Project: 61741
Buggy source:
private void updateTtlDays(){
  logger.info("String_Node_Str");
  ActiveTraces.start("String_Node_Str");
  ArrayList<BucketLifecycleConfiguration.Rule> rules=new ArrayList<>();
  for (  ChannelConfig config : configurations) {
    if (config.getTtlDays() > 0) {
      rules.add(addRule(config,"String_Node_Str"));
      rules.add(addRule(config,"String_Node_Str"));
    }
  }
  logger.info("String_Node_Str" + rules.size() + "String_Node_Str");
  if (!rules.isEmpty()) {
    BucketLifecycleConfiguration lifecycleConfig=new BucketLifecycleConfiguration(rules);
    s3Client.setBucketLifecycleConfiguration(s3BucketName,lifecycleConfig);
  }
  ActiveTraces.end();
}

Fixed version (ground truth):
private void updateTtlDays(){
  logger.info("String_Node_Str");
  ActiveTraces.start("String_Node_Str");
  ArrayList<BucketLifecycleConfiguration.Rule> rules=new ArrayList<>();
  for (  ChannelConfig config : configurations) {
    if (config.getTtlDays() > 0) {
      if (config.isSingle() || config.isBoth()) {
        rules.add(addRule(config,"String_Node_Str"));
      }
      if (config.isBatch() || config.isBoth()) {
        rules.add(addRule(config,"String_Node_Str"));
      }
    }
  }
  logger.info("String_Node_Str" + rules.size() + "String_Node_Str");
  if (!rules.isEmpty()) {
    BucketLifecycleConfiguration lifecycleConfig=new BucketLifecycleConfiguration(rules);
    s3Client.setBucketLifecycleConfiguration(s3BucketName,lifecycleConfig);
  }
  ActiveTraces.end();
}
Program: 61742
Project: 61742
Buggy source:
private SortedSet<ContentKey> handleNext(DirectionQuery query){
  SortedSet<ContentKey> keys=new TreeSet<>();
  Traces traces=ActiveTraces.getLocal();
  DateTime endTime=TimeUtil.time(query.isStable());
  DateTime markerTime=query.getContentKey().getTime().minusMinutes(1);
  int queryItems=Math.min(s3MaxQueryItems,query.getCount());
  do {
    String channel=query.getChannelName();
    ListObjectsRequest request=new ListObjectsRequest().withBucketName(s3BucketName).withPrefix(channel + BATCH_INDEX).withMarker(channel + BATCH_INDEX + TimeUtil.Unit.MINUTES.format(markerTime)).withMaxKeys(queryItems);
    SortedSet<MinutePath> paths=listMinutePaths(channel,request,traces,false);
    if (paths.isEmpty()) {
      return keys;
    }
    for (    MinutePath path : paths) {
      if (keys.size() >= query.getCount()) {
        return keys;
      }
      getKeysForMinute(channel,path,keys,traces);
      markerTime=path.getTime();
    }
  }
 while (keys.size() < query.getCount() && markerTime.isBefore(endTime));
  return keys;
}

Fixed version (ground truth):
private SortedSet<ContentKey> handleNext(DirectionQuery query){
  SortedSet<ContentKey> keys=new TreeSet<>();
  Traces traces=ActiveTraces.getLocal();
  DateTime endTime=TimeUtil.time(query.isStable());
  DateTime markerTime=query.getContentKey().getTime().minusMinutes(1);
  int queryItems=Math.min(s3MaxQueryItems,query.getCount());
  do {
    String channel=query.getChannelName();
    ListObjectsRequest request=new ListObjectsRequest().withBucketName(s3BucketName).withPrefix(channel + BATCH_INDEX).withMarker(channel + BATCH_INDEX + TimeUtil.Unit.MINUTES.format(markerTime)).withMaxKeys(queryItems);
    SortedSet<MinutePath> paths=listMinutePaths(channel,request,traces,false);
    if (paths.isEmpty()) {
      return keys;
    }
    for (    MinutePath path : paths) {
      getKeysForMinute(channel,path,traces,item -> {
        ContentKey contentKey=ContentKey.fromUrl(item.asText()).get();
        if (contentKey.compareTo(query.getContentKey()) > 0 && keys.size() < query.getCount()) {
          keys.add(contentKey);
        }
      }
);
      markerTime=path.getTime();
    }
  }
 while (keys.size() < query.getCount() && markerTime.isBefore(endTime));
  return keys;
}
Program: 61743
Project: 61743
Buggy source:
private void getKeysForMinute(String channel,MinutePath minutePath,SortedSet<ContentKey> keys,Traces traces){
  try (S3Object object=s3Client.getObject(s3BucketName,getS3BatchIndexKey(channel,minutePath))){
    sender.send("String_Node_Str" + channel + "String_Node_Str",1);
    byte[] bytes=ByteStreams.toByteArray(object.getObjectContent());
    JsonNode root=mapper.readTree(bytes);
    JsonNode items=root.get("String_Node_Str");
    for (    JsonNode item : items) {
      keys.add(ContentKey.fromUrl(item.asText()).get());
    }
    traces.add("String_Node_Str",minutePath,items.size());
  }
 catch (  AmazonS3Exception e) {
    if (e.getStatusCode() != 404) {
      logger.warn("String_Node_Str" + channel,minutePath,e);
      traces.add("String_Node_Str",e);
    }
 else {
      traces.add("String_Node_Str",minutePath);
    }
  }
catch (  IOException e) {
    logger.warn("String_Node_Str" + channel,minutePath,e);
    traces.add("String_Node_Str",e);
  }
}

Fixed version (ground truth):
private void getKeysForMinute(String channel,MinutePath minutePath,Traces traces,Consumer<JsonNode> itemNodeConsumer){
  try (S3Object object=s3Client.getObject(s3BucketName,getS3BatchIndexKey(channel,minutePath))){
    sender.send("String_Node_Str" + channel + "String_Node_Str",1);
    byte[] bytes=ByteStreams.toByteArray(object.getObjectContent());
    JsonNode root=mapper.readTree(bytes);
    JsonNode items=root.get("String_Node_Str");
    for (    JsonNode item : items) {
      itemNodeConsumer.accept(item);
    }
    traces.add("String_Node_Str",minutePath,items.size());
  }
 catch (  AmazonS3Exception e) {
    if (e.getStatusCode() != 404) {
      logger.warn("String_Node_Str" + channel,minutePath,e);
      traces.add("String_Node_Str",e);
    }
 else {
      traces.add("String_Node_Str",minutePath);
    }
  }
catch (  IOException e) {
    logger.warn("String_Node_Str" + channel,minutePath,e);
    traces.add("String_Node_Str",e);
  }
}
Program: 61744
Project: 61744
Buggy source:
@Test public void testDirectionQueryAndDelete() throws Exception {
  String channel="String_Node_Str" + RandomStringUtils.randomAlphanumeric(20);
  DateTime start=TimeUtil.now().minusHours(2);
  ContentKey key=new ContentKey(start,"String_Node_Str");
  for (int i=0; i < 12; i++) {
    writeBatchMinute(channel,new MinutePath(start.plusMinutes(i * 6)),2);
  }
  queryDirection(channel,key,true,50,24);
  queryDirection(channel,new ContentKey(start.plusMinutes(37),"String_Node_Str"),true,6,6);
  queryDirection(channel,new ContentKey(start.plusMinutes(73),"String_Node_Str"),true,0,0);
  queryDirection(channel,new ContentKey(start.plusMinutes(73),"String_Node_Str"),false,23,23);
  queryDirection(channel,new ContentKey(start.plusMinutes(14),"String_Node_Str"),false,8,6);
  contentDao.deleteBefore(channel,new ContentKey(start.plusMinutes(37),"String_Node_Str"));
  queryDirection(channel,new ContentKey(start.plusMinutes(37),"String_Node_Str"),false,8,0);
  queryDirection(channel,key,true,50,10);
}

Fixed version (ground truth):
@Test public void testDirectionQueryAndDelete() throws Exception {
  String channel="String_Node_Str" + RandomStringUtils.randomAlphanumeric(20);
  DateTime start=TimeUtil.now().minusHours(2);
  ContentKey key=new ContentKey(new MinutePath(start).getTime(),"String_Node_Str");
  for (int i=0; i < 12; i++) {
    writeBatchMinute(channel,new MinutePath(start.plusMinutes(i * 6)),2);
  }
  queryDirection(channel,key,true,50,24);
  queryDirection(channel,new ContentKey(start.plusMinutes(37),"String_Node_Str"),true,6,6);
  queryDirection(channel,new ContentKey(start.plusMinutes(73),"String_Node_Str"),true,0,0);
  queryDirection(channel,new ContentKey(start.plusMinutes(73),"String_Node_Str"),false,23,23);
  queryDirection(channel,new ContentKey(start.plusMinutes(14),"String_Node_Str"),false,8,6);
  contentDao.deleteBefore(channel,new ContentKey(start.plusMinutes(37),"String_Node_Str"));
  queryDirection(channel,new ContentKey(start.plusMinutes(37),"String_Node_Str"),false,8,0);
  queryDirection(channel,key,true,50,10);
}
Program: 61745
Project: 61745
Buggy source:
private void queryDirection(String channel,ContentKey contentKey,boolean next,int count,int expected){
  DirectionQuery query=DirectionQuery.builder().channelName(channel).contentKey(contentKey).next(next).count(count).ttlDays(2).build();
  SortedSet<ContentKey> found=contentDao.query(query);
  assertEquals(expected,found.size());
}

Fixed version (ground truth):
private SortedSet<ContentKey> queryDirection(String channel,ContentKey contentKey,boolean next,int count,int expected){
  DirectionQuery query=DirectionQuery.builder().channelName(channel).contentKey(contentKey).next(next).count(count).ttlDays(2).build();
  ActiveTraces.start(query);
  logger.info("String_Node_Str",query);
  SortedSet<ContentKey> found=contentDao.query(query);
  ActiveTraces.getLocal().log(logger);
  ActiveTraces.end();
  assertEquals(expected,found.size());
  return found;
}
Program: 61746
Project: 61746
Buggy source:
public void updateTable(String tableName,ProvisionedThroughput throughput){
  try {
    TableDescription tableDescription=waitForTableStatus(tableName,TableStatus.ACTIVE);
    ProvisionedThroughputDescription provisionedThroughput=tableDescription.getProvisionedThroughput();
    if (provisionedThroughput.equals(throughput)) {
      logger.info("String_Node_Str",tableName,throughput);
    }
 else {
      logger.info("String_Node_Str",tableName,throughput);
      dbClient.updateTable(tableName,throughput);
      waitForTableStatus(tableName,TableStatus.ACTIVE);
    }
  }
 catch (  ResourceNotFoundException e) {
    logger.warn("String_Node_Str" + tableName,e);
    throw new RuntimeException("String_Node_Str" + tableName);
  }
}

Fixed version (ground truth):
public void updateTable(String tableName,ProvisionedThroughput throughput){
  try {
    TableDescription tableDescription=waitForTableStatus(tableName,TableStatus.ACTIVE);
    ProvisionedThroughputDescription provisionedThroughput=tableDescription.getProvisionedThroughput();
    if (provisionedThroughput.getReadCapacityUnits().equals(throughput.getReadCapacityUnits()) && provisionedThroughput.getWriteCapacityUnits().equals(throughput.getWriteCapacityUnits())) {
      logger.info("String_Node_Str",tableName,throughput);
    }
 else {
      logger.info("String_Node_Str",tableName,throughput);
      dbClient.updateTable(tableName,throughput);
      waitForTableStatus(tableName,TableStatus.ACTIVE);
    }
  }
 catch (  ResourceNotFoundException e) {
    logger.warn("String_Node_Str" + tableName,e);
    throw new RuntimeException("String_Node_Str" + tableName);
  }
}
Program: 61748
Project: 61748
Buggy source:
public MinuteGroupStrategy(Group group,LastContentPath lastContentPath,ChannelService channelService){
  this.group=group;
  this.lastContentPath=lastContentPath;
  this.channelService=channelService;
  this.queue=new ArrayBlockingQueue<>(group.getParallelCalls() * 2);
}

Fixed version (ground truth):
public MinuteGroupStrategy(Group group,LastContentPath lastContentPath,ChannelService channelService){
  this.group=group;
  channel=ChannelNameUtils.extractFromChannelUrl(group.getChannelUrl());
  this.lastContentPath=lastContentPath;
  this.channelService=channelService;
  this.queue=new ArrayBlockingQueue<>(group.getParallelCalls() * 2);
}
Program: 61749
Project: 61749
Buggy source:
private void notify(ChannelConfig newConfig,ChannelConfig oldConfig){
  if (newConfig.isReplicating()) {
    replicatorManager.notifyWatchers();
  }
 else   if (oldConfig != null && oldConfig.isReplicating()) {
    replicatorManager.notifyWatchers();
  }
  if (newConfig.isSingle() && !oldConfig.isSingle()) {
    new S3Batch(newConfig,hubUtils).stop();
  }
 else {
    new S3Batch(newConfig,hubUtils).start();
  }
}

Fixed version (ground truth):
private void notify(ChannelConfig newConfig,ChannelConfig oldConfig){
  if (newConfig.isReplicating()) {
    replicatorManager.notifyWatchers();
  }
 else   if (oldConfig != null && oldConfig.isReplicating()) {
    replicatorManager.notifyWatchers();
  }
  if (newConfig.isSingle()) {
    if (oldConfig != null && !oldConfig.isSingle()) {
      new S3Batch(newConfig,hubUtils).stop();
    }
  }
 else {
    new S3Batch(newConfig,hubUtils).start();
  }
}
Program: 61751
Project: 61751
Buggy source:
private void handleNormal(){
  try {
    DateTime nextTime=lastAdded.getTime().plusMinutes(1);
    DateTime stable=TimeUtil.stable().minusMinutes(1);
    logger.debug("String_Node_Str",lastAdded,nextTime,stable);
    while (nextTime.isBefore(stable)) {
      MinutePath nextPath=createMinutePath(nextTime);
      logger.trace("String_Node_Str",channel,nextPath);
      queue.put(nextPath);
      lastAdded=nextPath;
      nextTime=lastAdded.getTime().plusMinutes(1);
    }
  }
 catch (  InterruptedException e) {
    logger.info("String_Node_Str" + channel + "String_Node_Str"+ e.getMessage());
    throw new RuntimeInterruptedException(e);
  }
}

Fixed version (ground truth):
private void handleNormal(){
  try {
    DateTime nextTime=lastAdded.getTime().plusMinutes(1);
    DateTime stable=TimeUtil.stable().minusMinutes(1);
    logger.debug("String_Node_Str",lastAdded,nextTime,stable);
    while (nextTime.isBefore(stable)) {
      MinutePath nextPath=createMinutePath(nextTime);
      logger.trace("String_Node_Str",channel,nextPath,nextPath.getKeys());
      queue.put(nextPath);
      lastAdded=nextPath;
      nextTime=lastAdded.getTime().plusMinutes(1);
    }
  }
 catch (  InterruptedException e) {
    logger.info("String_Node_Str" + channel + "String_Node_Str"+ e.getMessage());
    throw new RuntimeInterruptedException(e);
  }
}
Program: 61752
Project: 61752
Buggy source:
@Override public int compareTo(ContentPath o){
  return 0;
}

Fixed version (ground truth):
@Override public int compareTo(ContentPath contentPath){
  MinutePath other=(MinutePath)contentPath;
  return time.compareTo(other.time);
}
Program: 61753
Project: 61753
Buggy source:
@Test public void testCreateIfMissing() throws Exception {
  String name="String_Node_Str";
  ContentKey key=new ContentKey();
  assertEquals(key,contentKeyValue.get(name,key,"String_Node_Str"));
  assertEquals(key,contentKeyValue.get(name,new ContentKey(),"String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testCreateIfMissing() throws Exception {
  String name="String_Node_Str";
  ContentKey key=new ContentKey();
  assertEquals(key,lastContentPath.get(name,key,BASE_PATH));
  assertEquals(key,lastContentPath.get(name,new ContentKey(),BASE_PATH));
}
Program: 61754
Project: 61754
Buggy source:
@Before public void setUp() throws Exception {
  contentKeyValue=new LastContentPath(curator);
}

Fixed version (ground truth):
@Before public void setUp() throws Exception {
  lastContentPath=new LastContentPath(curator);
}
Program: 61755
Project: 61755
Buggy source:
@Test public void testLifeCycle() throws Exception {
  String name="String_Node_Str";
  DateTime start=new DateTime(2014,12,3,20,45,DateTimeZone.UTC);
  ContentKey key1=new ContentKey(start,"String_Node_Str");
  contentKeyValue.initialize(name,key1,"String_Node_Str");
  assertEquals(key1,contentKeyValue.get(name,new ContentKey(),"String_Node_Str"));
  ContentKey key2=new ContentKey(start.plusMillis(1),"String_Node_Str");
  contentKeyValue.updateIncrease(key2,name,"String_Node_Str");
  assertEquals(key2,contentKeyValue.get(name,new ContentKey(),"String_Node_Str"));
  ContentKey key3=new ContentKey(start.minusMillis(1),"String_Node_Str");
  contentKeyValue.updateIncrease(key3,name,"String_Node_Str");
  assertEquals(key2,contentKeyValue.get(name,new ContentKey(),"String_Node_Str"));
  ContentKey key4=new ContentKey(start.plusMinutes(1),"String_Node_Str");
  contentKeyValue.updateIncrease(key4,name,"String_Node_Str");
  assertEquals(key4,contentKeyValue.get(name,new ContentKey(),"String_Node_Str"));
  contentKeyValue.delete(name,"String_Node_Str");
  ContentKey contentKey=new ContentKey();
  assertEquals(contentKey,contentKeyValue.get(name,contentKey,"String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testLifeCycle() throws Exception {
  String name="String_Node_Str";
  DateTime start=new DateTime(2014,12,3,20,45,DateTimeZone.UTC);
  ContentKey key1=new ContentKey(start,"String_Node_Str");
  lastContentPath.initialize(name,key1,BASE_PATH);
  assertEquals(key1,lastContentPath.get(name,new ContentKey(),BASE_PATH));
  ContentKey key2=new ContentKey(start.plusMillis(1),"String_Node_Str");
  lastContentPath.updateIncrease(key2,name,BASE_PATH);
  assertEquals(key2,lastContentPath.get(name,new ContentKey(),BASE_PATH));
  ContentKey key3=new ContentKey(start.minusMillis(1),"String_Node_Str");
  lastContentPath.updateIncrease(key3,name,BASE_PATH);
  assertEquals(key2,lastContentPath.get(name,new ContentKey(),BASE_PATH));
  ContentKey key4=new ContentKey(start.plusMinutes(1),"String_Node_Str");
  lastContentPath.updateIncrease(key4,name,BASE_PATH);
  assertEquals(key4,lastContentPath.get(name,new ContentKey(),BASE_PATH));
  lastContentPath.delete(name,BASE_PATH);
  ContentKey contentKey=new ContentKey();
  assertEquals(contentKey,lastContentPath.get(name,contentKey,BASE_PATH));
}
Program: 61756
Project: 61756
Buggy source:
@Override public void takeLeadership(AtomicBoolean hasLeadership){
  this.hasLeadership=hasLeadership;
  retryer=buildRetryer();
  logger.info("String_Node_Str" + group);
  Optional<Group> foundGroup=groupService.getGroup(group.getName());
  if (!foundGroup.isPresent()) {
    logger.info("String_Node_Str" + group.getName());
    return;
  }
  this.client=RestClient.createClient(30,120,true);
  callbackQueue=queueProvider.get();
  try {
    ContentKey startingKey=group.getStartingKey();
    if (null == startingKey) {
      startingKey=new ContentKey();
    }
    ContentKey lastCompletedKey=getLastCompleted(startingKey);
    logger.info("String_Node_Str",lastCompletedKey,group.getName());
    if (hasLeadership.get()) {
      sendInProcess(lastCompletedKey);
      callbackQueue.start(group,lastCompletedKey);
      while (hasLeadership.get()) {
        Optional<ContentKey> nextOptional=callbackQueue.next();
        if (nextOptional.isPresent()) {
          send(nextOptional.get());
        }
      }
    }
  }
 catch (  RuntimeInterruptedException|InterruptedException e) {
    logger.info("String_Node_Str" + group.getName());
  }
 finally {
    ContentKey lastCompletedKey=getLastCompleted(ContentKey.NONE);
    logger.info("String_Node_Str",lastCompletedKey,group.getName());
    closeQueue();
    if (deleteOnExit.get()) {
      delete();
    }
  }
}

Fixed version (ground truth):
@Override public void takeLeadership(AtomicBoolean hasLeadership){
  this.hasLeadership=hasLeadership;
  retryer=buildRetryer();
  logger.info("String_Node_Str" + group);
  Optional<Group> foundGroup=groupService.getGroup(group.getName());
  if (!foundGroup.isPresent()) {
    Sleeper.sleep(1000);
    logger.info("String_Node_Str" + group.getName());
    return;
  }
  this.group=foundGroup.get();
  this.client=RestClient.createClient(30,120,true);
  callbackQueue=queueProvider.get();
  try {
    ContentKey startingKey=group.getStartingKey();
    if (null == startingKey) {
      startingKey=new ContentKey();
    }
    ContentKey lastCompletedKey=getLastCompleted(startingKey);
    logger.info("String_Node_Str",lastCompletedKey,group.getName());
    if (hasLeadership.get()) {
      sendInProcess(lastCompletedKey);
      callbackQueue.start(group,lastCompletedKey);
      while (hasLeadership.get()) {
        Optional<ContentKey> nextOptional=callbackQueue.next();
        if (nextOptional.isPresent()) {
          send(nextOptional.get());
        }
      }
    }
  }
 catch (  RuntimeInterruptedException|InterruptedException e) {
    logger.info("String_Node_Str" + group.getName());
  }
 finally {
    ContentKey lastCompletedKey=getLastCompleted(ContentKey.NONE);
    logger.info("String_Node_Str",lastCompletedKey,group.getName());
    closeQueue();
    if (deleteOnExit.get()) {
      delete();
    }
  }
}
Program: 61757
Project: 61757
Buggy source:
private void doWork(){
  while (!shouldExit.get()) {
    DateTime latestStableInChannel=getLatestStable();
    logger.trace("String_Node_Str",channel,lastQueryTime,latestStableInChannel);
    if (lastQueryTime.isBefore(latestStableInChannel)) {
      TimeUtil.Unit unit=getStepUnit(latestStableInChannel);
      logger.trace("String_Node_Str",channel,unit,lastQueryTime);
      Location location=Location.ALL;
      if (unit.equals(TimeUtil.Unit.SECONDS)) {
        location=Location.CACHE;
      }
      TimeQuery query=TimeQuery.builder().channelName(channel).startTime(lastQueryTime).unit(unit).location(location).build();
      query.trace(false);
      addKeys(channelService.queryByTime(query));
      lastQueryTime=lastQueryTime.plus(unit.getDuration());
    }
 else {
      Sleeper.sleep(1000);
    }
  }
}

Fixed version (ground truth):
private void doWork(){
  while (!shouldExit.get()) {
    TimeQuery timeQuery=queryGenerator.getQuery(getLatestStable());
    if (timeQuery != null) {
      addKeys(channelService.queryByTime(timeQuery));
    }
 else {
      Sleeper.sleep(1000);
    }
  }
}
Program: 61759
Project: 61759
Buggy source:
@Override public void takeLeadership(AtomicBoolean hasLeadership){
  this.hasLeadership=hasLeadership;
  retryer=buildRetryer();
  logger.info("String_Node_Str" + group);
  Optional<Group> foundGroup=groupService.getGroup(group.getName());
  if (!foundGroup.isPresent()) {
    logger.info("String_Node_Str" + group.getName());
    return;
  }
  this.client=RestClient.createClient(30,120);
  callbackQueue=queueProvider.get();
  try {
    ContentKey lastCompletedKey=lastContentKey.get(group.getName(),new ContentKey(),GROUP_LAST_COMPLETED);
    logger.debug("String_Node_Str",lastCompletedKey,group.getName());
    if (hasLeadership.get()) {
      sendInProcess(lastCompletedKey);
      callbackQueue.start(group,lastCompletedKey);
      while (hasLeadership.get()) {
        Optional<ContentKey> nextOptional=callbackQueue.next();
        if (nextOptional.isPresent()) {
          send(nextOptional.get());
        }
      }
    }
  }
 catch (  RuntimeInterruptedException|InterruptedException e) {
    logger.info("String_Node_Str" + group.getName());
  }
 finally {
    logger.info("String_Node_Str" + group);
    closeQueue();
    if (deleteOnExit.get()) {
      delete();
    }
  }
}

Fixed version (ground truth):
@Override public void takeLeadership(AtomicBoolean hasLeadership){
  this.hasLeadership=hasLeadership;
  retryer=buildRetryer();
  logger.info("String_Node_Str" + group);
  Optional<Group> foundGroup=groupService.getGroup(group.getName());
  if (!foundGroup.isPresent()) {
    logger.info("String_Node_Str" + group.getName());
    return;
  }
  this.client=RestClient.createClient(30,120);
  callbackQueue=queueProvider.get();
  try {
    ContentKey lastCompletedKey=lastContentKey.get(group.getName(),new ContentKey(),GROUP_LAST_COMPLETED);
    logger.info("String_Node_Str",lastCompletedKey,group.getName());
    if (hasLeadership.get()) {
      sendInProcess(lastCompletedKey);
      callbackQueue.start(group,lastCompletedKey);
      while (hasLeadership.get()) {
        Optional<ContentKey> nextOptional=callbackQueue.next();
        if (nextOptional.isPresent()) {
          send(nextOptional.get());
        }
      }
    }
  }
 catch (  RuntimeInterruptedException|InterruptedException e) {
    logger.info("String_Node_Str" + group.getName());
  }
 finally {
    logger.info("String_Node_Str" + group);
    closeQueue();
    if (deleteOnExit.get()) {
      delete();
    }
  }
}
Program: 61760
Project: 61760
Buggy source:
private boolean setValue(String path,ContentKey nextKey,LastUpdated existing) throws Exception {
  try {
    curator.setData().withVersion(existing.version).forPath(path,nextKey.getBytes());
    return true;
  }
 catch (  KeeperException.BadVersionException e) {
    logger.info("String_Node_Str" + path + "String_Node_Str"+ e.getMessage());
    return false;
  }
catch (  Exception e) {
    logger.info("String_Node_Str" + path,e);
    return false;
  }
}

Fixed version (ground truth):
private boolean setValue(String path,ContentKey nextKey,LastUpdated existing) throws Exception {
  try {
    curator.setData().withVersion(existing.version).forPath(path,nextKey.getBytes());
    return true;
  }
 catch (  KeeperException.BadVersionException e) {
    logger.debug("String_Node_Str" + path + "String_Node_Str"+ e.getMessage());
    return false;
  }
catch (  Exception e) {
    logger.info("String_Node_Str" + path,e);
    return false;
  }
}
Program: 61761
Project: 61761
Buggy source:
private synchronized void replicateChannels(){
  if (stopped.get()) {
    logger.info("String_Node_Str");
    return;
  }
  logger.info("String_Node_Str");
  Set<String> replicators=new HashSet<>();
  Iterable<ChannelConfig> replicatedChannels=channelService.getChannels(REPLICATED);
  for (  ChannelConfig channel : replicatedChannels) {
    logger.info("String_Node_Str",channel.getName());
    try {
      if (replicatorMap.containsKey(channel.getName())) {
        ChannelReplicator replicator=replicatorMap.get(channel.getName());
        if (!replicator.getChannel().getReplicationSource().equals(channel.getReplicationSource())) {
          logger.info("String_Node_Str",replicator.getChannel().getReplicationSource(),channel.getReplicationSource());
          replicator.stop();
          startReplication(channel);
        }
      }
 else {
        startReplication(channel);
      }
      replicators.add(channel.getName());
    }
 catch (    Exception e) {
      logger.warn("String_Node_Str" + channel,e);
    }
  }
  Set<String> toStop=new HashSet<>(replicatorMap.keySet());
  toStop.removeAll(replicators);
  logger.info("String_Node_Str",toStop);
  for (  String nameToStop : toStop) {
    logger.info("String_Node_Str",nameToStop);
    ChannelReplicator replicator=replicatorMap.remove(nameToStop);
    replicator.stop();
  }
}

Fixed version (ground truth):
private synchronized void replicateChannels(){
  if (stopped.get()) {
    logger.info("String_Node_Str");
    return;
  }
  logger.info("String_Node_Str");
  Set<String> replicators=new HashSet<>();
  Iterable<ChannelConfig> replicatedChannels=channelService.getChannels(REPLICATED);
  for (  ChannelConfig channel : replicatedChannels) {
    logger.info("String_Node_Str",channel.getName());
    try {
      replicators.add(channel.getName());
      if (replicatorMap.containsKey(channel.getName())) {
        ChannelReplicator replicator=replicatorMap.get(channel.getName());
        if (!replicator.getChannel().getReplicationSource().equals(channel.getReplicationSource())) {
          logger.info("String_Node_Str",replicator.getChannel().getReplicationSource(),channel.getReplicationSource());
          replicator.stop();
          startReplication(channel);
        }
      }
 else {
        startReplication(channel);
      }
    }
 catch (    Exception e) {
      logger.warn("String_Node_Str" + channel,e);
    }
  }
  Set<String> toStop=new HashSet<>(replicatorMap.keySet());
  toStop.removeAll(replicators);
  logger.info("String_Node_Str",toStop);
  for (  String nameToStop : toStop) {
    logger.info("String_Node_Str",nameToStop);
    ChannelReplicator replicator=replicatorMap.remove(nameToStop);
    replicator.stop();
  }
}
Program: 61762
Project: 61762
Buggy source:
@Override public ChannelConfig getChannel(){
  return null;
}

Fixed version (ground truth):
@Override public ChannelConfig getChannel(){
  return channel;
}
Program: 61763
Project: 61763
Buggy source:
public Response toResponse(T exception){
  logger.info(exception.getMessage());
  Response.ResponseBuilder builder=Response.status(this.getResponseCode());
  builder.entity(exception.getMessage());
  return builder.build();
}

Fixed version (ground truth):
public Response toResponse(T exception){
  logger.info(exception.getMessage());
  Response.ResponseBuilder builder=Response.status(this.getResponseCode());
  builder.entity("String_Node_Str");
  return builder.build();
}
Program: 61764
Project: 61764
Buggy source:
public Response toResponse(T exception){
  logger.info(exception.getMessage());
  Response.ResponseBuilder builder=Response.status(this.getResponseCode());
  builder.entity("String_Node_Str");
  return builder.build();
}

Fixed version (ground truth):
public Response toResponse(T exception){
  logger.info(exception.getMessage());
  Response.ResponseBuilder builder=Response.status(this.getResponseCode());
  builder.entity(exception.getMessage());
  return builder.build();
}
Program: 61765
Project: 61765
Buggy source:
@PATCH @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Response updateMetadata(@PathParam("String_Node_Str") String channelName,String json) throws Exception {
  if (noSuchChannel(channelName)) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  ChannelConfig oldConfig=channelService.getChannelConfig(channelName);
  ChannelConfig newConfig=ChannelConfig.builder().withChannelConfiguration(oldConfig).withUpdateJson(json).build();
  newConfig=channelService.updateChannel(newConfig);
  URI channelUri=LinkBuilder.buildChannelUri(newConfig,uriInfo);
  Linked<ChannelConfig> linked=LinkBuilder.buildChannelLinks(newConfig,channelUri);
  return Response.ok(channelUri).entity(linked).build();
}

Fixed version (ground truth):
@PATCH @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Response updateMetadata(@PathParam("String_Node_Str") String channelName,String json) throws Exception {
  ChannelConfig oldConfig=channelService.getChannelConfig(channelName);
  if (oldConfig == null) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  ChannelConfig newConfig=ChannelConfig.builder().withChannelConfiguration(oldConfig).withUpdateJson(json).build();
  newConfig=channelService.updateChannel(newConfig);
  URI channelUri=LinkBuilder.buildChannelUri(newConfig,uriInfo);
  Linked<ChannelConfig> linked=LinkBuilder.buildChannelLinks(newConfig,channelUri);
  return Response.ok(channelUri).entity(linked).build();
}
Program: 61766
Project: 61766
Buggy source:
@GET @Produces(MediaType.APPLICATION_JSON) public Response getChannelMetadata(@PathParam("String_Node_Str") String channelName){
  if (noSuchChannel(channelName)) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  ChannelConfig config=channelService.getChannelConfig(channelName);
  URI channelUri=LinkBuilder.buildChannelUri(config,uriInfo);
  Linked<ChannelConfig> linked=LinkBuilder.buildChannelLinks(config,channelUri);
  return Response.ok(channelUri).entity(linked).build();
}

Fixed version (ground truth):
@GET @Produces(MediaType.APPLICATION_JSON) public Response getChannelMetadata(@PathParam("String_Node_Str") String channelName){
  ChannelConfig config=channelService.getChannelConfig(channelName);
  if (config == null) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  URI channelUri=LinkBuilder.buildChannelUri(config,uriInfo);
  Linked<ChannelConfig> linked=LinkBuilder.buildChannelLinks(config,channelUri);
  return Response.ok(channelUri).entity(linked).build();
}
Program: 61768
Project: 61768
Buggy source:
public String getLatest(String channel,String limitPath){
  String[] split=StringUtils.split(limitPath,"String_Node_Str");
  split=new String[]{split[0],split[1],split[2],split[3],split[4],split[5] + split[6] + split[7]};
  String last=recurseLatest(channel,split,0);
  if (last == null) {
    return null;
  }
  return spokeKeyFromPath(last);
}

Fixed version (ground truth):
public String getLatest(String channel,String limitPath){
  logger.trace("String_Node_Str",channel,limitPath);
  String[] split=StringUtils.split(limitPath,"String_Node_Str");
  split=new String[]{split[0],split[1],split[2],split[3],split[4],split[5] + split[6] + split[7]};
  String last=recurseLatest(channel,split,0,channel);
  if (last == null) {
    return null;
  }
  String latest=spokeKeyFromPath(last);
  logger.trace("String_Node_Str",latest,limitPath);
  return latest;
}
Program: 61769
Project: 61769
Buggy source:
private String recurseLatest(String path,String[] limitPath,int count){
  String base="String_Node_Str";
  String pathname=storagePath + "String_Node_Str" + path;
  String[] items=new File(pathname).list();
  if (items == null) {
    logger.trace("String_Node_Str",pathname);
    return null;
  }
  for (  String item : items) {
    if (item.compareTo(base) > 0 && item.compareTo(limitPath[count]) <= 0) {
      base=item;
    }
  }
  if (base.equals("String_Node_Str")) {
    return null;
  }
  logger.trace("String_Node_Str",count,base,path);
  if (count == 5) {
    return path + "String_Node_Str" + base;
  }
  count++;
  return recurseLatest(path + "String_Node_Str" + base,limitPath,count);
}

Fixed version (ground truth):
private String recurseLatest(String path,String[] limitPath,int count,String channel){
  String base="String_Node_Str";
  String pathname=storagePath + "String_Node_Str" + path;
  String[] items=new File(pathname).list();
  if (items == null) {
    logger.trace("String_Node_Str",pathname);
    return null;
  }
  String limitCompare=channel + "String_Node_Str";
  for (int i=0; i <= count; i++) {
    limitCompare+=limitPath[i] + "String_Node_Str";
  }
  for (  String item : items) {
    if (item.compareTo(base) > 0) {
      if ((path + "String_Node_Str" + item).compareTo(limitCompare) <= 0) {
        base=item;
      }
    }
  }
  if (base.equals("String_Node_Str")) {
    return null;
  }
  logger.trace("String_Node_Str",count,base,path);
  if (count == 5) {
    return path + "String_Node_Str" + base;
  }
  count++;
  return recurseLatest(path + "String_Node_Str" + base,limitPath,count,channel);
}