nus-yam/ex-repair huggingface dataset:
Program: 33704
Project: 33704
Buggy source:
@Test public void testIsMetByShouldReturnTrueWhenTheCriterionIsMetEvenForCriteriaThatCrossMidnight() throws Exception {
  TimeVisibilityCriterion criterion=new TimeVisibilityCriterion(18,6);
  for (int i=0; i < 12; i++) {
    Mockito.when(world.getWorldDate()).thenReturn(new Date(1,1,1,(i + 18) % 24,0,0));
    Assert.assertTrue(criterion.isMetBy(observer));
  }
}

Fixed version (ground truth):
@Test public void testIsMetByShouldReturnTrueWhenTheCriterionIsMetEvenForCriteriaThatCrossMidnight() throws Exception {
  for (int begin=1; begin < HOURS_IN_DAY; begin++) {
    for (int end=0; end < begin; end++) {
      TimeVisibilityCriterion criterion=new TimeVisibilityCriterion(begin,end);
      for (int hour=begin; hour != end; hour=(hour + 1) % HOURS_IN_DAY) {
        Date date=new Date(1,1,1,hour,0,0);
        Mockito.when(world.getWorldDate()).thenReturn(date);
        Assert.assertTrue(criterion.isMetBy(observer));
      }
    }
  }
}
Program: 33705
Project: 33705
Buggy source:
@Test public void testIsMetByShouldReturnFalseWhenTheCriterionIsUnmetEvenForCriteriaThatCrossMidnight() throws Exception {
  TimeVisibilityCriterion criterion=new TimeVisibilityCriterion(18,6);
  for (int i=0; i < 12; i++) {
    Mockito.when(world.getWorldDate()).thenReturn(new Date(1,1,1,(i + 6) % 24,0,0));
    Assert.assertFalse(criterion.isMetBy(observer));
  }
}

Fixed version (ground truth):
@Test public void testIsMetByShouldReturnFalseWhenTheCriterionIsUnmetEvenForCriteriaThatCrossMidnight() throws Exception {
  for (int begin=1; begin < HOURS_IN_DAY; begin++) {
    for (int end=0; end < begin; end++) {
      TimeVisibilityCriterion criterion=new TimeVisibilityCriterion(begin,end);
      for (int hour=end; hour != begin; hour=(hour + 1) % HOURS_IN_DAY) {
        Date date=new Date(1,1,1,hour,0,0);
        Mockito.when(world.getWorldDate()).thenReturn(date);
        Assert.assertFalse(criterion.isMetBy(observer));
      }
    }
  }
}
Program: 33706
Project: 33706
Buggy source:
@Test public void testIsMetByShouldReturnFalseWhenTheCriterionIsUnmet() throws Exception {
  TimeVisibilityCriterion criterion=new TimeVisibilityCriterion(6,18);
  for (int i=0; i < 12; i++) {
    Mockito.when(world.getWorldDate()).thenReturn(new Date(1,1,1,(i + 18) % 24,0,0));
    Assert.assertFalse(criterion.isMetBy(observer));
  }
}

Fixed version (ground truth):
@Test public void testIsMetByShouldReturnFalseWhenTheCriterionIsUnmet() throws Exception {
  TimeVisibilityCriterion criterion=new TimeVisibilityCriterion(6,18);
  for (int i=0; i < 12; i++) {
    Mockito.when(world.getWorldDate()).thenReturn(new Date(1,1,1,(i + 18) % HOURS_IN_DAY,0,0));
    Assert.assertFalse(criterion.isMetBy(observer));
  }
}
Program: 33707
Project: 33707
Buggy source:
/** 
 * Generates a new random date of birth.
 */
public Date generateDateOfBirth(){
  Date minimumDate=today.minus(age + 1,DungeonTimeUnit.YEAR).plus(1,DungeonTimeUnit.SECOND);
  int secondsInYear=DungeonMath.safeCastLongToInteger(DungeonTimeUnit.YEAR.as(DungeonTimeUnit.SECOND));
  return minimumDate.plus(Random.nextInteger(secondsInYear),DungeonTimeUnit.SECOND);
}

Fixed version (ground truth):
/** 
 * Generates a new random date of birth.
 */
public Date generateDateOfBirth(){
  Date minimumDate=today.minus(age + 1,DungeonTimeUnit.YEAR).plus(1,DungeonTimeUnit.SECOND);
  int secondsInYear=DungeonMath.safeCastLongToInteger(DungeonTimeUnit.YEAR.as(DungeonTimeUnit.SECOND));
  return minimumDate.plus(Random.nextInteger(secondsInYear - 1) + 1,DungeonTimeUnit.SECOND);
}
Program: 33709
Project: 33709
Buggy source:
private static void logInstanceClosing(){
  String durationString=instanceInformation.getDurationString();
  long commandCount=instanceInformation.getAcceptedCommandCount();
  DungeonLogger.info("String_Node_Str" + durationString + "String_Node_Str"+ commandCount+ "String_Node_Str");
}

Fixed version (ground truth):
private static void logInstanceClosing(){
  String durationString=instanceInformation.getDurationString();
  int commandCount=instanceInformation.getAcceptedCommandCount();
  DungeonLogger.info("String_Node_Str" + durationString + "String_Node_Str"+ commandCount+ "String_Node_Str");
}
Program: 33710
Project: 33710
Buggy source:
public long getAcceptedCommandCount(){
  return acceptedCommandCount;
}

Fixed version (ground truth):
public int getAcceptedCommandCount(){
  return acceptedCommandCount;
}
Program: 33711
Project: 33711
Buggy source:
/** 
 * Refreshes all relevant Spawners in the world, currently, that is the spawner of the location the Hero is at.
 */
private static void refreshSpawners(){
  Game.getGameState().getHeroLocation().refreshSpawners();
}

Fixed version (ground truth):
/** 
 * Refreshes all relevant Spawners in the world, currently, that is the spawners of the location the Hero is at.
 */
private static void refreshSpawners(){
  Game.getGameState().getHeroLocation().refreshSpawners();
}
Program: 33712
Project: 33712
Buggy source:
/** 
 * Refreshes all the items in the location the Hero is in. This includes all the items in the location's inventory and all the items in the inventories of the creatures in this location.
 */
private static void refreshItems(){
  Game.getGameState().getHeroLocation().refreshItems();
}

Fixed version (ground truth):
/** 
 * Refreshes all the items in the location the Hero is at.
 */
private static void refreshItems(){
  Game.getGameState().getHeroLocation().refreshItems();
}
Program: 33713
Project: 33713
Buggy source:
/** 
 * Iterates over all achievements in GameData, trying to unlock yet to be unlocked achievements.
 */
