nus-yam/ex-repair huggingface dataset:
Program: 61819
Project: 61819
Buggy source:
private void replicate(AtomicBoolean hasLeadership){
  long sequence=getLastUpdated();
  if (sequence == ChannelUtils.NOT_FOUND) {
    return;
  }
  logger.info("String_Node_Str" + channel.getUrl() + "String_Node_Str"+ sequence);
  iterator=sequenceIteratorFactory.create(sequence,channel);
  long lastReplicated=0;
  try {
    while (iterator.hasNext() && hasLeadership.get()) {
      Optional<Content> optionalContent=iterator.next();
      if (optionalContent.isPresent()) {
        Content content=optionalContent.get();
        ContentKey key=content.getContentKey().get();
        if (key.getMillis() < lastReplicated) {
          key=new ContentKey(new DateTime(lastReplicated),key.getHash());
          content.setContentKey(key);
        }
        channelService.insert(channel.getName(),content);
        lastReplicated=key.getMillis();
      }
 else {
        logger.warn("String_Node_Str" + channel.getUrl());
      }
    }
  }
  finally {
    logger.info("String_Node_Str" + channel.getUrl() + "String_Node_Str");
    closeIterator();
  }
}

Fixed version (ground truth):
private void replicate(AtomicBoolean hasLeadership){
  long sequence=getLastUpdated();
  if (sequence == ChannelUtils.NOT_FOUND) {
    return;
  }
  logger.info("String_Node_Str" + channel.getUrl() + "String_Node_Str"+ sequence);
  iterator=sequenceIteratorFactory.create(sequence,channel);
  try {
    while (iterator.hasNext() && hasLeadership.get()) {
      Optional<Content> optionalContent=iterator.next();
      if (optionalContent.isPresent()) {
        Content content=optionalContent.get();
        ContentKey nextKey=content.getContentKey().get();
        ContentKey lastCompletedKey=lastContentKey.get(channel.getName(),nextKey,V1_REPLICATE_LAST_COMPLETED);
        if (nextKey.compareTo(lastCompletedKey) < 0) {
          nextKey=new ContentKey(lastCompletedKey.getTime(),nextKey.getHash());
          content.setContentKey(nextKey);
        }
        channelService.insert(channel.getName(),content);
        lastContentKey.updateIncrease(nextKey,channel.getName(),V1_REPLICATE_LAST_COMPLETED);
      }
 else {
        logger.warn("String_Node_Str" + channel.getUrl());
      }
    }
  }
  finally {
    logger.info("String_Node_Str" + channel.getUrl() + "String_Node_Str");
    closeIterator();
  }
}
Program: 61820
Project: 61820
Buggy source:
@Inject public S3WriterManager(ChannelService channelService,@Named(ContentDao.CACHE) ContentDao cacheContentDao,@Named(ContentDao.LONG_TERM) ContentDao longTermContentDao,S3WriteQueue s3WriteQueue){
  this.channelService=channelService;
  this.cacheContentDao=cacheContentDao;
  this.longTermContentDao=longTermContentDao;
  this.s3WriteQueue=s3WriteQueue;
  HubServices.register(new S3WriterManagerService(),HubServices.TYPE.POST_START,HubServices.TYPE.PRE_STOP);
  String host="String_Node_Str";
  try {
    host=InetAddress.getLocalHost().getHostAddress();
  }
 catch (  UnknownHostException e) {
    e.printStackTrace();
  }
  if (host.contains("String_Node_Str")) {
    this.offsetMinutes=HubProperties.getProperty("String_Node_Str",15);
  }
 else   if (host.contains("String_Node_Str")) {
    this.offsetMinutes=HubProperties.getProperty("String_Node_Str",30);
  }
 else   if (host.contains("String_Node_Str")) {
    this.offsetMinutes=HubProperties.getProperty("String_Node_Str",45);
  }
 else {
    this.offsetMinutes=5;
  }
  logger.info("String_Node_Str",this.offsetMinutes);
  queryThreadPool=Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("String_Node_Str").build());
  channelThreadPool=Executors.newFixedThreadPool(10,new ThreadFactoryBuilder().setNameFormat("String_Node_Str").build());
}

Fixed version (ground truth):
@Inject public S3WriterManager(ChannelService channelService,@Named(ContentDao.CACHE) ContentDao cacheContentDao,@Named(ContentDao.LONG_TERM) ContentDao longTermContentDao,S3WriteQueue s3WriteQueue){
  this.channelService=channelService;
  this.cacheContentDao=cacheContentDao;
  this.longTermContentDao=longTermContentDao;
  this.s3WriteQueue=s3WriteQueue;
  HubServices.register(new S3WriterManagerService(),HubServices.TYPE.POST_START,HubServices.TYPE.PRE_STOP);
  String host="String_Node_Str";
  try {
    host=InetAddress.getLocalHost().getHostName();
  }
 catch (  UnknownHostException e) {
    e.printStackTrace();
  }
  this.offsetMinutes=serverOffset(host);
  logger.info("String_Node_Str",host,this.offsetMinutes);
  queryThreadPool=Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("String_Node_Str").build());
  channelThreadPool=Executors.newFixedThreadPool(10,new ThreadFactoryBuilder().setNameFormat("String_Node_Str").build());
}
Program: 61821
Project: 61821
Buggy source:
@Inject public S3WriterManager(ChannelService channelService,@Named(ContentDao.CACHE) ContentDao cacheContentDao,@Named(ContentDao.LONG_TERM) ContentDao longTermContentDao,S3WriteQueue s3WriteQueue){
  this.channelService=channelService;
  this.cacheContentDao=cacheContentDao;
  this.longTermContentDao=longTermContentDao;
  this.s3WriteQueue=s3WriteQueue;
  HubServices.register(new S3WriterManagerService(),HubServices.TYPE.POST_START,HubServices.TYPE.PRE_STOP);
  String host="String_Node_Str";
  try {
    host=InetAddress.getLocalHost().getHostAddress();
  }
 catch (  UnknownHostException e) {
    e.printStackTrace();
  }
  if (host.contains("String_Node_Str")) {
    this.offsetMinutes=HubProperties.getProperty("String_Node_Str",15);
  }
 else   if (host.contains("String_Node_Str")) {
    this.offsetMinutes=HubProperties.getProperty("String_Node_Str",30);
  }
 else   if (host.contains("String_Node_Str")) {
    this.offsetMinutes=HubProperties.getProperty("String_Node_Str",45);
  }
 else {
    this.offsetMinutes=5;
  }
  logger.info("String_Node_Str",this.offsetMinutes);
  queryThreadPool=Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("String_Node_Str").build());
  channelThreadPool=Executors.newFixedThreadPool(10,new ThreadFactoryBuilder().setNameFormat("String_Node_Str").build());
}

