nus-yam/ex-repair huggingface dataset:
Program: 178156
Project: 178156
Buggy source:
private void handleSorting(ug guiScreen){
  yq selectedItem=getMainInventory()[getFocusedSlot()];
  try {
    new InvTweaksHandlerSorting(mc,cfgManager.getConfig(),InvTweaksContainerSection.INVENTORY,InvTweaksHandlerSorting.ALGORITHM_INVENTORY,InvTweaksConst.INVENTORY_ROW_SIZE).sort();
  }
 catch (  Exception e) {
    logInGameError("String_Node_Str",e);
    e.printStackTrace();
  }
  playClick();
  if (selectedItem != null && getMainInventory()[getFocusedSlot()] == null) {
    storedStackId=0;
  }
}

Fixed version (ground truth):
private void handleSorting(ug guiScreen){
  yq selectedItem=null;
  int focusedSlot=getFocusedSlot();
  yq[] mainInventory=getMainInventory();
  if (focusedSlot < mainInventory.length && focusedSlot >= 0) {
    selectedItem=mainInventory[focusedSlot];
  }
  try {
    new InvTweaksHandlerSorting(mc,cfgManager.getConfig(),InvTweaksContainerSection.INVENTORY,InvTweaksHandlerSorting.ALGORITHM_INVENTORY,InvTweaksConst.INVENTORY_ROW_SIZE).sort();
  }
 catch (  Exception e) {
    logInGameError("String_Node_Str",e);
    e.printStackTrace();
  }
  playClick();
  if (selectedItem != null && mainInventory[focusedSlot] == null) {
    storedStackId=0;
  }
}
Program: 178157
Project: 178157
Buggy source:
public boolean isChestWayTooBig(ug guiScreen){
  return is(guiScreen,"String_Node_Str") || is(guiScreen,"String_Node_Str");
}

Fixed version (ground truth):
public boolean isChestWayTooBig(ug guiScreen){
  return is(guiScreen,"String_Node_Str") || is(guiScreen,"String_Node_Str") || is(guiScreen,"String_Node_Str");
}
Program: 178162
Project: 178162
Buggy source:
private void move(boolean separateStacks,boolean drop) throws Exception {
  int toIndex=-1;
synchronized (this) {
    toIndex=getNextIndex(separateStacks,drop);
    if (toIndex != -1) {
switch (shortcutType) {
case MOVE_ONE_STACK:
{
          vv slot=container.getSlot(fromSection,fromIndex);
          while (hasStack(slot) && toIndex != -1) {
            container.move(fromSection,fromIndex,toSection,toIndex);
            toIndex=getNextIndex(separateStacks,drop);
          }
          break;
        }
case MOVE_ONE_ITEM:
{
        container.moveSome(fromSection,fromIndex,toSection,toIndex,1);
        break;
      }
case MOVE_ALL_ITEMS:
{
      dk stackToMatch=copy(fromStack);
      moveAll(fromSection,toSection,separateStacks,drop,stackToMatch);
      if (fromSection == InvTweaksContainerSection.INVENTORY_NOT_HOTBAR && toSection == InvTweaksContainerSection.CHEST) {
        moveAll(InvTweaksContainerSection.INVENTORY_HOTBAR,toSection,separateStacks,drop,stackToMatch);
      }
    }
}
}
}
}

Fixed version (ground truth):
private void move(boolean separateStacks,boolean drop) throws Exception {
  int toIndex=-1;
synchronized (this) {
    toIndex=getNextIndex(separateStacks,drop);
    if (toIndex != -1) {
switch (shortcutType) {
case MOVE_ONE_STACK:
{
          vv slot=container.getSlot(fromSection,fromIndex);
          if (fromSection != InvTweaksContainerSection.CRAFTING_OUT) {
            boolean canStillMove=true;
            while (hasStack(slot) && toIndex != -1 && canStillMove) {
              canStillMove=container.move(fromSection,fromIndex,toSection,toIndex);
              toIndex=getNextIndex(separateStacks,drop);
            }
          }
 else {
            container.move(fromSection,fromIndex,toSection,toIndex);
          }
          break;
        }
case MOVE_ONE_ITEM:
{
        container.moveSome(fromSection,fromIndex,toSection,toIndex,1);
        break;
      }
case MOVE_ALL_ITEMS:
{
      dk stackToMatch=copy(fromStack);
      moveAll(fromSection,toSection,separateStacks,drop,stackToMatch);
      if (fromSection == InvTweaksContainerSection.INVENTORY_NOT_HOTBAR && toSection == InvTweaksContainerSection.CHEST) {
        moveAll(InvTweaksContainerSection.INVENTORY_HOTBAR,toSection,separateStacks,drop,stackToMatch);
      }
    }
}
}
}
}
Program: 178163
Project: 178163
Buggy source:
private void moveAll(InvTweaksContainerSection fromSection,InvTweaksContainerSection toSection,boolean separateStacks,boolean drop,dk stackToMatch) throws TimeoutException {
  int toIndex=getNextIndex(separateStacks,drop);
  for (  vv slot : container.getSlots(fromSection)) {
    if (hasStack(slot) && areSameItemType(stackToMatch,getStack(slot))) {
      int fromIndex=container.getSlotIndex(getSlotNumber(slot));
      while (hasStack(slot) && toIndex != -1 && !(fromSection == toSection && fromIndex == toIndex)) {
        container.move(fromSection,fromIndex,toSection,toIndex);
        toIndex=getNextIndex(separateStacks,drop);
      }
    }
    if (toIndex == -1) {
      break;
    }
  }
}