private static void refreshAchievements(){
  Hero hero=Game.getGameState().getHero();
  hero.getAchievementTracker().update(GameData.ACHIEVEMENTS.values());
}

Fixed version (ground truth):
/** 
 * Iterates over all achievements in GameData, trying to unlock yet to be unlocked achievements.
 */
private static void refreshAchievements(){
  Game.getGameState().getHero().getAchievementTracker().update(GameData.ACHIEVEMENTS.values());
}
Program: 33714
Project: 33714
Buggy source:
/** 
 * Sets a new GameState to the static field. Can be used to nullify the GameState, something that should be done while another GameState is being created. If the provided GameState is not null, this setter also invokes Hero.look().
 * @param state another GameState object, or null
 */
public static void setGameState(GameState state){
  gameState=state;
  if (state == null) {
    DLogger.info("String_Node_Str");
  }
 else {
    DLogger.info("String_Node_Str");
    IO.writeNewLine();
    gameState.getHero().look(null);
  }
}

Fixed version (ground truth):
/** 
 * Sets a new GameState to the static field. Can be used to nullify the GameState, something that should be done while another GameState is being created. If the provided GameState is not null, this setter also invokes Hero.look().
 * @param state another GameState object, or null
 */
public static void setGameState(GameState state){
  gameState=state;
  if (state == null) {
    DLogger.info("String_Node_Str");
  }
 else {
    DLogger.info("String_Node_Str");
    Engine.refresh();
    IO.writeNewLine();
    gameState.getHero().look(null);
  }
}
Program: 33715
Project: 33715
Buggy source:
/** 
 * Finds matches of   {@code Selectable}s based on a given   {@code Collection} of objects and an array of search tokens.
 * @param collection a {@code Collection} of {@code Selectable} objects
 * @param complete   if true, only elements that match all tokens are returned
 * @param tokens     the search Strings
 * @param < T >        a type T that extends {@code Selectable}
 * @return a {@code Matches} object with zero or more elements of type T
 */
private static <T extends Selectable>Matches<T> findMatches(Collection<T> collection,boolean complete,String... tokens){
  List<T> listOfMatches=new ArrayList<T>();
  double maximumSimilarity=1e-6;
  for (  T candidate : collection) {
    String[] titleWords=split(candidate.getName().getSingular());
    int matches=countMatches(tokens,titleWords);
    if (!complete || matches == tokens.length) {
      double matchesOverTitleWords=matches / (double)titleWords.length;
      double matchesOverSearchArgs=matches / (double)tokens.length;
      double similarity=DungeonMath.mean(matchesOverTitleWords,matchesOverSearchArgs);
      int comparisonResult=DungeonMath.fuzzyCompare(similarity,maximumSimilarity);
      if (comparisonResult > 0) {
        maximumSimilarity=similarity;
        listOfMatches.clear();
        listOfMatches.add(candidate);
      }
 else       if (comparisonResult == 0) {
        listOfMatches.add(candidate);
      }
    }
  }
  return Matches.fromCollection(listOfMatches);
}

Fixed version (ground truth):
/** 
 * Finds matches of   {@code Selectable}s based on a given   {@code Collection} of objects and an array of search tokens.
 * @param collection a {@code Collection} of {@code Selectable} objects
 * @param complete   if true, only elements that match all tokens are returned
 * @param tokens     the search Strings
 * @param < T >        a type T that extends {@code Selectable}
 * @return a {@code Matches} object with zero or more elements of type T
 */
private static <T extends Selectable>Matches<T> findMatches(Collection<T> collection,boolean complete,String... tokens){
  List<T> listOfMatches=new ArrayList<T>();
  double maximumSimilarity=1e-6;
  for (  T candidate : collection) {
    String[] titleWords=split(candidate.getName().getSingular());
    int matches=countMatches(tokens,titleWords);
    if (!complete || matches >= tokens.length) {
      double matchesOverTitleWords=matches / (double)titleWords.length;
      double matchesOverSearchArgs=matches / (double)tokens.length;
      double similarity=DungeonMath.mean(matchesOverTitleWords,matchesOverSearchArgs);
      int comparisonResult=DungeonMath.fuzzyCompare(similarity,maximumSimilarity);
      if (comparisonResult > 0) {
        maximumSimilarity=similarity;
        listOfMatches.clear();
        listOfMatches.add(candidate);
      }
 else       if (comparisonResult == 0) {
        listOfMatches.add(candidate);
      }
    }
  }
  return Matches.fromCollection(listOfMatches);
}
Program: 33717
Project: 33717
Buggy source:
@Override public int compare(File o1,File o2){
  return Long.compare(o2.lastModified(),o1.lastModified());
}

Fixed version (ground truth):
@Override public int compare(File a,File b){
  return Long.valueOf(b.lastModified()).compareTo(a.lastModified());
}
Program: 33718
Project: 33718
Buggy source:
private static void sortFileArrayByLastModifiedDate(@NotNull File[] array){
  Arrays.sort(array,new Comparator<File>(){
    @Override public int compare(    File o1,    File o2){
      return Long.compare(o2.lastModified(),o1.lastModified());
    }
  }
);
}

Fixed version (ground truth):
private static void sortFileArrayByLastModifiedDate(@NotNull File[] array){
  Arrays.sort(array,new Comparator<File>(){
    @Override public int compare(    File a,    File b){
      return Long.valueOf(b.lastModified()).compareTo(a.lastModified());
    }
  }
);
}
Program: 33719
Project: 33719
Buggy source:
/** 
 * Makes the Hero read the current date and time as well as he can.
 */