Fixed version (ground truth):
@Inject public S3WriterManager(ChannelService channelService,@Named(ContentDao.CACHE) ContentDao cacheContentDao,@Named(ContentDao.LONG_TERM) ContentDao longTermContentDao,S3WriteQueue s3WriteQueue){
  this.channelService=channelService;
  this.cacheContentDao=cacheContentDao;
  this.longTermContentDao=longTermContentDao;
  this.s3WriteQueue=s3WriteQueue;
  HubServices.register(new S3WriterManagerService(),HubServices.TYPE.POST_START,HubServices.TYPE.PRE_STOP);
  String host="String_Node_Str";
  try {
    host=InetAddress.getLocalHost().getHostName();
  }
 catch (  UnknownHostException e) {
    e.printStackTrace();
  }
  this.offsetMinutes=serverOffset(host);
  logger.info("String_Node_Str",host,this.offsetMinutes);
  queryThreadPool=Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("String_Node_Str").build());
  channelThreadPool=Executors.newFixedThreadPool(10,new ThreadFactoryBuilder().setNameFormat("String_Node_Str").build());
}
Program: 61822
Project: 61822
Buggy source:
@Inject public S3WriterManager(ChannelService channelService,@Named(ContentDao.CACHE) ContentDao cacheContentDao,@Named(ContentDao.LONG_TERM) ContentDao longTermContentDao,S3WriteQueue s3WriteQueue){
  this.channelService=channelService;
  this.cacheContentDao=cacheContentDao;
  this.longTermContentDao=longTermContentDao;
  this.s3WriteQueue=s3WriteQueue;
  HubServices.register(new S3WriterManagerService(),HubServices.TYPE.POST_START,HubServices.TYPE.PRE_STOP);
  String host="String_Node_Str";
  try {
    host=InetAddress.getLocalHost().getHostAddress();
  }
 catch (  UnknownHostException e) {
    e.printStackTrace();
  }
  if (host.contains("String_Node_Str")) {
    this.offsetMinutes=HubProperties.getProperty("String_Node_Str",15);
  }
 else   if (host.contains("String_Node_Str")) {
    this.offsetMinutes=HubProperties.getProperty("String_Node_Str",30);
  }
 else   if (host.contains("String_Node_Str")) {
    this.offsetMinutes=HubProperties.getProperty("String_Node_Str",45);
  }
 else {
    this.offsetMinutes=5;
  }
  logger.info("String_Node_Str",this.offsetMinutes);
  queryThreadPool=Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("String_Node_Str").build());
  channelThreadPool=Executors.newFixedThreadPool(10,new ThreadFactoryBuilder().setNameFormat("String_Node_Str").build());
}

Fixed version (ground truth):
@Inject public S3WriterManager(ChannelService channelService,@Named(ContentDao.CACHE) ContentDao cacheContentDao,@Named(ContentDao.LONG_TERM) ContentDao longTermContentDao,S3WriteQueue s3WriteQueue){
  this.channelService=channelService;
  this.cacheContentDao=cacheContentDao;
  this.longTermContentDao=longTermContentDao;
  this.s3WriteQueue=s3WriteQueue;
  HubServices.register(new S3WriterManagerService(),HubServices.TYPE.POST_START,HubServices.TYPE.PRE_STOP);
  String host="String_Node_Str";
  try {
    host=InetAddress.getLocalHost().getHostName();
  }
 catch (  UnknownHostException e) {
    e.printStackTrace();
  }
  this.offsetMinutes=serverOffset(host);
  logger.info("String_Node_Str",host,this.offsetMinutes);
  queryThreadPool=Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("String_Node_Str").build());
  channelThreadPool=Executors.newFixedThreadPool(10,new ThreadFactoryBuilder().setNameFormat("String_Node_Str").build());
}
Program: 61823
Project: 61823
Buggy source:
public long getLastUpdated(){
  Collection<ContentKey> keys=channelService.getKeys(DirectionQuery.builder().contentKey(new ContentKey()).ttlDays(historicalDays).count(1).channelName(channel.getName()).build());
  if (!keys.isEmpty()) {
    ContentKey contentKey=keys.iterator().next();
    try {
      int sequence=Integer.parseInt(contentKey.getHash());
      return sequenceFinder.searchForLastUpdated(channel,sequence,historicalDays + 1,TimeUnit.DAYS);
    }
 catch (    NumberFormatException e) {
      logger.warn("String_Node_Str",contentKey);
    }
  }
  return sequenceFinder.searchForLastUpdated(channel,START_VALUE,historicalDays,TimeUnit.DAYS);
}

Fixed version (ground truth):
public long getLastUpdated(){
  DirectionQuery query=DirectionQuery.builder().contentKey(new ContentKey()).ttlDays(historicalDays).count(1).channelName(channel.getName()).build();
  query.trace(false);
  Collection<ContentKey> keys=channelService.getKeys(query);
  if (!keys.isEmpty()) {
    ContentKey contentKey=keys.iterator().next();
    try {
      int sequence=Integer.parseInt(contentKey.getHash());
      return sequenceFinder.searchForLastUpdated(channel,sequence,historicalDays + 1,TimeUnit.DAYS);
    }
 catch (    NumberFormatException e) {
      logger.warn("String_Node_Str",contentKey);
    }
  }
  return sequenceFinder.searchForLastUpdated(channel,START_VALUE,historicalDays,TimeUnit.DAYS);
}
Program: 61824
Project: 61824
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);
      TimeQuery query=TimeQuery.builder().channelName(channel).startTime(lastQueryTime).unit(unit).build();
      query.trace(false);
      addKeys(channelService.queryByTime(query));
      lastQueryTime=lastQueryTime.plus(unit.getDuration());
    }
 else {
      Duration duration=new Duration(latestStableInChannel,lastQueryTime);
      logger.trace("String_Node_Str" + duration.getMillis());
      Sleeper.sleep(duration.getMillis());
    }
  }
}

Fixed version (ground truth):
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);
      TimeQuery query=TimeQuery.builder().channelName(channel).startTime(lastQueryTime).unit(unit).build();
      query.trace(false);
      addKeys(channelService.queryByTime(query));
      lastQueryTime=lastQueryTime.plus(unit.getDuration());
    }
 else {
      Duration duration=new Duration(latestStableInChannel,lastQueryTime);
      logger.trace("String_Node_Str",duration.getMillis());
      Sleeper.sleep(duration.getMillis());
    }
  }
}
Program: 61825
Project: 61825
Buggy source:
private TimeUtil.Unit getStepUnit(DateTime latestStableInChannel){
  if (lastQueryTime.minusHours(2).isBefore(latestStableInChannel)) {
    return TimeUtil.Unit.HOURS;
  }
 else   if (lastQueryTime.minusMinutes(2).isBefore(latestStableInChannel)) {
    return TimeUtil.Unit.MINUTES;
  }
  return TimeUtil.Unit.SECONDS;
}