Fixed version (ground truth):
private void moveAll(InvTweaksContainerSection fromSection,InvTweaksContainerSection toSection,boolean separateStacks,boolean drop,dk stackToMatch) throws TimeoutException {
  int toIndex=getNextIndex(separateStacks,drop);
  for (  vv slot : container.getSlots(fromSection)) {
    if (hasStack(slot) && areSameItemType(stackToMatch,getStack(slot))) {
      int fromIndex=container.getSlotIndex(getSlotNumber(slot));
      boolean canStillMove=true;
      while (hasStack(slot) && toIndex != -1 && !(fromSection == toSection && fromIndex == toIndex) && canStillMove) {
        canStillMove=container.move(fromSection,fromIndex,toSection,toIndex);
        toIndex=getNextIndex(separateStacks,drop);
      }
    }
    if (toIndex == -1) {
      break;
    }
  }
}
Program: 178164
Project: 178164
Buggy source:
private void initAction(int fromSlot,ShortcutType shortcutType,InvTweaksContainerSection destSection) throws Exception {
  this.container=new InvTweaksContainerManager(mc);
  this.fromSection=container.getSlotSection(fromSlot);
  this.fromIndex=container.getSlotIndex(fromSlot);
  this.fromStack=container.getItemStack(fromSection,fromIndex);
  this.shortcutType=shortcutType;
  this.toSection=destSection;
  if (getHoldStack() != null) {
    container.leftClick(fromSection,fromIndex);
    if (getHoldStack() != null) {
      int firstEmptyIndex=container.getFirstEmptyIndex(InvTweaksContainerSection.INVENTORY);
      if (firstEmptyIndex != -1) {
        fromSection=InvTweaksContainerSection.INVENTORY;
        fromSlot=firstEmptyIndex;
        container.leftClick(fromSection,fromSlot);
      }
 else {
        throw new Exception("String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
private void initAction(int fromSlot,ShortcutType shortcutType,InvTweaksContainerSection destSection) throws Exception {
  this.container=new InvTweaksContainerManager(mc);
  this.fromSection=container.getSlotSection(fromSlot);
  this.fromIndex=container.getSlotIndex(fromSlot);
  this.fromStack=container.getItemStack(fromSection,fromIndex);
  this.shortcutType=shortcutType;
  this.toSection=destSection;
  if (getHoldStack() != null) {
    if (fromSection != InvTweaksContainerSection.CRAFTING_OUT) {
      container.leftClick(fromSection,fromIndex);
    }
    if (getHoldStack() != null) {
      int firstEmptyIndex=container.getFirstEmptyIndex(InvTweaksContainerSection.INVENTORY);
      if (firstEmptyIndex != -1) {
        fromSlot=firstEmptyIndex;
        container.leftClick(InvTweaksContainerSection.INVENTORY,fromSlot);
      }
 else {
        throw new Exception("String_Node_Str");
      }
    }
  }
}
Program: 178165
Project: 178165
Buggy source:
protected int getYDisplayPosition(vv slot){
  return slot.d;
}

Fixed version (ground truth):
protected int getYDisplayPosition(vv slot){
  return slot.f;
}
Program: 178166
Project: 178166
Buggy source:
private boolean isActive(ShortcutType shortcutType){
  for (  Integer keyCode : shortcuts.get(shortcutType)) {
    if (shortcutKeysStatus.get(keyCode)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean isActive(ShortcutType shortcutType){
  for (  Integer keyCode : shortcuts.get(shortcutType)) {
    if (shortcutKeysStatus.get(keyCode) && (keyCode != 29 || !Keyboard.isKeyDown(184))) {
      return true;
    }
  }
  return false;
}
Program: 178168
Project: 178168
Buggy source:
private int getItemOrder(int itemID,int itemDamage){
  List<ItemTreeItem> items=tree.getItems(itemID,itemDamage);
  return (items != null && items.size() > 0) ? items.get(0).getOrder() : Integer.MAX_VALUE;
}

Fixed version (ground truth):
private int getItemOrder(ItemStack item){
  List<ItemTreeItem> items=tree.getItems(getItemID(item),getItemDamage(item));
  return (items != null && items.size() > 0) ? items.get(0).getOrder() : Integer.MAX_VALUE;
}
Program: 178169
Project: 178169
Buggy source:
public SortingHandler(Minecraft mc,InvTweaksConfig config,ContainerSection section,int algorithm) throws Exception {
  super(mc);
  if (DEFAULT_LOCK_PRIORITIES == null) {
    DEFAULT_LOCK_PRIORITIES=new int[MAX_CONTAINER_SIZE];
    for (int i=0; i < MAX_CONTAINER_SIZE; i++) {
      DEFAULT_LOCK_PRIORITIES[i]=0;
    }
  }
  if (DEFAULT_FROZEN_SLOTS == null) {
    DEFAULT_FROZEN_SLOTS=new boolean[MAX_CONTAINER_SIZE];
    for (int i=0; i < MAX_CONTAINER_SIZE; i++) {
      DEFAULT_FROZEN_SLOTS[i]=false;
    }
  }
  this.containerMgr=new ContainerSectionManager(mc,section);
  this.size=containerMgr.getSectionSize();
  this.rules=config.getRules();
  this.tree=config.getTree();
  if (section == ContainerSection.INVENTORY) {
    this.lockPriorities=config.getLockPriorities();
    this.frozenSlots=config.getFrozenSlots();
    this.algorithm=ALGORITHM_INVENTORY;
  }
 else {
    this.lockPriorities=DEFAULT_LOCK_PRIORITIES;
    this.frozenSlots=DEFAULT_FROZEN_SLOTS;
    this.algorithm=algorithm;
    if (algorithm != ALGORITHM_DEFAULT) {
      computeLineSortingRules(Const.INVENTORY_ROW_SIZE,algorithm == ALGORITHM_HORIZONTAL);
    }
  }
  this.rulePriority=new int[size];
  this.keywordOrder=new int[size];
  for (int i=0; i < size; i++) {
    this.rulePriority[i]=-1;
    ItemStack stack=containerMgr.getItemStack(i);
    if (stack != null) {
      this.keywordOrder[i]=getItemOrder(getItemID(stack),getItemDamage(stack));
    }
 else {
      this.keywordOrder[i]=-1;
    }
  }
  this.isMultiplayer=isMultiplayerWorld();
}

Fixed version (ground truth):
public SortingHandler(Minecraft mc,InvTweaksConfig config,ContainerSection section,int algorithm) throws Exception {
  super(mc);
  if (DEFAULT_LOCK_PRIORITIES == null) {
    DEFAULT_LOCK_PRIORITIES=new int[MAX_CONTAINER_SIZE];
    for (int i=0; i < MAX_CONTAINER_SIZE; i++) {
      DEFAULT_LOCK_PRIORITIES[i]=0;
    }
  }
  if (DEFAULT_FROZEN_SLOTS == null) {
    DEFAULT_FROZEN_SLOTS=new boolean[MAX_CONTAINER_SIZE];
    for (int i=0; i < MAX_CONTAINER_SIZE; i++) {
      DEFAULT_FROZEN_SLOTS[i]=false;
    }
  }
  this.containerMgr=new ContainerSectionManager(mc,section);
  this.size=containerMgr.getSectionSize();
  this.rules=config.getRules();
  this.tree=config.getTree();
  if (section == ContainerSection.INVENTORY) {
    this.lockPriorities=config.getLockPriorities();
    this.frozenSlots=config.getFrozenSlots();
    this.algorithm=ALGORITHM_INVENTORY;
  }
 else {
    this.lockPriorities=DEFAULT_LOCK_PRIORITIES;
    this.frozenSlots=DEFAULT_FROZEN_SLOTS;
    this.algorithm=algorithm;
    if (algorithm != ALGORITHM_DEFAULT) {
      computeLineSortingRules(Const.INVENTORY_ROW_SIZE,algorithm == ALGORITHM_HORIZONTAL);
    }
  }
  this.rulePriority=new int[size];
  this.keywordOrder=new int[size];
  for (int i=0; i < size; i++) {
    this.rulePriority[i]=-1;
    ItemStack stack=containerMgr.getItemStack(i);
    if (stack != null) {
      this.keywordOrder[i]=getItemOrder(stack);
    }
 else {
      this.keywordOrder[i]=-1;
    }
  }
  this.isMultiplayer=isMultiplayerWorld();
}
Program: 178171
Project: 178171
Buggy source:
private void handleShortcuts(GuiScreen guiScreen){
  if (!(guiScreen instanceof GuiContainer)) {
    return;
  }
  if (Mouse.isButtonDown(0) || Mouse.isButtonDown(1)) {
    if (!mouseWasDown) {
      mouseWasDown=true;
      if (!cfgManager.getConfig().getProperty(InvTweaksConfig.PROP_ENABLE_SHORTCUTS).equals("String_Node_Str")) {
        cfgManager.getShortcutsHandler().handleShortcut((GuiContainer)guiScreen);
      }
    }
  }
 else {
    mouseWasDown=false;
  }
}

Fixed version (ground truth):
private void handleShortcuts(GuiScreen guiScreen){
  if (!(guiScreen instanceof GuiContainer)) {
    return;
  }
  if (Mouse.isButtonDown(0) || Mouse.isButtonDown(1)) {
    if (!mouseWasDown) {
      mouseWasDown=true;
      if (cfgManager.getConfig().getProperty(InvTweaksConfig.PROP_ENABLE_SHORTCUTS).equals("String_Node_Str")) {
        cfgManager.getShortcutsHandler().handleShortcut((GuiContainer)guiScreen);
      }
    }
  }
 else {
    mouseWasDown=false;
  }
}
Program: 178172
Project: 178172
Buggy source:
private void init(){
  rulesets=new Vector<InventoryConfigRuleset>();
  currentRuleset=-1;
  properties=new Properties();
  properties.setProperty(PROP_ENABLE_MIDDLE_CLICK,"String_Node_Str");
  properties.setProperty(PROP_SHOW_CHEST_BUTTONS,"String_Node_Str");
  properties.setProperty(PROP_ENABLE_SORTING_ON_PICKUP,"String_Node_Str");
  properties.setProperty(PROP_ENABLE_AUTOREPLACE_SOUND,"String_Node_Str");
  properties.setProperty(PROP_ENABLE_SORTING_SOUND,"String_Node_Str");
  invalidKeywords=new Vector<String>();
}

Fixed version (ground truth):
private void init(){
  rulesets=new Vector<InventoryConfigRuleset>();
  currentRuleset=-1;
  properties=new Properties();
  properties.setProperty(PROP_ENABLE_MIDDLE_CLICK,VALUE_TRUE);
  properties.setProperty(PROP_SHOW_CHEST_BUTTONS,VALUE_TRUE);
  properties.setProperty(PROP_ENABLE_SORTING_ON_PICKUP,VALUE_TRUE);
  properties.setProperty(PROP_ENABLE_AUTOREPLACE_SOUND,VALUE_TRUE);
  properties.setProperty(PROP_ENABLE_SORTING_SOUND,VALUE_TRUE);
  invalidKeywords=new Vector<String>();
}
Program: 178174
Project: 178174
Buggy source:
private String computeBooleanButtonLabel(String property,String label){
  Boolean enabled=new Boolean(config.getProperty(property));
  return label + ((enabled) ? ON : OFF);
}

Fixed version (ground truth):
private String computeBooleanButtonLabel(String property,String label){
  String propertyValue=config.getProperty(property);
  if (propertyValue.equals(InvTweaksConfig.VALUE_CI_COMPATIBILITY)) {
    return label + DISABLE_CI;
  }
 else {
    Boolean enabled=new Boolean(propertyValue);
    return label + ((enabled) ? ON : OFF);
  }
}
Program: 178175
Project: 178175
Buggy source:
@SuppressWarnings("String_Node_Str") public void initGui(){
  Point p=new Point();
  int i=0;
  moveToButtonCoords(0,p);
  controlList.add(new GuiButton(ID_EDITRULES,p.getX() + 55,height / 6 + 96,"String_Node_Str"));
  controlList.add(new GuiButton(ID_EDITTREE,p.getX() + 55,height / 6 + 120,"String_Node_Str"));
  controlList.add(new GuiButton(ID_HELP,p.getX() + 55,height / 6 + 144,"String_Node_Str"));
  controlList.add(new GuiButton(ID_DONE,p.getX() + 55,height / 6 + 168,"String_Node_Str"));
  String ciCompatibility=config.getProperty(InvTweaksConfig.PROP_CONVENIENT_INVENTORY_COMPATIBILITY);
  if (ciCompatibility == null || !ciCompatibility.equals("String_Node_Str")) {
    moveToButtonCoords(i++,p);
    controlList.add(new GuiSmallButton(ID_MIDDLE_CLICK,p.getX(),p.getY(),computeBooleanButtonLabel(InvTweaksConfig.PROP_ENABLE_MIDDLE_CLICK,MIDDLE_CLICK)));
  }
  moveToButtonCoords(i++,p);
  controlList.add(new GuiSmallButton(ID_CHESTS_BUTTONS,p.getX(),p.getY(),computeBooleanButtonLabel(InvTweaksConfig.PROP_SHOW_CHEST_BUTTONS,CHEST_BUTTONS)));
  moveToButtonCoords(i++,p);
  controlList.add(new GuiSmallButton(ID_SORT_ON_PICKUP,p.getX(),p.getY(),computeBooleanButtonLabel(InvTweaksConfig.PROP_ENABLE_SORTING_ON_PICKUP,SORT_ON_PICKUP)));
  if (!Desktop.isDesktopSupported()) {
    for (    Object o : controlList) {
      GuiButton button=(GuiButton)o;
      if (button.id == ID_EDITRULES || button.id < ID_EDITTREE) {
        button.enabled=false;
      }
    }
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void initGui(){
  Point p=new Point();
  int i=0;
  moveToButtonCoords(0,p);
  controlList.add(new GuiButton(ID_EDITRULES,p.getX() + 55,height / 6 + 96,"String_Node_Str"));
  controlList.add(new GuiButton(ID_EDITTREE,p.getX() + 55,height / 6 + 120,"String_Node_Str"));
  controlList.add(new GuiButton(ID_HELP,p.getX() + 55,height / 6 + 144,"String_Node_Str"));
  controlList.add(new GuiButton(ID_DONE,p.getX() + 55,height / 6 + 168,"String_Node_Str"));
  String middleClick=config.getProperty(InvTweaksConfig.PROP_ENABLE_MIDDLE_CLICK);
  moveToButtonCoords(i++,p);
  GuiButton middleClickBtn=new GuiSmallButton(ID_MIDDLE_CLICK,p.getX(),p.getY(),computeBooleanButtonLabel(InvTweaksConfig.PROP_ENABLE_MIDDLE_CLICK,MIDDLE_CLICK));
  controlList.add(middleClickBtn);
  if (middleClick == InvTweaksConfig.VALUE_CI_COMPATIBILITY) {
    middleClickBtn.enabled=false;
  }
  moveToButtonCoords(i++,p);
  controlList.add(new GuiSmallButton(ID_CHESTS_BUTTONS,p.getX(),p.getY(),computeBooleanButtonLabel(InvTweaksConfig.PROP_SHOW_CHEST_BUTTONS,CHEST_BUTTONS)));
  moveToButtonCoords(i++,p);
  controlList.add(new GuiSmallButton(ID_SORT_ON_PICKUP,p.getX(),p.getY(),computeBooleanButtonLabel(InvTweaksConfig.PROP_ENABLE_SORTING_ON_PICKUP,SORT_ON_PICKUP)));
  if (!Desktop.isDesktopSupported()) {
    for (    Object o : controlList) {
      GuiButton button=(GuiButton)o;
      if (button.id == ID_EDITRULES || button.id < ID_EDITTREE) {
        button.enabled=false;
      }
    }
  }
}
Program: 178176
Project: 178176
Buggy source:
private void toggleBooleanButton(GuiButton guibutton,String property,String label){
  Boolean enabled=!new Boolean(config.getProperty(property));
  config.setProperty(property,enabled.toString());
  guibutton.displayString=label + ((enabled) ? ON : OFF);
}

Fixed version (ground truth):
private void toggleBooleanButton(GuiButton guibutton,String property,String label){
  Boolean enabled=!new Boolean(config.getProperty(property));
  config.setProperty(property,enabled.toString());
  guibutton.displayString=computeBooleanButtonLabel(property,label);
}
Program: 178177
Project: 178177
Buggy source:
protected void addCategory(String parentCategory,ItemTreeCategory newCategory) throws NullPointerException {
  categories.get(parentCategory).addCategory(newCategory);
  categories.put(newCategory.getName(),newCategory);
}

Fixed version (ground truth):
protected void addCategory(String parentCategory,ItemTreeCategory newCategory) throws NullPointerException {
  categories.get(parentCategory.toLowerCase()).addCategory(newCategory);
  categories.put(newCategory.getName(),newCategory);
}
Program: 178178
Project: 178178
Buggy source:
protected void addItem(String parentCategory,ItemTreeItem newItem) throws NullPointerException {
  categories.get(parentCategory).addItem(newItem);
  if (itemsByName.containsKey(newItem.getName())) {
    itemsByName.get(newItem.getName()).add(newItem);
  }
 else {
    Vector<ItemTreeItem> list=new Vector<ItemTreeItem>();
    list.add(newItem);
    itemsByName.put(newItem.getName(),list);
  }
  if (itemsById.containsKey(newItem.getId())) {
    itemsById.get(newItem.getId()).add(newItem);
  }
 else {
    Vector<ItemTreeItem> list=new Vector<ItemTreeItem>();
    list.add(newItem);
    itemsById.put(newItem.getId(),list);
  }
}

Fixed version (ground truth):
protected void addItem(String parentCategory,ItemTreeItem newItem) throws NullPointerException {
  categories.get(parentCategory.toLowerCase()).addItem(newItem);
  if (itemsByName.containsKey(newItem.getName())) {
    itemsByName.get(newItem.getName()).add(newItem);
  }
 else {
    Vector<ItemTreeItem> list=new Vector<ItemTreeItem>();
    list.add(newItem);
    itemsByName.put(newItem.getName(),list);
  }
  if (itemsById.containsKey(newItem.getId())) {
    itemsById.get(newItem.getId()).add(newItem);
  }
 else {
    Vector<ItemTreeItem> list=new Vector<ItemTreeItem>();
    list.add(newItem);
    itemsById.put(newItem.getId(),list);
  }
}
Program: 178179
Project: 178179
Buggy source:
public ItemTreeCategory(String name){
  this.name=name;
}

Fixed version (ground truth):
public ItemTreeCategory(String name){
  this.name=(name != null) ? name.toLowerCase() : null;
}
Program: 178180
Project: 178180
Buggy source:
private boolean onTick(){
  if (!cfgManager.makeSureConfigurationIsLoaded()) {
    return false;
  }
  InvTweaksConfig config=cfgManager.getConfig();
  GuiScreen currentScreen=getCurrentScreen();
  if (currentScreen == null || currentScreen instanceof GuiInventory) {
    cloneHotbar();
  }
  if (Keyboard.isKeyDown(getKeycode(sortKeyBinding))) {
    long currentTime=System.currentTimeMillis();
    if (sortingKeyPressedDate == 0) {
      sortingKeyPressedDate=currentTime;
    }
 else     if (currentTime - sortingKeyPressedDate > Const.RULESET_SWAP_DELAY) {
      String previousRuleset=config.getCurrentRulesetName();
      String newRuleset=config.switchConfig();
      if (newRuleset == null) {
        logInGameError("String_Node_Str",null);
      }
 else       if (!previousRuleset.equals(newRuleset)) {
        logInGame("String_Node_Str" + newRuleset + "String_Node_Str");
        handleSorting(currentScreen);
      }
      sortingKeyPressedDate=currentTime;
    }
  }
 else {
    sortingKeyPressedDate=0;
  }
  return true;
}

Fixed version (ground truth):
private boolean onTick(){
  InvTweaksConfig config=cfgManager.getConfig();
  if (config == null) {
    return false;
  }
  GuiScreen currentScreen=getCurrentScreen();
  if (currentScreen == null || currentScreen instanceof GuiInventory) {
    cloneHotbar();
  }
  if (Keyboard.isKeyDown(getKeycode(sortKeyBinding))) {
    long currentTime=System.currentTimeMillis();
    if (sortingKeyPressedDate == 0) {
      sortingKeyPressedDate=currentTime;
    }
 else     if (currentTime - sortingKeyPressedDate > Const.RULESET_SWAP_DELAY) {
      String previousRuleset=config.getCurrentRulesetName();
      String newRuleset=config.switchConfig();
      if (newRuleset == null) {
        logInGameError("String_Node_Str",null);
      }
 else       if (!previousRuleset.equals(newRuleset)) {
        logInGame("String_Node_Str" + newRuleset + "String_Node_Str");
        handleSorting(currentScreen);
      }
      sortingKeyPressedDate=currentTime;
    }
  }
 else {
    sortingKeyPressedDate=0;
  }
  return true;
}
Program: 178182
Project: 178182
Buggy source:
/** 
 * Creates an instance of the mod, and loads the configuration from the files, creating them if necessary.
 * @param mc
 */
public InvTweaks(Minecraft mc){
  super(mc);
  log.setLevel(Const.DEFAULT_LOG_LEVEL);
  instance=this;
  cfgManager=new InvTweaksConfigManager(mc);
  if (cfgManager.makeSureConfigurationIsLoaded()) {
    log.info("String_Node_Str");
  }
 else {
    log.severe("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Creates an instance of the mod, and loads the configuration from the files, creating them if necessary.
 * @param mc
 */
public InvTweaks(Minecraft mc){
  super(mc);
  log.setLevel(Const.DEFAULT_LOG_LEVEL);
  instance=this;
  cfgManager=new InvTweaksConfigManager(mc);
  if (cfgManager.makeSureConfigurationIsLoaded()) {
    log.info("String_Node_Str");
    resolveConvenientInventoryConflicts();
  }
 else {
    log.severe("String_Node_Str");
  }
}
Program: 178183
Project: 178183
Buggy source:
/** 
 * Autoreplace + middle click sorting
 */
public void onTick(){
  if (config == null || onTickBusy == true)   return;
  if (Mouse.isButtonDown(2) && config.isMiddleClickEnabled())   onSortingKeyPressed();
synchronized (this) {
    onTickBusy=true;
    ItemStack currentStack=getFocusedStack();
    int currentStackId=(currentStack == null) ? 0 : getItemID(currentStack);
    int currentStackDamage=(currentStack == null) ? 0 : getItemDamage(currentStack);
    int focusedSlot=getFocusedSlot();
    if (currentStackId != storedStackId || currentStackDamage != storedStackDamage) {
      if (storedFocusedSlot != focusedSlot) {
        storedFocusedSlot=focusedSlot;
      }
 else       if ((currentStack == null || getItemID(currentStack) == 281 && storedStackId == 282) && (getCurrentScreen() == null || getCurrentScreen() instanceof GuiEditSign)) {
        sortingAlgorithm.autoReplaceSlot(focusedSlot,storedStackId,storedStackDamage);
      }
    }
    storedStackId=currentStackId;
    storedStackDamage=currentStackDamage;
  }
}

Fixed version (ground truth):
/** 
 * Autoreplace + middle click sorting
 */
public void onTick(){
  if (config == null)   return;
  if (Mouse.isButtonDown(2) && config.isMiddleClickEnabled())   onSortingKeyPressed();
synchronized (this) {
    ItemStack currentStack=getFocusedStack();
    int currentStackId=(currentStack == null) ? 0 : getItemID(currentStack);
    int currentStackDamage=(currentStack == null) ? 0 : getItemDamage(currentStack);
    int focusedSlot=getFocusedSlot();
    if (currentStackId != storedStackId || currentStackDamage != storedStackDamage) {
      if (storedFocusedSlot != focusedSlot) {
        storedFocusedSlot=focusedSlot;
      }
 else       if ((currentStack == null || getItemID(currentStack) == 281 && storedStackId == 282) && (getCurrentScreen() == null || getCurrentScreen() instanceof GuiEditSign)) {
        sortingAlgorithm.autoReplaceSlot(focusedSlot,storedStackId,storedStackDamage);
      }
    }
    storedStackId=currentStackId;
    storedStackDamage=currentStackDamage;
  }
}
Program: 178185
Project: 178185
Buggy source:
public Runnable init(InvTweaksInventory inventory,int i,int currentItem){
  this.inventory=inventory;
  this.currentItem=currentItem;
  this.expectedItemId=getItemID(inventory.getItemStack(i));
  this.i=i;
  return this;
}

Fixed version (ground truth):
public Runnable init(InvTweaksInventory inventory,int i,int currentItem){
  this.inventory=inventory;
  this.targetedSlot=currentItem;
  this.expectedItemId=getItemID(inventory.getItemStack(i));
  this.i=i;
  return this;
}
Program: 178186
Project: 178186
Buggy source:
public void run(){
  if (isMultiplayerWorld()) {
    int pollingTime=0;
    setHasInventoryChanged(false);
    while (!hasInventoryChanged() && pollingTime < POLLING_TIMEOUT) {
      trySleep(POLLING_DELAY);
    }
    if (pollingTime < AUTOREPLACE_DELAY)     trySleep(AUTOREPLACE_DELAY - pollingTime);
    if (pollingTime >= POLLING_TIMEOUT)     log.warning("String_Node_Str");
  }
 else {
    trySleep(AUTOREPLACE_DELAY);
  }
  try {
    ItemStack stack=inventory.getItemStack(i);
    if (stack != null && getItemID(stack) == expectedItemId) {
      inventory.moveStack(i,currentItem,Integer.MAX_VALUE);
    }
  }
 catch (  NullPointerException e) {
  }
}

Fixed version (ground truth):
public void run(){
  if (isMultiplayerWorld()) {
    int pollingTime=0;
    setHasInventoryChanged(false);
    while (!hasInventoryChanged() && pollingTime < POLLING_TIMEOUT) {
      trySleep(POLLING_DELAY);
    }
    if (pollingTime < AUTOREPLACE_DELAY)     trySleep(AUTOREPLACE_DELAY - pollingTime);
    if (pollingTime >= POLLING_TIMEOUT)     log.warning("String_Node_Str");
  }
 else {
    trySleep(AUTOREPLACE_DELAY);
  }
  try {
    ItemStack stack=inventory.getItemStack(i);
    if (stack != null && getItemID(stack) == expectedItemId) {
      inventory.moveStack(i,targetedSlot,Integer.MAX_VALUE);
    }
  }
 catch (  NullPointerException e) {
  }
}
Program: 178187
Project: 178187
Buggy source:
public boolean contains(String item){
  if (items.contains(item)) {
    return true;
  }
  for (  SortButtonCategory category : categories) {
    if (category.contains(item)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean contains(String item){
  if (items.contains(item)) {
    return true;
  }
  for (  SortButtonCategory category : subCategories) {
    if (category.contains(item)) {
      return true;
    }
  }
  return false;
}
Program: 178188
Project: 178188
Buggy source:
public int getKeywordPriority(String keyword){
  if (items.contains(keyword)) {
    return items.indexOf(keyword);
  }
 else   if (categories.contains(keyword)) {
    return 100;
  }
 else {
    int result;
    for (    SortButtonCategory category : categories) {
      result=category.getKeywordPriority(keyword);
      if (result != -1)       return result + 100;
    }
    return -1;
  }
}

Fixed version (ground truth):
public int getKeywordPriority(String keyword){
  if (keyword.equals(name)) {
    return 0;
  }
 else   if (items.contains(keyword)) {
    return items.size() - items.indexOf(keyword);
  }
 else {
    int result;
    for (    SortButtonCategory category : subCategories) {
      result=category.getKeywordPriority(keyword);
      if (result != -1)       return result + 100;
    }
    return -1;
  }
}
Program: 178189
Project: 178189
Buggy source:
/** 
 * Returns a references to all categories contained in this one.
 * @return
 */
public Collection<SortButtonCategory> getSubCategories(){
  return categories;
}

Fixed version (ground truth):
/** 
 * Returns a references to all categories contained in this one.
 * @return
 */
public Collection<SortButtonCategory> getSubCategories(){
  return subCategories;
}
Program: 178190
Project: 178190
Buggy source:
public SortButtonCategory addCategory(SortButtonCategory category){
  categories.add(category);
  return this;
}

Fixed version (ground truth):
public void addCategory(SortButtonCategory category){
  subCategories.add(category);
}
Program: 178191
Project: 178191
Buggy source:
/** 
 * WARNING: Currently not thread-safe
 */
public void load() throws FileNotFoundException, IOException {
  File f=new File(file);
  char[] bytes=new char[(int)f.length()];
  FileReader reader=new FileReader(f);
  reader.read(bytes);
  String[] config=String.valueOf(bytes).replace("String_Node_Str","String_Node_Str").replace('\r','\n').split("String_Node_Str");
  rules.clear();
  String lineText;
  SortButtonRule newRule;
  int currentLine=0;
  while (currentLine < config.length) {
    lineText=config[currentLine++];
    if (lineText.matches("String_Node_Str")) {
      String[] words=lineText.split("String_Node_Str");
      if (words.length == 2) {
        if (SortButtonKeywords.isValid(words[1])) {
          newRule=new SortButtonRule(words[0],words[1]);
          rules.add(newRule);
        }
 else {
          invalidKeywords.add(words[1]);
        }
      }
    }
  }
  Collections.sort(rules);
  Collections.reverse(rules);
}

Fixed version (ground truth):
/** 
 * WARNING: Currently not thread-safe
 */
public void load() throws FileNotFoundException, IOException {
  File f=new File(file);
  char[] bytes=new char[(int)f.length()];
  FileReader reader=new FileReader(f);
  reader.read(bytes);
  String[] config=String.valueOf(bytes).replace("String_Node_Str","String_Node_Str").replace('\r','\n').split("String_Node_Str");
  rules.clear();
  String lineText;
  SortButtonRule newRule;
  int currentLine=0;
  while (currentLine < config.length) {
    lineText=config[currentLine++];
    if (lineText.matches("String_Node_Str")) {
      String[] words=lineText.split("String_Node_Str");
      if (words.length == 2) {
        if (SortButtonTree.isKeywordValid(words[1])) {
          newRule=new SortButtonRule(words[0],words[1]);
          rules.add(newRule);
        }
 else {
          invalidKeywords.add(words[1]);
        }
      }
    }
  }
  Collections.sort(rules,Collections.reverseOrder());
}
Program: 178192
Project: 178192
Buggy source:
public SortButtonRule(String constraint,String keyword){
  this.keyword=keyword;
  this.constraint=constraint;
  int column=-1, row=-1;
  boolean reverse=false;
  for (int i=0; i < constraint.length(); i++) {
    char c=constraint.charAt(i);
    if (c <= '9')     column=c - '1';
 else     if (c == 'r') {
      reverse=true;
    }
 else {
switch (c) {
case 'A':
        row=1;
      break;
case 'B':
    row=2;
  break;
case 'C':
row=3;
break;
case 'D':
row=0;
}
}
}
if (column != -1 && row != -1) {
type=RuleType.TILE;
preferredPositions=new int[]{index(row,column)};
}
 else if (row != -1) {
type=RuleType.ROW;
preferredPositions=new int[9];
for (int i=0; i < 9; i++) {
preferredPositions[i]=index(row,reverse ? 8 - i : i);
}
}
 else {
type=RuleType.COLUMN;
preferredPositions=new int[]{index(0,column),index(3,column),index(2,column),index(1,column)};
}
priority=type.priority * 10000 + SortButtonKeywords.getKeywordPriority(keyword);
}

Fixed version (ground truth):
public SortButtonRule(String constraint,String keyword){
  this.keyword=keyword;
  this.constraint=constraint;
  int column=-1, row=-1;
  boolean reverse=false;
  for (int i=0; i < constraint.length(); i++) {
    char c=constraint.charAt(i);
    if (c <= '9')     column=c - '1';
 else     if (c == 'r') {
      reverse=true;
    }
 else {
switch (c) {
case 'A':
        row=1;
      break;
case 'B':
    row=2;
  break;
case 'C':
row=3;
break;
case 'D':
row=0;
}
}
}
if (column != -1 && row != -1) {
type=RuleType.TILE;
preferredPositions=new int[]{index(row,column)};
}
 else if (row != -1) {
type=RuleType.ROW;
preferredPositions=new int[9];
for (int i=0; i < 9; i++) {
preferredPositions[i]=index(row,reverse ? 8 - i : i);
}
}
 else {
type=RuleType.COLUMN;
preferredPositions=new int[]{index(0,column),index(3,column),index(2,column),index(1,column)};
}
priority=type.priority * 10000 + SortButtonTree.getKeywordPriority(keyword);
}
Program: 178193
Project: 178193
Buggy source:
/** 
 * Compares rules priority : positive value means 'this' is of greater priority than o
 */
@Override public int compareTo(SortButtonRule o){
  return this.getPriority() - o.getPriority();
}

Fixed version (ground truth):
/** 
 * Compares rules priority : positive value means 'this' is of greater priority than o
 */
@Override public int compareTo(SortButtonRule o){
  return getPriority() - o.getPriority();
}
Program: 178194
Project: 178194
Buggy source:
/** 
 * Add object from new ghost data, no corresponding change version so this came from an index request
 */
protected void addObjectWithGhost(final Ghost ghost){
  executor.execute(new Runnable(){
    @Override public void run(){
      ghostStore.saveGhost(Bucket.this,ghost);
      T object=buildObject(ghost);
      addObject(object);
    }
  }
);
}

Fixed version (ground truth):
/** 
 */
protected void addObjectWithGhost(final Ghost ghost,final Runnable runnable){
  executor.execute(new Runnable(){
    @Override public void run(){
      ghostStore.saveGhost(Bucket.this,ghost);
      T object=buildObject(ghost);
      addObject(object);
      if (runnable != null) {
        runnable.run();
      }
    }
  }
);
}
Program: 178195
Project: 178195
Buggy source:
private void notifyProgress(){
  bucket.notifyOnNetworkChangeListeners(Bucket.ChangeType.INDEX);
}

Fixed version (ground truth):
private void notifyProgress(){
  if (BuildConfig.DEBUG) {
    Log.d(TAG,"String_Node_Str" + Channel.this);
  }
  mBucket.notifyOnNetworkChangeListeners(Bucket.ChangeType.INDEX);
}
Program: 178196
Project: 178196
Buggy source:
public void next(){
  if (!queue.isEmpty()) {
    String versionString=queue.get(0);
    ObjectVersion version;
    try {
      version=ObjectVersion.parseString(versionString);
    }
 catch (    ObjectVersionParseException e) {
      Logger.log(TAG,"String_Node_Str",e);
      queue.remove(versionString);
      next();
      return;
    }
    if (!bucket.hasKeyVersion(version.getKey(),version.getVersion())) {
      sendMessage(String.format("String_Node_Str",COMMAND_ENTITY,version.toString()));
    }
 else {
      Logger.log(TAG,String.format("String_Node_Str",version));
      queue.remove(versionString);
      next();
      return;
    }
    return;
  }
  if (nextQuery != null) {
    sendMessage(nextQuery.toString());
    return;
  }
  complete=true;
  notifyDone();
}

Fixed version (ground truth):
public void next(){
  if (!mQueue.isEmpty()) {
    String versionString=mQueue.get(0);
    ObjectVersion version;
    try {
      version=ObjectVersion.parseString(versionString);
    }
 catch (    ObjectVersionParseException e) {
      Logger.log(TAG,"String_Node_Str",e);
      mQueue.remove(versionString);
      next();
      return;
    }
    if (!mBucket.hasKeyVersion(version.getKey(),version.getVersion())) {
      sendMessage(String.format("String_Node_Str",COMMAND_ENTITY,version.toString()));
    }
 else {
      Logger.log(TAG,String.format("String_Node_Str",version));
      mQueue.remove(versionString);
      next();
      return;
    }
    return;
  }
  if (mNextQuery != null) {
    sendMessage(mNextQuery.toString());
    return;
  }
  mComplete=true;
  if (BuildConfig.DEBUG) {
    Log.d(TAG,"String_Node_Str" + Channel.this);
  }
  if (mReceivedCount == mIndexedCount) {
    notifyDone();
  }
}
Program: 178198
Project: 178198
Buggy source:
public IndexProcessor(Bucket bucket,String cv,IndexProcessorListener listener){
  this.bucket=bucket;
  this.cv=cv;
  this.listener=listener;
}

Fixed version (ground truth):
public IndexProcessor(Bucket bucket,String cv,IndexProcessorListener listener){
  mBucket=bucket;
  mCv=cv;
  mListener=listener;
}
Program: 178199
Project: 178199
Buggy source:
/** 
 * Receive an object's version data and store it. Send the request for the next object.
 */
public void addObjectData(ObjectVersionData objectVersion) throws ObjectVersionUnexpectedException {
  if (!queue.remove(objectVersion.toString()))   throw new ObjectVersionUnexpectedException(objectVersion);
  Ghost ghost=new Ghost(objectVersion.getKey(),objectVersion.getVersion(),objectVersion.getData());
  bucket.addObjectWithGhost(ghost);
  indexedCount++;
  if (indexedCount % 10 == 0) {
    notifyProgress();
  }
  next();
}

Fixed version (ground truth):
/** 
 * Receive an object's version data and store it. Send the request for the next object.
 */
public void addObjectData(ObjectVersionData objectVersion) throws ObjectVersionUnexpectedException {
  if (!mQueue.remove(objectVersion.toString()))   throw new ObjectVersionUnexpectedException(objectVersion);
  Ghost ghost=new Ghost(objectVersion.getKey(),objectVersion.getVersion(),objectVersion.getData());
  mBucket.addObjectWithGhost(ghost,new Runnable(){
    @Override public void run(){
synchronized (mCountLock) {
        mIndexedCount++;
        if (mIndexedCount % 10 == 0) {
          notifyProgress();
        }
      }
      if (mComplete && mReceivedCount == mIndexedCount) {
        notifyDone();
      }
    }
  }
);
  next();
}
Program: 178200
Project: 178200
Buggy source:
private void notifyDone(){
  bucket.indexComplete(cv);
  listener.onComplete(cv);
}

Fixed version (ground truth):
synchronized private void notifyDone(){
  if (mNotified) {
    return;
  }
  mNotified=true;
  if (BuildConfig.DEBUG) {
    Log.d(TAG,"String_Node_Str" + Channel.this);
  }
  mBucket.indexComplete(mCv);
  mListener.onComplete(mCv);
}
Program: 178201
Project: 178201
Buggy source:
/** 
 * If the index is done processing
 */
public boolean isComplete(){
  return complete;
}

Fixed version (ground truth):
/** 
 * If the index is done processing
 */
public boolean isComplete(){
  return mComplete;
}
Program: 178202
Project: 178202
Buggy source:
public void testApplyRemoteChange() throws Exception {
  Note note=mBucket.newObject();
  note.setContent("String_Node_Str");
  note.save();
  JSONObject external=new JSONObject(note.getDiffableValue().toString());
  external.put("String_Node_Str","String_Node_Str");
  RemoteChange change=RemoteChangesUtil.buildRemoteChange(note,external);
  mBucket.applyRemoteChange(change);
  assertEquals("String_Node_Str",note.getContent());
}

Fixed version (ground truth):
public void testApplyRemoteChange() throws Exception {
  Note note=mBucket.newObject();
  note.setContent("String_Node_Str");
  note.save();
  JSONObject external=new JSONObject(note.getDiffableValue().toString());
  external.put("String_Node_Str","String_Node_Str");
  note.setTitle("String_Node_Str");
  RemoteChange change=RemoteChangesUtil.buildRemoteChange(note,external);
  mBucket.applyRemoteChange(change);
  assertEquals("String_Node_Str",note.getContent());
}
Program: 178203
Project: 178203
Buggy source:
public void testTransformStringDiff() throws Exception {
  String origin="String_Node_Str";
  String target="String_Node_Str";
  JSONObject diff_1=JSONDiff.diff(origin,"String_Node_Str");
  JSONObject diff_2=JSONDiff.diff(origin,"String_Node_Str");
  JSONObject transformed=JSONDiff.transform(diff_2.getString("String_Node_Str"),diff_1.getString("String_Node_Str"),origin);
  assertEquals(target,JSONDiff.apply(origin,transformed));
}

Fixed version (ground truth):
public void testTransformStringDiff() throws Exception {
  String origin="String_Node_Str";
  String target="String_Node_Str";
  JSONObject diff_1=JSONDiff.diff(origin,"String_Node_Str");
  JSONObject diff_2=JSONDiff.diff(origin,"String_Node_Str");
  JSONObject transformed=JSONDiff.transform(diff_2.getString("String_Node_Str"),diff_1.getString("String_Node_Str"),origin);
  assertEquals(target,JSONDiff.apply(JSONDiff.apply(origin,diff_1),transformed));
}
Program: 178205
Project: 178205
Buggy source:
/** 
 * Change queue processes one change per run. If it has more work to do it schedules itself on the executor.
 */
public void run(){
  if (!haveCompleteIndex())   return;
  try {
    if (!started || Thread.interrupted())     throw new InterruptedException();
    idle=false;
    Logger.log(TAG,String.format("String_Node_Str",Thread.currentThread().getName()));
    if (!remoteQueue.isEmpty()) {
      processRemoteChange();
      executor.execute(this);
      return;
    }
    if (!localQueue.isEmpty()) {
      Logger.log(TAG,"String_Node_Str");
      if (processLocalChange()) {
        executor.execute(this);
      }
      ;
      return;
    }
  }
 catch (  InterruptedException e) {
    Logger.log(TAG,String.format("String_Node_Str",getBucketName(),Thread.currentThread().getName()));
  }
  Logger.log(TAG,"String_Node_Str");
  idle=true;
}

Fixed version (ground truth):
/** 
 * Change queue processes one change per run. If it has more work to do it schedules itself on the executor.
 */
public void run(){
  if (!haveCompleteIndex())   return;
  try {
    if (!started || Thread.interrupted())     throw new InterruptedException();
    idle=false;
    Logger.log(TAG,String.format("String_Node_Str",Thread.currentThread().getName()));
    if (!remoteQueue.isEmpty()) {
      processRemoteChange();
      executor.execute(this);
      return;
    }
    if (!localQueue.isEmpty()) {
      Logger.log(TAG,"String_Node_Str");
      if (processLocalChange()) {
        executor.execute(this);
      }
      return;
    }
  }
 catch (  InterruptedException e) {
    Logger.log(TAG,String.format("String_Node_Str",getBucketName(),Thread.currentThread().getName()));
  }
  Logger.log(TAG,"String_Node_Str");
  idle=true;
}
Program: 178207
Project: 178207
Buggy source:
public Schema(String name){
  this.remoteName=remoteName;
}

Fixed version (ground truth):
public Schema(String name){
  this.remoteName=name;
}
Program: 178209
Project: 178209
Buggy source:
public DocumentFragment generate(NodeList nl,NodeList tedxml) throws SAXException {
  HashMap<String,String> namespaces=new HashMap<String,String>();
  namespaces.put("String_Node_Str","String_Node_Str");
  XmlOptions opts=new XmlOptions();
  opts.setLoadSubstituteNamespaces(namespaces);
  TEDType ted;
  try {
    ted=TEDType.Factory.parse(tedxml.item(0),opts);
    String msg=new String(XMLUtil.getCleaned(ted));
    return generate(nl,msg);
  }
 catch (  XmlException e) {
    e.printStackTrace();
    throw new SAXException(e);
  }
}

Fixed version (ground truth):
public DocumentFragment generate(NodeList nl,NodeList tedxml) throws SAXException {
  HashMap<String,String> namespaces=new HashMap<String,String>();
  namespaces.put("String_Node_Str","String_Node_Str");
  XmlOptions opts=new XmlOptions();
  opts.setLoadSubstituteNamespaces(namespaces);
  TEDType ted;
  try {
    ted=TEDType.Factory.parse(tedxml.item(0),opts);
    String msg=null;
    try {
      msg=new String(XMLUtil.getCleaned(ted),"String_Node_Str");
    }
 catch (    UnsupportedEncodingException e) {
      e.printStackTrace();
    }
    System.out.println(msg);
    return generate(nl,msg);
  }
 catch (  XmlException e) {
    e.printStackTrace();
    throw new SAXException(e);
  }
}
Program: 178210
Project: 178210
Buggy source:
/** 
 * Obtiene una representaci&oacute;n "limpia" de un elemento XML, esto quiere decir, sin espacios ni nuevas l&iacute;neas entre tags. Este m&eacute;todo se utiliza en la generaci&oacute;n PDF del &lt;TED&gt;.
 * @param xml El nodo XML
 * @return El arreglo de bytes codificado con ISO-8859-1 (norma exigida porSII) del contenido del nodo (incluyendo los tags y caracteres especiales de XML como &amp;).
 */
public static byte[] getCleaned(XmlObject xml){
  try {
    ByteArrayOutputStream out=new ByteArrayOutputStream();
    XmlOptions opts=new XmlOptions();
    HashMap<String,String> namespaces=new HashMap<String,String>();
    namespaces.put("String_Node_Str","String_Node_Str");
    opts.setCharacterEncoding("String_Node_Str");
    opts.setSaveImplicitNamespaces(namespaces);
    opts.setSaveOuter();
    opts.setSavePrettyPrint();
    opts.setSavePrettyPrintIndent(0);
    opts.setSaveNoXmlDecl();
    xml.save(out,opts);
    return out.toString("String_Node_Str").replaceAll("String_Node_Str","String_Node_Str").getBytes("String_Node_Str");
  }
 catch (  UnsupportedEncodingException e) {
    e.printStackTrace();
    return null;
  }
catch (  IOException e) {
    e.printStackTrace();
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Obtiene una representaci&oacute;n "limpia" de un elemento XML, esto quiere decir, sin espacios ni nuevas l&iacute;neas entre tags. Este m&eacute;todo se utiliza en la generaci&oacute;n PDF del &lt;TED&gt;.
 * @param xml El nodo XML
 * @return El arreglo de bytes codificado con ISO-8859-1 (norma exigida porSII) del contenido del nodo (incluyendo los tags y caracteres especiales de XML como &amp;).
 */
public static byte[] getCleaned(XmlObject xml){
  try {
    ByteArrayOutputStream out=new ByteArrayOutputStream();
    XmlOptions opts=new XmlOptions();
    HashMap<String,String> namespaces=new HashMap<String,String>();
    namespaces.put("String_Node_Str","String_Node_Str");
    opts.setCharacterEncoding("String_Node_Str");
    opts.setSaveImplicitNamespaces(namespaces);
    opts.setSaveOuter();
    opts.setSavePrettyPrintIndent(0);
    opts.setSaveNoXmlDecl();
    xml.save(out,opts);
    return out.toString("String_Node_Str").replaceAll("String_Node_Str","String_Node_Str").getBytes("String_Node_Str");
  }
 catch (  UnsupportedEncodingException e) {
    e.printStackTrace();
    return null;
  }
catch (  IOException e) {
    e.printStackTrace();
    return null;
  }
}