public void readTime(){
  Item clock=getBestClock();
  if (clock != null) {
    IO.writeString(clock.getClockComponent().getTimeString());
    if (getWeapon() == clock) {
      Engine.rollDateAndRefresh(SECONDS_TO_READ_EQUIPPED_CLOCK);
    }
 else {
      Engine.rollDateAndRefresh(SECONDS_TO_READ_UNEQUIPPED_CLOCK);
    }
  }
  World world=getLocation().getWorld();
  Date worldDate=getLocation().getWorld().getWorldDate();
  IO.writeString("String_Node_Str" + worldDate.toDateString() + "String_Node_Str");
  if (worldDate.getMonth() == dateOfBirth.getMonth() && worldDate.getDay() == dateOfBirth.getDay()) {
    IO.writeString("String_Node_Str");
  }
  IO.writeString("String_Node_Str" + world.getPartOfDay().toString().toLowerCase() + "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Makes the Hero read the current date and time as well as he can.
 */
public void readTime(){
  Item clock=getBestClock();
  if (clock != null) {
    IO.writeString(clock.getClockComponent().getTimeString());
    Engine.rollDateAndRefresh(getTimeToReadFromClock(clock));
  }
  World world=getLocation().getWorld();
  Date worldDate=getLocation().getWorld().getWorldDate();
  IO.writeString("String_Node_Str" + worldDate.toDateString() + "String_Node_Str");
  if (worldDate.getMonth() == dateOfBirth.getMonth() && worldDate.getDay() == dateOfBirth.getDay()) {
    IO.writeString("String_Node_Str");
  }
  IO.writeString("String_Node_Str" + world.getPartOfDay().toString().toLowerCase() + "String_Node_Str");
}
Program: 33720
Project: 33720
Buggy source:
/** 
 * Gets the easiest-to-access unbroken clock of the Hero. If the Hero has no unbroken clock, the easiest-to-access broken clock. Lastly, if the Hero does not have a clock at all, null is returned.
 * @return an Item object of the clock Item (or null)
 */
@Nullable private Item getBestClock(){
  Item clock=null;
  if (hasWeapon() && getWeapon().hasTag(Item.Tag.CLOCK)) {
    if (!getWeapon().isBroken()) {
      clock=getWeapon();
    }
 else {
      for (      Item item : getInventory().getItems()) {
        if (item.hasTag(Item.Tag.CLOCK) && !item.isBroken()) {
          clock=item;
          break;
        }
      }
      if (clock == null) {
        clock=getWeapon();
      }
    }
  }
 else {
    Item brokenClock=null;
    for (    Item item : getInventory().getItems()) {
      if (item.hasTag(Item.Tag.CLOCK)) {
        if (item.isBroken() && brokenClock == null) {
          brokenClock=item;
        }
 else {
          clock=item;
          break;
        }
      }
    }
    if (brokenClock != null) {
      clock=brokenClock;
    }
  }
  int timeSpent;
  if (clock == null) {
    timeSpent=0;
  }
 else   if (clock == getWeapon()) {
    timeSpent=SECONDS_TO_READ_EQUIPPED_CLOCK;
  }
 else {
    timeSpent=SECONDS_TO_READ_UNEQUIPPED_CLOCK;
  }
  Engine.rollDateAndRefresh(timeSpent);
  return clock;
}

Fixed version (ground truth):
/** 
 * Gets the easiest-to-access unbroken clock of the Hero. If the Hero has no unbroken clock, the easiest-to-access broken clock. Lastly, if the Hero does not have a clock at all, null is returned.
 * @return an Item object of the clock Item (or null)
 */
@Nullable private Item getBestClock(){
  Item clock=null;
  if (hasWeapon() && getWeapon().hasTag(Item.Tag.CLOCK)) {
    if (!getWeapon().isBroken()) {
      clock=getWeapon();
    }
 else {
      for (      Item item : getInventory().getItems()) {
        if (item.hasTag(Item.Tag.CLOCK) && !item.isBroken()) {
          clock=item;
          break;
        }
      }
      if (clock == null) {
        clock=getWeapon();
      }
    }
  }
 else {
    Item brokenClock=null;
    for (    Item item : getInventory().getItems()) {
      if (item.hasTag(Item.Tag.CLOCK)) {
        if (item.isBroken() && brokenClock == null) {
          brokenClock=item;
        }
 else {
          clock=item;
          break;
        }
      }
    }
    if (brokenClock != null) {
      clock=brokenClock;
    }
  }
  if (clock != null) {
    Engine.rollDateAndRefresh(getTimeToReadFromClock(clock));
  }
  return clock;
}
Program: 33721
Project: 33721
Buggy source:
public CounterMap<CauseOfDeath> getKillsByCauseOfDeath(){
  CounterMap<CauseOfDeath> causeOfDeathCounterMap=new CounterMap<CauseOfDeath>();
  for (  BattleRecord record : records.keySet()) {
    causeOfDeathCounterMap.incrementCounter(record.getCauseOfDeath());
  }
  return causeOfDeathCounterMap;
}

Fixed version (ground truth):
/** 
 * Returns a CounterMap of CauseOfDeath representing how many times each CauseOfDeath already registered occurred.
 */
public CounterMap<CauseOfDeath> getKillsByCauseOfDeath(){
  CounterMap<CauseOfDeath> causeOfDeathCounterMap=new CounterMap<CauseOfDeath>();
  for (  BattleRecord record : records.keySet()) {
    causeOfDeathCounterMap.incrementCounter(record.getCauseOfDeath(),records.getCounter(record));
  }
  return causeOfDeathCounterMap;
}
Program: 33723
Project: 33723
Buggy source:
/** 
 * Returns a List with all the UnlockedAchievements in this AchievementTracker sorted using the provided Comparator.
 * @param comparator a Comparator of UnlockedAchievements, not null
 * @return a sorted List with all the UnlockedAchievements in this AchievementTracker
 */
public List<UnlockedAchievement> getUnlockedAchievements(Comparator<UnlockedAchievement> comparator){
  if (comparator == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  List<UnlockedAchievement> list=new ArrayList<UnlockedAchievement>(unlockedAchievements);
  list.sort(comparator);
  return list;
}

Fixed version (ground truth):
/** 
 * Returns a List with all the UnlockedAchievements in this AchievementTracker sorted using the provided Comparator.
 * @param comparator a Comparator of UnlockedAchievements, not null
 * @return a sorted List with all the UnlockedAchievements in this AchievementTracker
 */
public List<UnlockedAchievement> getUnlockedAchievements(Comparator<UnlockedAchievement> comparator){
  if (comparator == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  List<UnlockedAchievement> list=new ArrayList<UnlockedAchievement>(unlockedAchievements);
  Collections.sort(list,comparator);
  return list;
}
Program: 33724
Project: 33724
Buggy source:
private static void printNotYetUnlockedAchievements(){
  AchievementTracker tracker=Game.getGameState().getHero().getAchievementTracker();
  List<Achievement> achievementList=new ArrayList<Achievement>();
  for (  Achievement achievement : GameData.ACHIEVEMENTS.values()) {
    if (!tracker.isUnlocked(achievement)) {
      achievementList.add(achievement);
    }
  }
  if (achievementList.isEmpty()) {
    IO.writeString("String_Node_Str");
  }
 else {
    achievementList.sort(null);
    for (    Achievement achievement : achievementList) {
      IO.writeString(String.format("String_Node_Str",achievement.getName(),achievement.getInfo()));
    }
  }
}

Fixed version (ground truth):
private static void printNotYetUnlockedAchievements(){
  AchievementTracker tracker=Game.getGameState().getHero().getAchievementTracker();
  List<Achievement> achievementList=new ArrayList<Achievement>();
  for (  Achievement achievement : GameData.ACHIEVEMENTS.values()) {
    if (!tracker.isUnlocked(achievement)) {
      achievementList.add(achievement);
    }
  }
  if (achievementList.isEmpty()) {
    IO.writeString("String_Node_Str");
  }
 else {
    Collections.sort(achievementList);
    for (    Achievement achievement : achievementList) {
      IO.writeString(String.format("String_Node_Str",achievement.getName(),achievement.getInfo()));
    }
  }
}
Program: 33725
Project: 33725
Buggy source:
/** 
 * Gives a Creature all the Items defined in the corresponding CreaturePreset and equips its weapon, if there is one.
 */
private static void giveItems(Creature creature){
  CreaturePreset preset=creaturePresetMap.get(creature.getID());
  for (  ID itemID : preset.getItems()) {
    Date date=Game.getGameState().getWorld().getWorldDate();
    Item item=ItemFactory.makeItem(itemID,date);
    SimulationResult result=creature.getInventory().simulateItemAddition(item);
    if (result == SimulationResult.SUCCESSFUL) {
      creature.getInventory().addItem(item);
    }
 else {
      DLogger.warning("String_Node_Str" + itemID + "String_Node_Str"+ creature.getID()+ "String_Node_Str"+ result+ "String_Node_Str");
    }
  }
  equipWeapon(creature,preset);
}

Fixed version (ground truth):
/** 
 * Gives a Creature all the Items defined in the corresponding CreaturePreset and equips its weapon, if there is one.
 * @param creature the Creature
 * @param date     the Date when the Items this Creature has were created
 */
private static void giveItems(Creature creature,Date date){
  CreaturePreset preset=creaturePresetMap.get(creature.getID());
  for (  ID itemID : preset.getItems()) {
    Item item=ItemFactory.makeItem(itemID,date);
    SimulationResult result=creature.getInventory().simulateItemAddition(item);
    if (result == SimulationResult.SUCCESSFUL) {
      creature.getInventory().addItem(item);
    }
 else {
      DLogger.warning("String_Node_Str" + itemID + "String_Node_Str"+ creature.getID()+ "String_Node_Str"+ result+ "String_Node_Str");
    }
  }
  equipWeapon(creature,preset);
}
Program: 33726
Project: 33726
Buggy source:
public static Hero makeHero(){
  Hero hero=new Hero(creaturePresetMap.get(Constants.HERO_ID));
  giveItems(hero);
  return hero;
}

Fixed version (ground truth):
/** 
 * Creates the Hero.
 * @param date the Date when the Items the Hero has were created
 * @return the Hero object
 */
public static Hero makeHero(Date date){
  Hero hero=new Hero(creaturePresetMap.get(Constants.HERO_ID));
  giveItems(hero,date);
  return hero;
}
Program: 33727
Project: 33727
Buggy source:
/** 
 * Sets a new GameState to the static field. This setter also invokes the   {@code Hero.look()} method on the Hero of the specified GameState.<p/> There is no need to call Engine.refresh() after invoking this method.
 * @param state the new GameState (should not be {@code null})
 */
public static void setGameState(GameState state){
  gameState=state;
  Engine.refresh();
  IO.writeNewLine();
  gameState.getHero().look(null);
}

Fixed version (ground truth):
/** 
 * Sets a new GameState to the static field. Can be used to nullify the GameState, something that should be done while another GameState is being created. If the provided GameState is not null, this setter also invokes Hero.look() and Engine.refresh().
 * @param state another GameState object, or null
 */
public static void setGameState(GameState state){
  gameState=state;
  if (state == null) {
    DLogger.info("String_Node_Str");
  }
 else {
    DLogger.info("String_Node_Str");
    Engine.refresh();
    IO.writeNewLine();
    gameState.getHero().look(null);
  }
}
Program: 33728
Project: 33728
Buggy source:
/** 
 * Creates the Hero and the starting Location.
 */
private void createHeroAndStartingLocation(){
  hero=CreatureFactory.makeHero();
  heroPosition=new Point(0,0);
  world.getLocation(heroPosition).addCreature(hero);
  getStatistics().getExplorationStatistics().addVisit(heroPosition,world.getLocation(heroPosition).getID());
}

Fixed version (ground truth):
/** 
 * Creates the Hero and the starting Location.
 */
private void createHeroAndStartingLocation(){
  hero=CreatureFactory.makeHero(world.getWorldDate());
  heroPosition=new Point(0,0);
  world.getLocation(heroPosition).addCreature(hero);
  getStatistics().getExplorationStatistics().addVisit(heroPosition,world.getLocation(heroPosition).getID());
}
Program: 33729
Project: 33729
Buggy source:
/** 
 * Iterates through the inventory, removing items that shouldn't exist anymore.
 */
public void refreshItems(){
  for (  Item item : items) {
    if (item.hasTag(Tag.DECOMPOSES) && item.getAge() > item.getDecompositionPeriod()) {
      removeItem(item);
    }
  }
}

Fixed version (ground truth):
/** 
 * Iterates through the inventory, removing items that shouldn't exist anymore.
 */
public void refreshItems(){
  for (Iterator<Item> iterator=items.iterator(); iterator.hasNext(); ) {
    Item item=iterator.next();
    if (isDecomposed(item)) {
      iterator.remove();
    }
  }
}
Program: 33730
Project: 33730
Buggy source:
public void dropEverything(){
  for (  Item item : getInventory().getItems()) {
    dropItem(item);
  }
}

Fixed version (ground truth):
/** 
 * Iterates though the Creature's inventory, dropping all Items on the ground.
 */
public void dropEverything(){
  for (Iterator<Item> iterator=getInventory().getItems().iterator(); iterator.hasNext(); ) {
    getLocation().addItem(iterator.next());
    iterator.remove();
  }
}
Program: 33731
Project: 33731
Buggy source:
/** 
 * The method that enables a Hero to drink milk from a Creature.
 * @param issuedCommand the command entered by the player
 * @return how many seconds this action took
 */
public int parseMilk(IssuedCommand issuedCommand){
  if (checkForCreatureVisibilityWarningIfFalse()) {
    if (issuedCommand.hasArguments()) {
      Creature selectedCreature=selectTarget(issuedCommand);
      if (selectedCreature != null) {
        if (selectedCreature.hasTag(Creature.Tag.MILKABLE)) {
          milk(selectedCreature);
        }
 else {
          IO.writeString("String_Node_Str");
        }
      }
    }
 else {
      List<Creature> visibleCreatures=filterByVisibility(getLocation().getCreatures());
      List<Creature> milkableCreatures=filterByTag(visibleCreatures,Tag.MILKABLE);
      if (milkableCreatures.isEmpty()) {
        IO.writeString("String_Node_Str");
      }
 else {
        if (Matches.fromCollection(milkableCreatures).getDifferentNames() == 1) {
          milk(milkableCreatures.get(0));
        }
 else {
          IO.writeString("String_Node_Str");
        }
      }
    }
  }
  return 0;
}

Fixed version (ground truth):
/** 
 * The method that enables a Hero to drink milk from a Creature.
 * @param issuedCommand the command entered by the player
 * @return how many seconds this action took
 */
public int parseMilk(IssuedCommand issuedCommand){
  if (checkForCreatureVisibilityWarningIfFalse()) {
    if (issuedCommand.hasArguments()) {
      Creature selectedCreature=selectTarget(issuedCommand);
      if (selectedCreature != null) {
        if (selectedCreature.hasTag(Creature.Tag.MILKABLE)) {
          return milk(selectedCreature);
        }
 else {
          IO.writeString("String_Node_Str");
        }
      }
    }
 else {
      List<Creature> visibleCreatures=filterByVisibility(getLocation().getCreatures());
      List<Creature> milkableCreatures=filterByTag(visibleCreatures,Tag.MILKABLE);
      if (milkableCreatures.isEmpty()) {
        IO.writeString("String_Node_Str");
      }
 else {
        if (Matches.fromCollection(milkableCreatures).getDifferentNames() == 1) {
          return milk(milkableCreatures.get(0));
        }
 else {
          IO.writeString("String_Node_Str");
        }
      }
    }
  }
  return 0;
}
Program: 33733
Project: 33733
Buggy source:
public static void wait(IssuedCommand issuedCommand){
  if (issuedCommand.getTokenCount() >= 3) {
    int seconds=0;
    boolean gotSeconds=false;
    String argument=issuedCommand.getArguments()[1];
    Matches<PartOfDay> matches=Utils.findBestCompleteMatches(Arrays.asList(PartOfDay.values()),argument);
    if (matches.size() == 1) {
      seconds=PartOfDay.getSecondsToNext(Game.getGameState().getWorld().getWorldDate(),matches.getMatch(0));
      gotSeconds=true;
    }
 else     if (matches.size() > 1) {
      Messenger.printAmbiguousSelectionMessage();
    }
 else {
      try {
        seconds=Integer.parseInt(argument);
        gotSeconds=true;
      }
 catch (      NumberFormatException warn) {
        Messenger.printInvalidNumberFormatOrValue();
      }
    }
    if (gotSeconds) {
      Game.getGameState().getWorld().rollDate(seconds);
      IO.writeString("String_Node_Str" + seconds + "String_Node_Str");
    }
  }
 else {
    Messenger.printMissingArgumentsMessage();
  }
}

Fixed version (ground truth):
private static void wait(IssuedCommand issuedCommand){
  if (issuedCommand.getTokenCount() >= 3) {
    int seconds=0;
    boolean gotSeconds=false;
    String argument=issuedCommand.getArguments()[1];
    Matches<PartOfDay> matches=Utils.findBestCompleteMatches(Arrays.asList(PartOfDay.values()),argument);
    if (matches.size() == 1) {
      seconds=PartOfDay.getSecondsToNext(Game.getGameState().getWorld().getWorldDate(),matches.getMatch(0));
      gotSeconds=true;
    }
 else     if (matches.size() > 1) {
      Messenger.printAmbiguousSelectionMessage();
    }
 else {
      try {
        seconds=Integer.parseInt(argument);
        gotSeconds=true;
      }
 catch (      NumberFormatException warn) {
        Messenger.printInvalidNumberFormatOrValue();
      }
    }
    if (gotSeconds) {
      rollDate(seconds);
    }
  }
 else {
    Messenger.printMissingArgumentsMessage();
  }
}
Program: 33734
Project: 33734
Buggy source:
public static void printIsSaved(){
  if (Game.getGameState().isSaved()) {
    IO.writeString("String_Node_Str");
  }
 else {
    IO.writeString("String_Node_Str");
  }
}

Fixed version (ground truth):
private static void printIsSaved(){
  if (Game.getGameState().isSaved()) {
    IO.writeString("String_Node_Str");
  }
 else {
    IO.writeString("String_Node_Str");
  }
}
Program: 33735
Project: 33735
Buggy source:
public static void printTime(){
  IO.writeString(Game.getGameState().getWorld().getWorldDate().toTimeString());
}

Fixed version (ground truth):
private static void printTime(){
  IO.writeString(Game.getGameState().getWorld().getWorldDate().toTimeString());
}
Program: 33736
Project: 33736
Buggy source:
public void cast(Creature caster,Creature target){
  target.takeDamage(getDamage());
  printSkillCast(this,caster,target);
  Item casterWeapon=caster.getWeapon();
  if (casterWeapon != null && casterWeapon.isRepairable()) {
    casterWeapon.incrementIntegrity(getRepair());
    IO.writeString(casterWeapon.getName() + "String_Node_Str");
  }
  startCoolDown();
}

Fixed version (ground truth):
public void cast(Creature caster,Creature target){
  target.takeDamage(getDamage());
  printSkillCast(this,caster,target);
  Item casterWeapon=caster.getWeapon();
  if (casterWeapon != null && casterWeapon.isRepairable() && getRepair() > 0) {
    casterWeapon.incrementIntegrity(getRepair());
    IO.writeString(casterWeapon.getName() + "String_Node_Str");
  }
  startCoolDown();
}
Program: 33738
Project: 33738
Buggy source:
/** 
 * Returns the n-th element of the fibonacci sequence.
 * @param n the position of the element on the sequence. Must be positive.
 */
private static String fibonacci(int n){
  if (n < 1) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  BigInteger a=BigInteger.ZERO;
  BigInteger b=BigInteger.ONE;
  BigInteger s;
  for (int i=1; i < n; i++) {
    s=a;
    a=b;
    b=b.add(s);
  }
  return a.toString();
}

Fixed version (ground truth):
/** 
 * Finds the n-th element of the fibonacci sequence if it can be computed in less than one second.
 * @param n the position of the element on the sequence
 * @return a String representation of the number or the {@code TIMEOUT} constant
 */
private static String fibonacci(int n){
  final long interruptTime=System.nanoTime() + 1000000000;
  BigInteger a=BigInteger.ZERO;
  BigInteger b=BigInteger.ONE;
  BigInteger s;
  for (int i=1; i < n; i++) {
    s=a;
    a=b;
    b=b.add(s);
    if (System.nanoTime() >= interruptTime) {
      return TIMEOUT;
    }
  }
  return a.toString();
}
Program: 33739
Project: 33739
Buggy source:
/** 
 * Sets a new GameState to the static field. This setter also invokes the   {@code Hero.look()} method on the Hero of the specified GameState.
 * @param state the new GameState (should not be {@code null})
 */
private static void setGameState(GameState state){
  gameState=state;
  IO.writeNewLine();
  gameState.getHero().look(null);
}

Fixed version (ground truth):
/** 
 * Sets a new GameState to the static field. This setter also invokes the   {@code Hero.look()} method on the Hero of the specified GameState.
 * @param state the new GameState (should not be {@code null})
 */
private static void setGameState(GameState state){
  gameState=state;
  Engine.refresh();
  IO.writeNewLine();
  gameState.getHero().look(null);
}
Program: 33740
Project: 33740
Buggy source:
/** 
 * Prints the table to the game window.
 */
public void print(){
  if (columns.size() == 0) {
    DLogger.warning("String_Node_Str");
    return;
  }
  int columnCount=columns.size();
  int columnWidth=(Constants.COLS - columnCount + 1) / columnCount;
  int rowCount=columns.get(0).rows.size();
  StringBuilder builder=new StringBuilder(Constants.COLS * rowCount + 16);
  String[] currentRow=new String[columnCount];
  for (int i=0; i < columnCount; i++) {
    currentRow[i]=columns.get(i).header;
  }
  appendRow(builder,columnWidth,currentRow);
  appendHorizontalSeparator(builder,columnWidth,columnCount);
  for (int rowIndex=0; rowIndex < rowCount + 1; rowIndex++) {
    for (int remainingSeparators=separators.getCounter(rowIndex); remainingSeparators > 0; remainingSeparators--) {
      appendHorizontalSeparator(builder,columnWidth,columnCount);
    }
    if (rowIndex != rowCount) {
      for (int columnIndex=0; columnIndex < columnCount; columnIndex++) {
        currentRow[columnIndex]=columns.get(columnIndex).rows.get(rowIndex);
      }
      appendRow(builder,columnWidth,currentRow);
    }
  }
  IO.writeString(builder.toString());
}

Fixed version (ground truth):
/** 
 * Prints the table to the game window.
 */
public void print(){
  if (columns.size() == 0) {
    DLogger.warning("String_Node_Str");
    return;
  }
  int columnCount=columns.size();
  int columnWidth=(Constants.COLS - columnCount + 1) / columnCount;
  int rowCount=columns.get(0).rows.size();
  StringBuilder builder=new StringBuilder(Constants.COLS * rowCount + 16);
  String[] currentRow=new String[columnCount];
  for (int i=0; i < columnCount; i++) {
    currentRow[i]=columns.get(i).header;
  }
  appendRow(builder,columnWidth,currentRow);
  appendHorizontalSeparator(builder,columnWidth,columnCount);
  for (int rowIndex=0; rowIndex < rowCount + 1; rowIndex++) {
    if (separators != null) {
      for (int remaining=separators.getCounter(rowIndex); remaining > 0; remaining--) {
        appendHorizontalSeparator(builder,columnWidth,columnCount);
      }
    }
    if (rowIndex != rowCount) {
      for (int columnIndex=0; columnIndex < columnCount; columnIndex++) {
        currentRow[columnIndex]=columns.get(columnIndex).rows.get(rowIndex);
      }
      appendRow(builder,columnWidth,currentRow);
    }
  }
  IO.writeString(builder.toString());
}
Program: 33741
Project: 33741
Buggy source:
/** 
 * Converts a String of data to an ArrayList of separate Strings. <p/> "[First Item | Second Item ]" becomes {"First Item", "Second Item"}.
 */
private String[] toArray(String data){
  if (data.startsWith("String_Node_Str")) {
    data=data.substring(1,data.length());
    return Utils.split(data,"String_Node_Str");
  }
 else {
    return new String[]{data};
  }
}

Fixed version (ground truth):
/** 
 * Converts a String of data to an ArrayList of separate Strings. <p/> "[First Item | Second Item ]" becomes {"First Item", "Second Item"}.
 */
private String[] toArray(String data){
  if (data.startsWith("String_Node_Str")) {
    data=data.substring(1,data.length() - 1);
    return Utils.split(data,"String_Node_Str");
  }
 else {
    return new String[]{data};
  }
}
Program: 33742
Project: 33742
Buggy source:
public int readItem(IssuedCommand issuedCommand){
  Item selectedItem=selectInventoryItem(issuedCommand);
  if (selectedItem != null) {
    BookComponent book=selectedItem.getBookComponent();
    if (book != null) {
      Skill skill=new Skill(GameData.getSkillDefinitions().get(book.getSkillID()));
      if (getSkillList().hasSkill(skill.getID())) {
        IO.writeString("String_Node_Str" + skill.getName() + "String_Node_Str");
        return SECONDS_TO_LOOK_AT_THE_COVER_OF_THE_BOOK;
      }
 else {
        getSkillList().addSkill(skill);
        IO.writeString("String_Node_Str" + skill.getName() + "String_Node_Str");
        return SECONDS_TO_LEARN_A_SKILL;
      }
    }
 else {
      IO.writeString("String_Node_Str");
    }
  }
  return 0;
}

Fixed version (ground truth):
public int readItem(IssuedCommand issuedCommand){
  Item selectedItem=selectInventoryItem(issuedCommand);
  if (selectedItem != null) {
    BookComponent book=selectedItem.getBookComponent();
    if (book != null) {
      Skill skill=new Skill(GameData.getSkillDefinitions().get(book.getSkillID()));
      if (getSkillList().hasSkill(skill.getID())) {
        IO.writeString("String_Node_Str" + skill.getName() + "String_Node_Str");
        return SECONDS_TO_LOOK_AT_THE_COVER_OF_A_BOOK;
      }
 else {
        getSkillList().addSkill(skill);
        IO.writeString("String_Node_Str" + skill.getName() + "String_Node_Str");
        return SECONDS_TO_LEARN_A_SKILL;
      }
    }
 else {
      IO.writeString("String_Node_Str");
    }
  }
  return 0;
}
Program: 33743
Project: 33743
Buggy source:
/** 
 * Attempts to drop an item from the hero's inventory.
 */
public void dropItem(IssuedCommand issuedCommand){
  Item selectedItem=selectInventoryItem(issuedCommand);
  if (selectedItem != null) {
    if (selectedItem == getWeapon()) {
      unequipWeapon();
    }
    getInventory().removeItem(selectedItem);
    getLocation().addItem(selectedItem);
    IO.writeString("String_Node_Str" + selectedItem.getName() + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Attempts to drop an item from the hero's inventory.
 */
public int dropItem(IssuedCommand issuedCommand){
  Item selectedItem=selectInventoryItem(issuedCommand);
  if (selectedItem != null) {
    int totalTime=SECONDS_TO_DROP_AN_ITEM;
    if (selectedItem == getWeapon()) {
      totalTime+=unequipWeapon();
    }
    getInventory().removeItem(selectedItem);
    getLocation().addItem(selectedItem);
    IO.writeString("String_Node_Str" + selectedItem.getName() + "String_Node_Str");
    return totalTime;
  }
  return 0;
}
Program: 33744
Project: 33744
Buggy source:
public void unequipWeapon(){
  if (hasWeapon()) {
    IO.writeString(getName() + "String_Node_Str" + getWeapon().getName()+ "String_Node_Str");
    setWeapon(null);
  }
 else {
    IO.writeString(Constants.NOT_EQUIPPING_A_WEAPON);
  }
}

Fixed version (ground truth):
public int unequipWeapon(){
  if (hasWeapon()) {
    IO.writeString(getName() + "String_Node_Str" + getWeapon().getName()+ "String_Node_Str");
    setWeapon(null);
    return SECONDS_TO_UNEQUIP;
  }
 else {
    IO.writeString(Constants.NOT_EQUIPPING_A_WEAPON);
  }
  return 0;
}
Program: 33745
Project: 33745
Buggy source:
/** 
 * Tries to equip an item from the inventory.
 */
public void parseEquip(IssuedCommand issuedCommand){
  Item selectedItem=selectInventoryItem(issuedCommand);
  if (selectedItem != null) {
    if (selectedItem.isWeapon()) {
      equipWeapon(selectedItem);
    }
 else {
      IO.writeString("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Tries to equip an item from the inventory.
 */
public int parseEquip(IssuedCommand issuedCommand){
  Item selectedItem=selectInventoryItem(issuedCommand);
  if (selectedItem != null) {
    if (selectedItem.isWeapon()) {
      equipWeapon(selectedItem);
      return SECONDS_TO_EQUIP;
    }
 else {
      IO.writeString("String_Node_Str");
    }
  }
  return 0;
}
Program: 33746
Project: 33746
Buggy source:
/** 
 * Attempts to eat an item from the ground.
 */
public int eatItem(IssuedCommand issuedCommand){
  Item selectedItem=selectInventoryItem(issuedCommand);
  if (selectedItem != null) {
    if (selectedItem.isFood()) {
      FoodComponent food=selectedItem.getFoodComponent();
      double remainingBites=selectedItem.getCurIntegrity() / (double)food.getIntegrityDecrementOnEat();
      if (remainingBites >= 1.0) {
        addHealth(food.getNutrition());
      }
 else {
        addHealth((int)(food.getNutrition() * remainingBites));
      }
      selectedItem.decrementIntegrity(food.getIntegrityDecrementOnEat());
      if (selectedItem.isBroken() && !selectedItem.isRepairable()) {
        IO.writeString("String_Node_Str" + selectedItem.getName() + "String_Node_Str");
        getInventory().removeItem(selectedItem);
      }
 else {
        IO.writeString("String_Node_Str" + selectedItem.getName() + "String_Node_Str");
      }
      if (isCompletelyHealed()) {
        IO.writeString("String_Node_Str");
      }
    }
 else {
      IO.writeString("String_Node_Str");
    }
  }
  return SECONDS_TO_EAT_AN_ITEM;
}

Fixed version (ground truth):
/** 
 * Attempts to eat an item from the ground.
 */
public int eatItem(IssuedCommand issuedCommand){
  Item selectedItem=selectInventoryItem(issuedCommand);
  if (selectedItem != null) {
    if (selectedItem.isFood()) {
      FoodComponent food=selectedItem.getFoodComponent();
      double remainingBites=selectedItem.getCurIntegrity() / (double)food.getIntegrityDecrementOnEat();
      if (remainingBites >= 1.0) {
        addHealth(food.getNutrition());
      }
 else {
        addHealth((int)(food.getNutrition() * remainingBites));
      }
      selectedItem.decrementIntegrity(food.getIntegrityDecrementOnEat());
      if (selectedItem.isBroken() && !selectedItem.isRepairable()) {
        IO.writeString("String_Node_Str" + selectedItem.getName() + "String_Node_Str");
        getInventory().removeItem(selectedItem);
      }
 else {
        IO.writeString("String_Node_Str" + selectedItem.getName() + "String_Node_Str");
      }
      if (isCompletelyHealed()) {
        IO.writeString("String_Node_Str");
      }
      return SECONDS_TO_EAT_AN_ITEM;
    }
 else {
      IO.writeString("String_Node_Str");
    }
  }
  return 0;
}
Program: 33747
Project: 33747
Buggy source:
/** 
 * Attempts to pick and item and add it to the inventory.
 */
public int pickItem(IssuedCommand issuedCommand){
  if (canSee()) {
    Item selectedItem=selectLocationItem(issuedCommand);
    if (selectedItem != null) {
      if (getInventory().isFull()) {
        IO.writeString(Constants.INVENTORY_FULL);
      }
 else {
        getInventory().addItem(selectedItem);
        getLocation().removeItem(selectedItem);
      }
    }
  }
 else {
    IO.writeString("String_Node_Str");
  }
  return SECONDS_TO_PICK_UP_AN_ITEM;
}

Fixed version (ground truth):
/** 
 * Attempts to pick and item and add it to the inventory.
 */
public int pickItem(IssuedCommand issuedCommand){
  if (canSee()) {
    Item selectedItem=selectLocationItem(issuedCommand);
    if (selectedItem != null) {
      if (getInventory().isFull()) {
        IO.writeString(Constants.INVENTORY_FULL);
      }
 else {
        getInventory().addItem(selectedItem);
        getLocation().removeItem(selectedItem);
        return SECONDS_TO_PICK_UP_AN_ITEM;
      }
    }
  }
 else {
    IO.writeString("String_Node_Str");
  }
  return 0;
}
Program: 33749
Project: 33749
Buggy source:
/** 
 * Refreshes the remaining cool down of all Skills in this SkillRotation. <p/> This method should be invoked after each turn.
 */
public void refresh(){
  for (  Skill skill : skillList) {
    skill.refresh();
  }
}

Fixed version (ground truth):
/** 
 * Refreshes the remaining cool down of all Skills in this SkillRotation. <p/> This method should be invoked after each turn.
 */
public void refresh(){
  ArrayList<Skill> alreadyRefreshedSkills=new ArrayList<Skill>(skillList.size());
  for (  Skill skill : skillList) {
    if (!alreadyRefreshedSkills.contains(skill)) {
      skill.refresh();
      alreadyRefreshedSkills.add(skill);
    }
  }
}
Program: 33750
Project: 33750
Buggy source:
/** 
 * Read a String of text formatted according to the Dungeon convention. <p/> Returns   {@code null} if the end of the file has been reached.
 */
public String readString(){
  readLine();
  if (line == null) {
    return null;
  }
  if (line.isContinued()) {
    StringBuilder sb=new StringBuilder();
    do {
      sb.append(line.toString()).append('\n');
      readLine();
    }
 while (line != null && line.isContinued());
    return sb.toString();
  }
  return line.toString();
}

Fixed version (ground truth):
/** 
 * Read a String of text formatted according to the Dungeon convention. <p/> Returns   {@code null} if the end of the file has been reached.
 */
public String readString(){
  readLine();
  if (line == null) {
    return null;
  }
  if (line.isContinued()) {
    StringBuilder sb=new StringBuilder();
    sb.append(line.toString()).append('\n');
    while (line.isContinued()) {
      readLine();
      if (line != null) {
        sb.append(line.toString()).append('\n');
      }
 else {
        break;
      }
    }
    return sb.toString();
  }
  return line.toString();
}
Program: 33751
Project: 33751
Buggy source:
/** 
 * Attempts to move the hero character in a given direction.
 * @return the number of seconds the player walk took as an integer.
 */
private static int heroWalk(Direction dir){
  GameState gameState=Game.getGameState();
  World world=gameState.getWorld();
  Point point=gameState.getHeroPosition();
  Hero hero=gameState.getHero();
  Point destinationPoint=new Point(gameState.getHeroPosition(),dir);
  if (world.getLocation(destinationPoint).isBlocked(dir.invert()) || world.getLocation(point).isBlocked(dir)) {
    IO.writeString("String_Node_Str" + dir + "String_Node_Str");
    return TimeConstants.WALK_BLOCKED;
  }
  Location destination=gameState.getWorld().moveHero(dir);
  hero.setLocation(destination);
  hero.look(true);
  hero.getExplorationLog().addVisit(destinationPoint);
  return TimeConstants.WALK_SUCCESS;
}

Fixed version (ground truth):
/** 
 * Attempts to move the hero character in a given direction.
 * @return the number of seconds the player walk took as an integer.
 */
private static int heroWalk(Direction dir){
  GameState gameState=Game.getGameState();
  World world=gameState.getWorld();
  Point point=gameState.getHeroPosition();
  Hero hero=gameState.getHero();
  Point destinationPoint=new Point(gameState.getHeroPosition(),dir);
  if (world.getLocation(destinationPoint).isBlocked(dir.invert()) || world.getLocation(point).isBlocked(dir)) {
    IO.writeString("String_Node_Str" + dir + "String_Node_Str");
    return TimeConstants.WALK_BLOCKED;
  }
  Location destination=gameState.getWorld().moveHero(dir);
  refreshSpawners();
  hero.setLocation(destination);
  hero.look(true);
  hero.getExplorationLog().addVisit(destinationPoint);
  return TimeConstants.WALK_SUCCESS;
}
Program: 33752
Project: 33752
Buggy source:
/** 
 * Handles a key press in the text field.
 * @param e the KeyEvent.
 */
private void textFieldKeyPressed(KeyEvent e){
  CommandHistory commandHistory=Game.getGameState().getCommandHistory();
  if (idle && commandHistory != null) {
    if (e.getKeyCode() == KeyEvent.VK_UP) {
      textField.setText(commandHistory.getCursor().moveUp().getSelectedCommand());
    }
 else     if (e.getKeyCode() == KeyEvent.VK_DOWN) {
      textField.setText(commandHistory.getCursor().moveDown().getSelectedCommand());
    }
 else     if (e.getKeyCode() == KeyEvent.VK_TAB) {
      String trimmedTextFieldText=getTrimmedTextFieldText();
      if (trimmedTextFieldText.isEmpty() && !commandHistory.isEmpty()) {
        textField.setText(commandHistory.getCursor().moveToEnd().moveUp().getSelectedCommand());
      }
 else {
        String lastSimilarCommand=commandHistory.getLastSimilarCommand(trimmedTextFieldText);
        if (lastSimilarCommand != null) {
          textField.setText(lastSimilarCommand);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Handles a key press in the text field.
 * @param e the KeyEvent.
 */
private void textFieldKeyPressed(KeyEvent e){
  if (idle) {
    GameState gameState=Game.getGameState();
    if (gameState != null) {
      CommandHistory commandHistory=gameState.getCommandHistory();
      if (e.getKeyCode() == KeyEvent.VK_UP) {
        textField.setText(commandHistory.getCursor().moveUp().getSelectedCommand());
      }
 else       if (e.getKeyCode() == KeyEvent.VK_DOWN) {
        textField.setText(commandHistory.getCursor().moveDown().getSelectedCommand());
      }
 else       if (e.getKeyCode() == KeyEvent.VK_TAB) {
        String trimmedTextFieldText=getTrimmedTextFieldText();
        if (trimmedTextFieldText.isEmpty() && !commandHistory.isEmpty()) {
          textField.setText(commandHistory.getCursor().moveToEnd().moveUp().getSelectedCommand());
        }
 else {
          String lastSimilarCommand=commandHistory.getLastSimilarCommand(trimmedTextFieldText);
          if (lastSimilarCommand != null) {
            textField.setText(lastSimilarCommand);
          }
        }
      }
    }
  }
}
Program: 33754
Project: 33754
Buggy source:
public Command(String source){
  this.tokens=Utils.split(source);
  this.stringRepresentation=String.join("String_Node_Str",tokens);
  if (tokens.length == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
}

Fixed version (ground truth):
public Command(String source){
  this.tokens=Utils.split(source);
  this.stringRepresentation=Utils.join("String_Node_Str",tokens);
  if (tokens.length == 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
}