Fixed version (ground truth):
private TimeUtil.Unit getStepUnit(DateTime latestStableInChannel){
  if (lastQueryTime.isBefore(latestStableInChannel.minusHours(2))) {
    return TimeUtil.Unit.HOURS;
  }
 else   if (lastQueryTime.isBefore(latestStableInChannel.minusMinutes(2))) {
    return TimeUtil.Unit.MINUTES;
  }
  return TimeUtil.Unit.SECONDS;
}
Program: 61827
Project: 61827
Buggy source:
public long getLastUpdated(){
  Collection<ContentKey> keys=channelService.getKeys(DirectionQuery.builder().contentKey(new ContentKey()).ttlDays(historicalDays).count(1).channelName(channel.getName()).build());
  if (!keys.isEmpty()) {
    ContentKey contentKey=keys.iterator().next();
    try {
      int sequence=Integer.parseInt(contentKey.getHash());
      return sequenceFinder.searchForLastUpdated(channel,sequence,historicalDays + 1,TimeUnit.DAYS);
    }
 catch (    NumberFormatException e) {
      logger.warn("String_Node_Str",contentKey);
    }
  }
  return sequenceFinder.searchForLastUpdated(channel,START_VALUE,historicalDays,TimeUnit.DAYS);
}

Fixed version (ground truth):
public long getLastUpdated(){
  DirectionQuery query=DirectionQuery.builder().contentKey(new ContentKey()).ttlDays(historicalDays).count(1).channelName(channel.getName()).build();
  query.trace(false);
  Collection<ContentKey> keys=channelService.getKeys(query);
  if (!keys.isEmpty()) {
    ContentKey contentKey=keys.iterator().next();
    try {
      int sequence=Integer.parseInt(contentKey.getHash());
      return sequenceFinder.searchForLastUpdated(channel,sequence,historicalDays + 1,TimeUnit.DAYS);
    }
 catch (    NumberFormatException e) {
      logger.warn("String_Node_Str",contentKey);
    }
  }
  return sequenceFinder.searchForLastUpdated(channel,START_VALUE,historicalDays,TimeUnit.DAYS);
}
Program: 61828
Project: 61828
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);
      TimeQuery query=TimeQuery.builder().channelName(channel).startTime(lastQueryTime).unit(unit).build();
      query.trace(false);
      addKeys(channelService.queryByTime(query));
      lastQueryTime=lastQueryTime.plus(unit.getDuration());
    }
 else {
      Duration duration=new Duration(latestStableInChannel,lastQueryTime);
      logger.trace("String_Node_Str" + duration.getMillis());
      Sleeper.sleep(duration.getMillis());
    }
  }
}

Fixed version (ground truth):
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);
      TimeQuery query=TimeQuery.builder().channelName(channel).startTime(lastQueryTime).unit(unit).build();
      query.trace(false);
      addKeys(channelService.queryByTime(query));
      lastQueryTime=lastQueryTime.plus(unit.getDuration());
    }
 else {
      Duration duration=new Duration(latestStableInChannel,lastQueryTime);
      logger.trace("String_Node_Str",duration.getMillis());
      Sleeper.sleep(duration.getMillis());
    }
  }
}
Program: 61829
Project: 61829
Buggy source:
private TimeUtil.Unit getStepUnit(DateTime latestStableInChannel){
  if (lastQueryTime.minusHours(2).isBefore(latestStableInChannel)) {
    return TimeUtil.Unit.HOURS;
  }
 else   if (lastQueryTime.minusMinutes(2).isBefore(latestStableInChannel)) {
    return TimeUtil.Unit.MINUTES;
  }
  return TimeUtil.Unit.SECONDS;
}

Fixed version (ground truth):
private TimeUtil.Unit getStepUnit(DateTime latestStableInChannel){
  if (lastQueryTime.isBefore(latestStableInChannel.minusHours(2))) {
    return TimeUtil.Unit.HOURS;
  }
 else   if (lastQueryTime.isBefore(latestStableInChannel.minusMinutes(2))) {
    return TimeUtil.Unit.MINUTES;
  }
  return TimeUtil.Unit.SECONDS;
}
Program: 61831
Project: 61831
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);
      TimeQuery query=TimeQuery.builder().channelName(channel).startTime(lastQueryTime).unit(unit).build();
      query.trace(false);
      addKeys(channelService.queryByTime(query));
      lastQueryTime=lastQueryTime.plus(unit.getDuration());
    }
 else {
      Duration duration=new Duration(latestStableInChannel,lastQueryTime);
      logger.trace("String_Node_Str" + duration.getMillis());
      Sleeper.sleep(duration.getMillis());
    }
  }
}

Fixed version (ground truth):
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);
      TimeQuery query=TimeQuery.builder().channelName(channel).startTime(lastQueryTime).unit(unit).build();
      query.trace(false);
      addKeys(channelService.queryByTime(query));
      lastQueryTime=lastQueryTime.plus(unit.getDuration());
    }
 else {
      Duration duration=new Duration(latestStableInChannel,lastQueryTime);
      logger.trace("String_Node_Str",duration.getMillis());
      Sleeper.sleep(duration.getMillis());
    }
  }
}
Program: 61832
Project: 61832
Buggy source:
private TimeUtil.Unit getStepUnit(DateTime latestStableInChannel){
  if (lastQueryTime.minusHours(2).isBefore(latestStableInChannel)) {
    return TimeUtil.Unit.HOURS;
  }
 else   if (lastQueryTime.minusMinutes(2).isBefore(latestStableInChannel)) {
    return TimeUtil.Unit.MINUTES;
  }
  return TimeUtil.Unit.SECONDS;
}

Fixed version (ground truth):
private TimeUtil.Unit getStepUnit(DateTime latestStableInChannel){
  if (lastQueryTime.isBefore(latestStableInChannel.minusHours(2))) {
    return TimeUtil.Unit.HOURS;
  }
 else   if (lastQueryTime.isBefore(latestStableInChannel.minusMinutes(2))) {
    return TimeUtil.Unit.MINUTES;
  }
  return TimeUtil.Unit.SECONDS;
}
Program: 61834
Project: 61834
Buggy source:
public long getLastUpdated(){
  Collection<ContentKey> keys=channelService.getKeys(DirectionQuery.builder().contentKey(new ContentKey()).ttlDays(historicalDays).count(1).channelName(channel.getName()).build());
  if (!keys.isEmpty()) {
    ContentKey contentKey=keys.iterator().next();
    try {
      int sequence=Integer.parseInt(contentKey.getHash());
      return sequenceFinder.searchForLastUpdated(channel,sequence,historicalDays + 1,TimeUnit.DAYS);
    }
 catch (    NumberFormatException e) {
      logger.warn("String_Node_Str",contentKey);
    }
  }
  return sequenceFinder.searchForLastUpdated(channel,START_VALUE,historicalDays,TimeUnit.DAYS);
}

Fixed version (ground truth):
public long getLastUpdated(){
  DirectionQuery query=DirectionQuery.builder().contentKey(new ContentKey()).ttlDays(historicalDays).count(1).channelName(channel.getName()).build();
  query.trace(false);
  Collection<ContentKey> keys=channelService.getKeys(query);
  if (!keys.isEmpty()) {
    ContentKey contentKey=keys.iterator().next();
    try {
      int sequence=Integer.parseInt(contentKey.getHash());
      return sequenceFinder.searchForLastUpdated(channel,sequence,historicalDays + 1,TimeUnit.DAYS);
    }
 catch (    NumberFormatException e) {
      logger.warn("String_Node_Str",contentKey);
    }
  }
  return sequenceFinder.searchForLastUpdated(channel,START_VALUE,historicalDays,TimeUnit.DAYS);
}
Program: 61835
Project: 61835
Buggy source:
@Override public SortedSet<ContentKey> query(DirectionQuery query){
  SortedSet<ContentKey> orderedKeys=new TreeSet<>();
  ContentKey startKey=query.getContentKey();
  DateTime startTime=startKey.getTime();
  Collection<ContentKey> queryByTime=queryByTime(query.getChannelName(),startTime,TimeUtil.Unit.DAYS);
  if (queryByTime.size() < query.getCount()) {
    startTime=query.isNext() ? startTime.plusDays(1) : startTime.minusDays(1);
    queryByTime.addAll(queryByTime(query.getChannelName(),startTime,TimeUtil.Unit.DAYS));
  }
  if (query.isNext()) {
    DateTime stableTime=TimeUtil.time(query.isStable());
    for (    ContentKey contentKey : new TreeSet<>(queryByTime)) {
      if (contentKey.compareTo(startKey) > 0 && contentKey.getTime().isBefore(stableTime)) {
        orderedKeys.add(contentKey);
        if (orderedKeys.size() == query.getCount()) {
          return orderedKeys;
        }
      }
    }
  }
 else {
    PreviousUtil.addToPrevious(query,queryByTime,orderedKeys);
  }
  return orderedKeys;
}

Fixed version (ground truth):
private boolean query(DirectionQuery query,SortedSet<ContentKey> orderedKeys,ContentKey startKey,DateTime startTime){
  Collection<ContentKey> queryByTime=queryByTime(query.getChannelName(),startTime,TimeUtil.Unit.DAYS);
  if (query.isNext()) {
    DateTime stableTime=TimeUtil.time(query.isStable());
    for (    ContentKey contentKey : new TreeSet<>(queryByTime)) {
      if (contentKey.compareTo(startKey) > 0 && contentKey.getTime().isBefore(stableTime)) {
        orderedKeys.add(contentKey);
        if (orderedKeys.size() == query.getCount()) {
          return true;
        }
      }
    }
  }
 else {
    PreviousUtil.addToPrevious(query,queryByTime,orderedKeys);
  }
  return false;
}
Program: 61836
Project: 61836
Buggy source:
public void testDirectionQuery() throws Exception {
  String channel="String_Node_Str" + RandomStringUtils.randomAlphanumeric(20);
  List<ContentKey> keys=new ArrayList<>();
  DateTime start=new DateTime(2014,11,14,22,27,DateTimeZone.UTC);
  for (int i=0; i < 7; i++) {
    ContentKey key=new ContentKey(start.plusHours(i),"String_Node_Str" + i);
    keys.add(key);
    logger.info("String_Node_Str" + key);
    contentDao.write(channel,createContent(key));
  }
  logger.info("String_Node_Str",keys.size(),keys);
  query(channel,keys,20,7,true,start.minusMinutes(1));
  query(channel,keys,3,3,true,start.minusMinutes(1));
  query(channel,keys,20,7,false,start.plusHours(8));
  query(channel,keys,3,3,false,start.plusHours(8));
}

Fixed version (ground truth):
public void testDirectionQuery() throws Exception {
  String channel="String_Node_Str" + RandomStringUtils.randomAlphanumeric(20);
  List<ContentKey> keys=new ArrayList<>();
  DateTime start=new DateTime(2014,11,14,22,27,DateTimeZone.UTC);
  for (int i=0; i < 7; i++) {
    ContentKey key=new ContentKey(start.plusHours(i),"String_Node_Str" + i);
    keys.add(key);
    logger.info("String_Node_Str" + key);
    contentDao.write(channel,createContent(key));
  }
  logger.info("String_Node_Str",keys.size(),keys);
  query(channel,keys,20,7,true,start.minusMinutes(1));
  query(channel,keys,3,3,true,start.minusMinutes(1));
  query(channel,keys,20,7,false,start.plusHours(8));
}
Program: 61837
Project: 61837
Buggy source:
@Override public SortedSet<ContentKey> query(DirectionQuery query){
  SortedSet<ContentKey> orderedKeys=new TreeSet<>();
  ContentKey startKey=query.getContentKey();
  DateTime startTime=startKey.getTime();
  Collection<ContentKey> queryByTime=queryByTime(query.getChannelName(),startTime,TimeUtil.Unit.DAYS);
  if (queryByTime.size() < query.getCount()) {
    startTime=query.isNext() ? startTime.plusDays(1) : startTime.minusDays(1);
    queryByTime.addAll(queryByTime(query.getChannelName(),startTime,TimeUtil.Unit.DAYS));
  }
  if (query.isNext()) {
    DateTime stableTime=TimeUtil.time(query.isStable());
    for (    ContentKey contentKey : new TreeSet<>(queryByTime)) {
      if (contentKey.compareTo(startKey) > 0 && contentKey.getTime().isBefore(stableTime)) {
        orderedKeys.add(contentKey);
        if (orderedKeys.size() == query.getCount()) {
          return orderedKeys;
        }
      }
    }
  }
 else {
    PreviousUtil.addToPrevious(query,queryByTime,orderedKeys);
  }
  return orderedKeys;
}

Fixed version (ground truth):
private boolean query(DirectionQuery query,SortedSet<ContentKey> orderedKeys,ContentKey startKey,DateTime startTime){
  Collection<ContentKey> queryByTime=queryByTime(query.getChannelName(),startTime,TimeUtil.Unit.DAYS);
  if (query.isNext()) {
    DateTime stableTime=TimeUtil.time(query.isStable());
    for (    ContentKey contentKey : new TreeSet<>(queryByTime)) {
      if (contentKey.compareTo(startKey) > 0 && contentKey.getTime().isBefore(stableTime)) {
        orderedKeys.add(contentKey);
        if (orderedKeys.size() == query.getCount()) {
          return true;
        }
      }
    }
  }
 else {
    PreviousUtil.addToPrevious(query,queryByTime,orderedKeys);
  }
  return false;
}
Program: 61838
Project: 61838
Buggy source:
public void testDirectionQuery() throws Exception {
  String channel="String_Node_Str" + RandomStringUtils.randomAlphanumeric(20);
  List<ContentKey> keys=new ArrayList<>();
  DateTime start=new DateTime(2014,11,14,22,27,DateTimeZone.UTC);
  for (int i=0; i < 7; i++) {
    ContentKey key=new ContentKey(start.plusHours(i),"String_Node_Str" + i);
    keys.add(key);
    logger.info("String_Node_Str" + key);
    contentDao.write(channel,createContent(key));
  }
  logger.info("String_Node_Str",keys.size(),keys);
  query(channel,keys,20,7,true,start.minusMinutes(1));
  query(channel,keys,3,3,true,start.minusMinutes(1));
  query(channel,keys,20,7,false,start.plusHours(8));
  query(channel,keys,3,3,false,start.plusHours(8));
}

Fixed version (ground truth):
public void testDirectionQuery() throws Exception {
  String channel="String_Node_Str" + RandomStringUtils.randomAlphanumeric(20);
  List<ContentKey> keys=new ArrayList<>();
  DateTime start=new DateTime(2014,11,14,22,27,DateTimeZone.UTC);
  for (int i=0; i < 7; i++) {
    ContentKey key=new ContentKey(start.plusHours(i),"String_Node_Str" + i);
    keys.add(key);
    logger.info("String_Node_Str" + key);
    contentDao.write(channel,createContent(key));
  }
  logger.info("String_Node_Str",keys.size(),keys);
  query(channel,keys,20,7,true,start.minusMinutes(1));
  query(channel,keys,3,3,true,start.minusMinutes(1));
  query(channel,keys,20,7,false,start.plusHours(8));
}
Program: 61839
Project: 61839
Buggy source:
@Override public SortedSet<ContentKey> query(DirectionQuery query){
  SortedSet<ContentKey> orderedKeys=new TreeSet<>();
  ContentKey startKey=query.getContentKey();
  DateTime startTime=startKey.getTime();
  Collection<ContentKey> queryByTime=queryByTime(query.getChannelName(),startTime,TimeUtil.Unit.DAYS);
  if (queryByTime.size() < query.getCount()) {
    startTime=query.isNext() ? startTime.plusDays(1) : startTime.minusDays(1);
    queryByTime.addAll(queryByTime(query.getChannelName(),startTime,TimeUtil.Unit.DAYS));
  }
  if (query.isNext()) {
    DateTime stableTime=TimeUtil.time(query.isStable());
    for (    ContentKey contentKey : new TreeSet<>(queryByTime)) {
      if (contentKey.compareTo(startKey) > 0 && contentKey.getTime().isBefore(stableTime)) {
        orderedKeys.add(contentKey);
        if (orderedKeys.size() == query.getCount()) {
          return orderedKeys;
        }
      }
    }
  }
 else {
    PreviousUtil.addToPrevious(query,queryByTime,orderedKeys);
  }
  return orderedKeys;
}

Fixed version (ground truth):
private boolean query(DirectionQuery query,SortedSet<ContentKey> orderedKeys,ContentKey startKey,DateTime startTime){
  Collection<ContentKey> queryByTime=queryByTime(query.getChannelName(),startTime,TimeUtil.Unit.DAYS);
  if (query.isNext()) {
    DateTime stableTime=TimeUtil.time(query.isStable());
    for (    ContentKey contentKey : new TreeSet<>(queryByTime)) {
      if (contentKey.compareTo(startKey) > 0 && contentKey.getTime().isBefore(stableTime)) {
        orderedKeys.add(contentKey);
        if (orderedKeys.size() == query.getCount()) {
          return true;
        }
      }
    }
  }
 else {
    PreviousUtil.addToPrevious(query,queryByTime,orderedKeys);
  }
  return false;
}
Program: 61840
Project: 61840
Buggy source:
public void testDirectionQuery() throws Exception {
  String channel="String_Node_Str" + RandomStringUtils.randomAlphanumeric(20);
  List<ContentKey> keys=new ArrayList<>();
  DateTime start=new DateTime(2014,11,14,22,27,DateTimeZone.UTC);
  for (int i=0; i < 7; i++) {
    ContentKey key=new ContentKey(start.plusHours(i),"String_Node_Str" + i);
    keys.add(key);
    logger.info("String_Node_Str" + key);
    contentDao.write(channel,createContent(key));
  }
  logger.info("String_Node_Str",keys.size(),keys);
  query(channel,keys,20,7,true,start.minusMinutes(1));
  query(channel,keys,3,3,true,start.minusMinutes(1));
  query(channel,keys,20,7,false,start.plusHours(8));
  query(channel,keys,3,3,false,start.plusHours(8));
}

Fixed version (ground truth):
public void testDirectionQuery() throws Exception {
  String channel="String_Node_Str" + RandomStringUtils.randomAlphanumeric(20);
  List<ContentKey> keys=new ArrayList<>();
  DateTime start=new DateTime(2014,11,14,22,27,DateTimeZone.UTC);
  for (int i=0; i < 7; i++) {
    ContentKey key=new ContentKey(start.plusHours(i),"String_Node_Str" + i);
    keys.add(key);
    logger.info("String_Node_Str" + key);
    contentDao.write(channel,createContent(key));
  }
  logger.info("String_Node_Str",keys.size(),keys);
  query(channel,keys,20,7,true,start.minusMinutes(1));
  query(channel,keys,3,3,true,start.minusMinutes(1));
  query(channel,keys,20,7,false,start.plusHours(8));
}
Program: 61841
Project: 61841
Buggy source:
File adjacentPath(File file,boolean findNext){
  String parentPath=file.getParent();
  File parentFolder=new File(parentPath).getAbsoluteFile();
  File[] files=parentFolder.listFiles();
  if (files == null || files.length == 0)   return null;
  Arrays.sort(files);
  int i=Arrays.binarySearch(files,file);
  File nextPath;
  if (findNext) {
    if (i + 1 < files.length) {
      nextPath=files[i + 1];
    }
 else {
      File adjacentParent=nextPath(parentFolder);
      nextPath=nthFileInFolder(adjacentParent,0);
    }
  }
 else {
    if (i > 0) {
      nextPath=files[i - 1];
    }
 else {
      File adjacentParent=previousPath(parentFolder);
      nextPath=nthFileInFolder(adjacentParent,-1);
    }
  }
  return nextPath;
}

Fixed version (ground truth):
String adjacentPath(String keyPart,boolean findNext){
  File file=spokeFilePathPart(keyPart);
  File parentFolder=file.getParentFile();
  String parentKey=spokeKeyFromFile(parentFolder);
  File[] files=parentFolder.listFiles();
  if (files == null || files.length == 0)   return null;
  Arrays.sort(files);
  int i=Arrays.binarySearch(files,file);
  File nextPath;
  if (findNext) {
    if (i + 1 < files.length) {
      nextPath=files[i + 1];
    }
 else {
      File adjacentParent=spokeFilePathPart(nextPath(parentKey));
      nextPath=nthFileInFolder(adjacentParent,0);
    }
  }
 else {
    if (i > 0) {
      nextPath=files[i - 1];
    }
 else {
      File adjacentParent=spokeFilePathPart(previousPath(parentKey));
      nextPath=nthFileInFolder(adjacentParent,-1);
    }
  }
  return spokeKeyFromFile(nextPath);
}
Program: 61842
Project: 61842
Buggy source:
Collection<File> adjacentNFiles(File path,int count,boolean next){
  path=next ? nextPath(path) : previousPath(path);
  if (path == null)   return new ArrayList<>(0);
  File hourPath=SpokePathUtil.hourPathFolder(path);
  Collection<File> hourFiles=filesInBucket(hourPath,SpokePathUtil.second(path.getAbsolutePath()));
  File[] hourFileArray=new File[hourFiles.size()];
  hourFileArray=hourFiles.toArray(hourFileArray);
  Arrays.sort(hourFileArray);
  File[] adjacentFiles;
  int i=Arrays.binarySearch(hourFileArray,path);
  if (next) {
    int nextCompliment=hourFileArray.length - i;
    int to=nextCompliment > count ? i + count : hourFileArray.length - 1;
    to=to == i ? to + 1 : to;
    adjacentFiles=Arrays.copyOfRange(hourFileArray,i,to);
  }
 else {
    int from=i < count ? 0 : i - count;
    i=from == i ? i + 1 : i;
    adjacentFiles=Arrays.copyOfRange(hourFileArray,from,i);
  }
  Arrays.sort(adjacentFiles);
  ArrayList<File> result=new ArrayList<>();
  List<File> temp=Arrays.asList((File[])adjacentFiles);
  result.addAll(temp);
  if (adjacentFiles.length == count)   return result;
  File nextPath=next ? Iterables.getLast(result,null) : Iterables.getFirst(result,null);
  result.addAll(adjacentNFiles(nextPath,count - result.size(),next));
  return result;
}

Fixed version (ground truth):
Collection<File> adjacentNFiles(File path,int count,boolean next){
  String key=spokeKeyFromFile(path);
  key=next ? nextPath(key) : previousPath(key);
  if (key == null)   return new ArrayList<>(0);
  File hourPath=SpokePathUtil.hourPathFolder(spokeFilePathPart(key));
  Collection<File> hourFiles=filesInBucket(hourPath,SpokePathUtil.second(path.getAbsolutePath()));
  File[] hourFileArray=new File[hourFiles.size()];
  hourFileArray=hourFiles.toArray(hourFileArray);
  Arrays.sort(hourFileArray);
  File[] adjacentFiles;
  File searchForThisFile=spokeFilePathPart(key);
  int i=Arrays.binarySearch(hourFileArray,searchForThisFile);
  if (next) {
    int nextCompliment=hourFileArray.length - i;
    int to=nextCompliment > count ? i + count : hourFileArray.length - 1;
    to=to == i ? to + 1 : to;
    adjacentFiles=Arrays.copyOfRange(hourFileArray,i,to);
  }
 else {
    int from=i < count ? 0 : i - count;
    i=from == i ? i + 1 : i;
    adjacentFiles=Arrays.copyOfRange(hourFileArray,from,i);
  }
  Arrays.sort(adjacentFiles);
  ArrayList<File> result=new ArrayList<>();
  List<File> temp=Arrays.asList((File[])adjacentFiles);
  result.addAll(temp);
  if (adjacentFiles.length == count)   return result;
  File nextPath=next ? Iterables.getLast(result,null) : Iterables.getFirst(result,null);
  result.addAll(adjacentNFiles(nextPath,count - result.size(),next));
  return result;
}
Program: 61843
Project: 61843
Buggy source:
public String previousPath(String path){
  return spokeKeyFromFile(previousPath(spokeFilePathPart(path)));
}

Fixed version (ground truth):
String previousPath(String path){
  return adjacentPath(path,false);
}
Program: 61844
Project: 61844
Buggy source:
public String nextPath(String path){
  return spokeKeyFromFile(nextPath(spokeFilePathPart(path)));
}

Fixed version (ground truth):
String nextPath(String path){
  return adjacentPath(path,true);
}
Program: 61846
Project: 61846
Buggy source:
public String readKeysInBucket(String path){
  String seconds=SpokePathUtil.second(path);
  Collection<File> files=filesInBucket(spokeFilePathPart(path),seconds);
  String keys="String_Node_Str";
  int i=0;
  for (  File file : files) {
    keys+=spokeKeyFromFile(file);
    if (i < files.size() - 1) {
      keys+="String_Node_Str";
      i++;
    }
  }
  return keys;
}

Fixed version (ground truth):
public String readKeysInBucket(String path){
  Collection<String> keys=keysInBucket(path);
  return StringUtils.join(keys,"String_Node_Str");
}
Program: 61847
Project: 61847
Buggy source:
@Test public void testAdjacentPaths() throws Exception {
  String previousSecond="String_Node_Str";
  String path1="String_Node_Str";
  File path1File=makeFile(path1);
  String path2="String_Node_Str";
  File path2File=makeFile(path2);
  String path3="String_Node_Str";
  File path3File=makeFile(path3);
  String nextSecond="String_Node_Str";
  File nextSecondFile=makeFile(nextSecond);
  spokeStore.write(path1,BYTES);
  spokeStore.write(path2,BYTES);
  spokeStore.write(path3,BYTES);
  spokeStore.write(previousSecond,BYTES);
  spokeStore.write(nextSecond,BYTES);
  assertEquals(path3,spokeStore.nextPath(path2));
  assertEquals(path1,spokeStore.previousPath(path2));
  String previousMillisecond="String_Node_Str";
  spokeStore.write(previousMillisecond,BYTES);
  String nextMillisecond="String_Node_Str";
  spokeStore.write(nextMillisecond,BYTES);
  assertEquals(spokeStore.nextPath(path3),nextMillisecond);
  assertEquals(spokeStore.previousPath(path1),previousMillisecond);
  Collection<File> files=spokeStore.filesInBucket(new File(tempDir + "String_Node_Str"),null);
  assertEquals(7,files.size());
  logger.info("String_Node_Str" + files);
  assertTrue(files.contains(path1File));
  assertTrue(files.contains(path2File));
  assertTrue(files.contains(path3File));
  files=spokeStore.filesInBucket(spokeStore.spokeFilePathPart("String_Node_Str"),"String_Node_Str");
  assertEquals(5,files.size());
  files=spokeStore.nextNKeys(path1File,2);
  assertEquals(2,files.size());
  assertTrue(files.contains(path2File));
  assertTrue(files.contains(path3File));
  String nexthour1="String_Node_Str";
  spokeStore.write(nexthour1,BYTES);
  File nexthour1File=makeFile(nexthour1);
  assertEquals(nexthour1,spokeStore.nextPath(nextSecond));
}

Fixed version (ground truth):
@Test public void testAdjacentPaths() throws Exception {
  String previousSecond="String_Node_Str";
  String path1="String_Node_Str";
  File path1File=makeFile(path1);
  String path2="String_Node_Str";
  File path2File=makeFile(path2);
  String path3="String_Node_Str";
  File path3File=makeFile(path3);
  String nextSecond="String_Node_Str";
  File nextSecondFile=makeFile(nextSecond);
  spokeStore.write(path1,BYTES);
  spokeStore.write(path2,BYTES);
  spokeStore.write(path3,BYTES);
  spokeStore.write(previousSecond,BYTES);
  spokeStore.write(nextSecond,BYTES);
  assertEquals(path3,spokeStore.nextPath(path2));
  assertEquals(path1,spokeStore.previousPath(path2));
  String previousMillisecond="String_Node_Str";
  spokeStore.write(previousMillisecond,BYTES);
  String nextMillisecond="String_Node_Str";
  spokeStore.write(nextMillisecond,BYTES);
  assertEquals(spokeStore.nextPath(path3),nextMillisecond);
  assertEquals(spokeStore.previousPath(path1),previousMillisecond);
  Collection<String> keys=spokeStore.keysInBucket("String_Node_Str");
  assertEquals(7,keys.size());
  logger.info("String_Node_Str" + keys);
  assertTrue(keys.contains(path1));
  assertTrue(keys.contains(path2));
  assertTrue(keys.contains(path3));
  keys=spokeStore.keysInBucket("String_Node_Str");
  assertEquals(5,keys.size());
}
Program: 61848
Project: 61848
Buggy source:
public String readKeysInBucket(String path){
  String seconds=SpokePathUtil.second(path);
  Collection<File> files=filesInBucket(spokeFilePathPart(path),seconds);
  String keys="String_Node_Str";
  int i=0;
  for (  File file : files) {
    keys+=spokeKeyFromFile(file);
    if (i < files.size() - 1) {
      keys+="String_Node_Str";
      i++;
    }
  }
  return keys;
}

Fixed version (ground truth):
public String readKeysInBucket(String path){
  Collection<String> keys=keysInBucket(path);
  return StringUtils.join(keys,"String_Node_Str");
}
Program: 61849
Project: 61849
Buggy source:
@Test public void testAdjacentPaths() throws Exception {
  String previousSecond="String_Node_Str";
  String path1="String_Node_Str";
  File path1File=makeFile(path1);
  String path2="String_Node_Str";
  File path2File=makeFile(path2);
  String path3="String_Node_Str";
  File path3File=makeFile(path3);
  String nextSecond="String_Node_Str";
  File nextSecondFile=makeFile(nextSecond);
  spokeStore.write(path1,BYTES);
  spokeStore.write(path2,BYTES);
  spokeStore.write(path3,BYTES);
  spokeStore.write(previousSecond,BYTES);
  spokeStore.write(nextSecond,BYTES);
  assertEquals(path3,spokeStore.nextPath(path2));
  assertEquals(path1,spokeStore.previousPath(path2));
  String previousMillisecond="String_Node_Str";
  spokeStore.write(previousMillisecond,BYTES);
  String nextMillisecond="String_Node_Str";
  spokeStore.write(nextMillisecond,BYTES);
  assertEquals(spokeStore.nextPath(path3),nextMillisecond);
  assertEquals(spokeStore.previousPath(path1),previousMillisecond);
  Collection<File> files=spokeStore.filesInBucket(new File(tempDir + "String_Node_Str"),null);
  assertEquals(7,files.size());
  logger.info("String_Node_Str" + files);
  assertTrue(files.contains(path1File));
  assertTrue(files.contains(path2File));
  assertTrue(files.contains(path3File));
  files=spokeStore.filesInBucket(spokeStore.spokeFilePathPart("String_Node_Str"),"String_Node_Str");
  assertEquals(5,files.size());
  files=spokeStore.nextNKeys(path1File,2);
  assertEquals(2,files.size());
  assertTrue(files.contains(path2File));
  assertTrue(files.contains(path3File));
  String nexthour1="String_Node_Str";
  spokeStore.write(nexthour1,BYTES);
  File nexthour1File=makeFile(nexthour1);
  assertEquals(nexthour1,spokeStore.nextPath(nextSecond));
}

Fixed version (ground truth):
@Test public void testAdjacentPaths() throws Exception {
  String previousSecond="String_Node_Str";
  String path1="String_Node_Str";
  File path1File=makeFile(path1);
  String path2="String_Node_Str";
  File path2File=makeFile(path2);
  String path3="String_Node_Str";
  File path3File=makeFile(path3);
  String nextSecond="String_Node_Str";
  File nextSecondFile=makeFile(nextSecond);
  spokeStore.write(path1,BYTES);
  spokeStore.write(path2,BYTES);
  spokeStore.write(path3,BYTES);
  spokeStore.write(previousSecond,BYTES);
  spokeStore.write(nextSecond,BYTES);
  assertEquals(path3,spokeStore.nextPath(path2));
  assertEquals(path1,spokeStore.previousPath(path2));
  String previousMillisecond="String_Node_Str";
  spokeStore.write(previousMillisecond,BYTES);
  String nextMillisecond="String_Node_Str";
  spokeStore.write(nextMillisecond,BYTES);
  assertEquals(spokeStore.nextPath(path3),nextMillisecond);
  assertEquals(spokeStore.previousPath(path1),previousMillisecond);
  Collection<String> keys=spokeStore.keysInBucket("String_Node_Str");
  assertEquals(7,keys.size());
  logger.info("String_Node_Str" + keys);
  assertTrue(keys.contains(path1));
  assertTrue(keys.contains(path2));
  assertTrue(keys.contains(path3));
  keys=spokeStore.keysInBucket("String_Node_Str");
  assertEquals(5,keys.size());
}
Program: 61850
Project: 61850
Buggy source:
public String readKeysInBucket(String path){
  String seconds=SpokePathUtil.second(path);
  Collection<File> files=filesInBucket(spokeFilePathPart(path),seconds);
  String keys="String_Node_Str";
  int i=0;
  for (  File file : files) {
    keys+=spokeKeyFromFile(file);
    if (i < files.size() - 1) {
      keys+="String_Node_Str";
      i++;
    }
  }
  return keys;
}

Fixed version (ground truth):
public String readKeysInBucket(String path){
  Collection<String> keys=keysInBucket(path);
  return StringUtils.join(keys,"String_Node_Str");
}
Program: 61851
Project: 61851
Buggy source:
@Test public void testAdjacentPaths() throws Exception {
  String previousSecond="String_Node_Str";
  String path1="String_Node_Str";
  File path1File=makeFile(path1);
  String path2="String_Node_Str";
  File path2File=makeFile(path2);
  String path3="String_Node_Str";
  File path3File=makeFile(path3);
  String nextSecond="String_Node_Str";
  File nextSecondFile=makeFile(nextSecond);
  spokeStore.write(path1,BYTES);
  spokeStore.write(path2,BYTES);
  spokeStore.write(path3,BYTES);
  spokeStore.write(previousSecond,BYTES);
  spokeStore.write(nextSecond,BYTES);
  assertEquals(path3,spokeStore.nextPath(path2));
  assertEquals(path1,spokeStore.previousPath(path2));
  String previousMillisecond="String_Node_Str";
  spokeStore.write(previousMillisecond,BYTES);
  String nextMillisecond="String_Node_Str";
  spokeStore.write(nextMillisecond,BYTES);
  assertEquals(spokeStore.nextPath(path3),nextMillisecond);
  assertEquals(spokeStore.previousPath(path1),previousMillisecond);
  Collection<File> files=spokeStore.filesInBucket(new File(tempDir + "String_Node_Str"),null);
  assertEquals(7,files.size());
  logger.info("String_Node_Str" + files);
  assertTrue(files.contains(path1File));
  assertTrue(files.contains(path2File));
  assertTrue(files.contains(path3File));
  files=spokeStore.filesInBucket(spokeStore.spokeFilePathPart("String_Node_Str"),"String_Node_Str");
  assertEquals(5,files.size());
  files=spokeStore.nextNKeys(path1File,2);
  assertEquals(2,files.size());
  assertTrue(files.contains(path2File));
  assertTrue(files.contains(path3File));
  String nexthour1="String_Node_Str";
  spokeStore.write(nexthour1,BYTES);
  File nexthour1File=makeFile(nexthour1);
  assertEquals(nexthour1,spokeStore.nextPath(nextSecond));
}

Fixed version (ground truth):
@Test public void testAdjacentPaths() throws Exception {
  String previousSecond="String_Node_Str";
  String path1="String_Node_Str";
  File path1File=makeFile(path1);
  String path2="String_Node_Str";
  File path2File=makeFile(path2);
  String path3="String_Node_Str";
  File path3File=makeFile(path3);
  String nextSecond="String_Node_Str";
  File nextSecondFile=makeFile(nextSecond);
  spokeStore.write(path1,BYTES);
  spokeStore.write(path2,BYTES);
  spokeStore.write(path3,BYTES);
  spokeStore.write(previousSecond,BYTES);
  spokeStore.write(nextSecond,BYTES);
  assertEquals(path3,spokeStore.nextPath(path2));
  assertEquals(path1,spokeStore.previousPath(path2));
  String previousMillisecond="String_Node_Str";
  spokeStore.write(previousMillisecond,BYTES);
  String nextMillisecond="String_Node_Str";
  spokeStore.write(nextMillisecond,BYTES);
  assertEquals(spokeStore.nextPath(path3),nextMillisecond);
  assertEquals(spokeStore.previousPath(path1),previousMillisecond);
  Collection<String> keys=spokeStore.keysInBucket("String_Node_Str");
  assertEquals(7,keys.size());
  logger.info("String_Node_Str" + keys);
  assertTrue(keys.contains(path1));
  assertTrue(keys.contains(path2));
  assertTrue(keys.contains(path3));
  keys=spokeStore.keysInBucket("String_Node_Str");
  assertEquals(5,keys.size());
}
Program: 61852
Project: 61852
Buggy source:
File adjacentPath(File file,boolean findNext){
  String parentPath=file.getParent();
  File parentFolder=new File(parentPath).getAbsoluteFile();
  File[] files=parentFolder.listFiles();
  if (files == null || files.length == 0)   return null;
  Arrays.sort(files);
  int i=Arrays.binarySearch(files,file);
  File nextPath;
  if (findNext) {
    if (i + 1 < files.length) {
      nextPath=files[i + 1];
    }
 else {
      File adjacentParent=nextPath(parentFolder);
      nextPath=nthFileInFolder(adjacentParent,0);
    }
  }
 else {
    if (i > 0) {
      nextPath=files[i - 1];
    }
 else {
      File adjacentParent=previousPath(parentFolder);
      nextPath=nthFileInFolder(adjacentParent,-1);
    }
  }
  return nextPath;
}

Fixed version (ground truth):
String adjacentPath(String keyPart,boolean findNext){
  File file=spokeFilePathPart(keyPart);
  File parentFolder=file.getParentFile();
  String parentKey=spokeKeyFromFile(parentFolder);
  File[] files=parentFolder.listFiles();
  if (files == null || files.length == 0)   return null;
  Arrays.sort(files);
  int i=Arrays.binarySearch(files,file);
  File nextPath;
  if (findNext) {
    if (i + 1 < files.length) {
      nextPath=files[i + 1];
    }
 else {
      File adjacentParent=spokeFilePathPart(nextPath(parentKey));
      nextPath=nthFileInFolder(adjacentParent,0);
    }
  }
 else {
    if (i > 0) {
      nextPath=files[i - 1];
    }
 else {
      File adjacentParent=spokeFilePathPart(previousPath(parentKey));
      nextPath=nthFileInFolder(adjacentParent,-1);
    }
  }
  return spokeKeyFromFile(nextPath);
}