nus-yam/ex-repair huggingface dataset:
Program: 17169
Project: 17169
Buggy source:
@EventHandler(priority=EventPriority.LOWEST) public static void onPreShopCreation(PreShopCreationEvent event){
  String itemCode=event.getSignLine(ITEM_LINE);
  ItemStack item=MaterialUtil.getItem(itemCode);
  if (item == null) {
    event.setOutcome(INVALID_ITEM);
    return;
  }
  if (Odd.getFromString(itemCode) != null) {
    return;
  }
  String metadata=getMetadata(itemCode);
  String longName=MaterialUtil.getName(item,LONG_NAME);
  if (longName.length() <= (MAXIMUM_SIGN_LETTERS - metadata.length())) {
    if (isStillValidItem(longName + metadata,item)) {
      String itemName=StringUtil.capitalizeFirstLetter(longName + metadata);
      event.setSignLine(ITEM_LINE,itemName);
      return;
    }
  }
  String code=MaterialUtil.getName(item,SHORT_NAME);
  String[] parts=itemCode.split("String_Node_Str",2);
  String data=(parts.length > 1 ? parts[1] : "String_Node_Str");
  if (!data.isEmpty() && code.length() >= (MAXIMUM_SIGN_LETTERS - 1 - data.length())) {
    code=code.substring(0,MAXIMUM_SIGN_LETTERS - 1 - data.length()) + data;
  }
  if (!isStillValidItem(code,item)) {
    code=String.valueOf(item.getTypeId()) + data;
  }
  code=StringUtil.capitalizeFirstLetter(code);
  event.setSignLine(ITEM_LINE,code);
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOWEST) public static void onPreShopCreation(PreShopCreationEvent event){
  String itemCode=event.getSignLine(ITEM_LINE);
  ItemStack item=MaterialUtil.getItem(itemCode);
  if (item == null) {
    event.setOutcome(INVALID_ITEM);
    return;
  }
  if (Odd.getFromString(itemCode) != null) {
    return;
  }
  String metadata=getMetadata(itemCode);
  String longName=MaterialUtil.getName(item);
  if (longName.length() <= (MAXIMUM_SIGN_LETTERS - metadata.length())) {
    if (isSameItem(longName + metadata,item)) {
      String itemName=StringUtil.capitalizeFirstLetter(longName + metadata);
      event.setSignLine(ITEM_LINE,itemName);
      return;
    }
  }
  String code=MaterialUtil.getName(item,SHORT_NAME);
  String[] parts=itemCode.split("String_Node_Str",2);
  String data=(parts.length > 1 ? parts[1] : "String_Node_Str");
  if (!data.isEmpty() && code.length() > (MAXIMUM_SIGN_LETTERS - data.length())) {
    code=code.substring(0,MAXIMUM_SIGN_LETTERS - data.length());
  }
  code+=data;
  if (!isSameItem(code,item)) {
    code=String.valueOf(item.getTypeId()) + data;
  }
  code=StringUtil.capitalizeFirstLetter(code);
  event.setSignLine(ITEM_LINE,code);
}
Program: 17170
Project: 17170
Buggy source:
/** 
 * Adds an item to the inventory (it currently uses a custom method of adding items, because Bukkit hasn't fixed it for 6 months now)
 * @param item      Item to add
 * @param inventory Inventory
 * @return Number of leftover items
 */
public static int add(ItemStack item,Inventory inventory){
  if (item.getAmount() < 1) {
    return 0;
  }
  int amountLeft=item.getAmount();
  int maxStackSize=item.getMaxStackSize();
  for (int currentSlot=0; currentSlot < inventory.getSize() && amountLeft > 0; currentSlot++) {
    ItemStack currentItem=inventory.getItem(currentSlot);
    ItemStack duplicate=item.clone();
    if (MaterialUtil.isEmpty(currentItem)) {
      duplicate.setAmount(Math.min(duplicate.getAmount(),maxStackSize));
      duplicate.addEnchantments(item.getEnchantments());
      amountLeft-=duplicate.getAmount();
      inventory.setItem(currentSlot,duplicate);
    }
 else     if (currentItem.getAmount() < maxStackSize && MaterialUtil.equals(currentItem,item)) {
      int currentAmount=currentItem.getAmount();
      int neededToAdd=Math.min(maxStackSize - currentAmount,amountLeft);
      duplicate.setAmount(currentAmount + neededToAdd);
      duplicate.addEnchantments(item.getEnchantments());
      amountLeft-=duplicate.getAmount();
      inventory.setItem(currentSlot,duplicate);
    }
  }
  return amountLeft;
}

Fixed version (ground truth):
/** 
 * Adds an item to the inventory (it currently uses a custom method of adding items, because Bukkit hasn't fixed it for 6 months now)
 * @param item      Item to add
 * @param inventory Inventory
 * @return Number of leftover items
 */
public static int add(ItemStack item,Inventory inventory){
  if (item.getAmount() < 1) {
    return 0;
  }
  int amountLeft=item.getAmount();
  int maxStackSize=item.getMaxStackSize();
  for (int currentSlot=0; currentSlot < inventory.getSize() && amountLeft > 0; currentSlot++) {
    ItemStack currentItem=inventory.getItem(currentSlot);
    ItemStack duplicate=item.clone();
    if (MaterialUtil.isEmpty(currentItem)) {
      duplicate.setAmount(Math.min(amountLeft,maxStackSize));
      duplicate.addEnchantments(item.getEnchantments());
      amountLeft-=duplicate.getAmount();
      inventory.setItem(currentSlot,duplicate);
    }
 else     if (currentItem.getAmount() < maxStackSize && MaterialUtil.equals(currentItem,item)) {
      int currentAmount=currentItem.getAmount();
      int neededToAdd=Math.min(maxStackSize - currentAmount,amountLeft);
      duplicate.setAmount(currentAmount + neededToAdd);
      duplicate.addEnchantments(item.getEnchantments());
      amountLeft-=duplicate.getAmount();
      inventory.setItem(currentSlot,duplicate);
    }
  }
  return amountLeft;
}
Program: 17171
Project: 17171
Buggy source:
@EventHandler public static void onInventoryOpen(InventoryOpenEvent event){
  if (event.getInventory().getType() != InventoryType.CHEST) {
    return;
  }
  if (!Config.getBoolean(TURN_OFF_DEFAULT_PROTECTION_WHEN_PROTECTED_EXTERNALLY)) {
    return;
  }
  HumanEntity entity=event.getPlayer();
  if (!(entity instanceof Player) || (!(event.getInventory().getHolder() instanceof Chest) && !(event.getInventory().getHolder() instanceof DoubleChest))) {
    return;
  }
  Player player=(Player)entity;
  Block chest=((BlockState)event.getInventory().getHolder()).getBlock();
  if (!PlayerInteract.canOpenOtherShops(player) && !ChestShop.canAccess(player,chest)) {
    player.sendMessage(Config.getLocal(ACCESS_DENIED));
    event.setCancelled(true);
  }
}

Fixed version (ground truth):
@EventHandler public static void onInventoryOpen(InventoryOpenEvent event){
  if (event.getInventory().getType() != InventoryType.CHEST) {
    return;
  }
  if (!Properties.TURN_OFF_DEFAULT_PROTECTION_WHEN_PROTECTED_EXTERNALLY) {
    return;
  }
  HumanEntity entity=event.getPlayer();
  if (!(entity instanceof Player) || (!(event.getInventory().getHolder() instanceof Chest) && !(event.getInventory().getHolder() instanceof DoubleChest))) {
    return;
  }
  Player player=(Player)entity;
  Block chest;
  if (event.getInventory().getHolder() instanceof Chest) {
    chest=((BlockState)event.getInventory().getHolder()).getBlock();
  }
 else {
    chest=((DoubleChest)event.getInventory().getHolder()).getLocation().getBlock();
  }
  if (!PlayerInteract.canOpenOtherShops(player) && !ChestShop.canAccess(player,chest)) {
    player.sendMessage(Messages.prefix(Messages.ACCESS_DENIED));
    event.setCancelled(true);
  }
}
Program: 17172
Project: 17172
Buggy source:
/** 
 * Adds an item to the inventory (it currently uses a custom method of adding items, because Bukkit hasn't fixed it for 6 months now)
 * @param item      Item to add
 * @param inventory Inventory
 * @return Number of leftover items
 */
public static int add(ItemStack item,Inventory inventory){
  if (item.getAmount() < 1) {
    return 0;
  }
  int amountLeft=item.getAmount();
  int maxStackSize=item.getMaxStackSize();
  for (int currentSlot=0; currentSlot < inventory.getSize() && amountLeft > 0; currentSlot++) {
    ItemStack currentItem=inventory.getItem(currentSlot);
    ItemStack duplicate=item.clone();
    if (MaterialUtil.isEmpty(currentItem)) {
      duplicate.setAmount(Math.min(amountLeft,maxStackSize));
      duplicate.addEnchantments(item.getEnchantments());
      amountLeft-=duplicate.getAmount();
      inventory.setItem(currentSlot,duplicate);
    }
 else     if (currentItem.getAmount() < maxStackSize && MaterialUtil.equals(currentItem,item)) {
      int currentAmount=currentItem.getAmount();
      int neededToAdd=Math.min(maxStackSize - currentAmount,amountLeft);
      duplicate.setAmount(currentAmount + neededToAdd);
      duplicate.addEnchantments(item.getEnchantments());
      amountLeft-=duplicate.getAmount();
      inventory.setItem(currentSlot,duplicate);
    }
  }
  return amountLeft;
}

Fixed version (ground truth):
/** 
 * Adds an item to the inventory (it currently uses a custom method of adding items, because Bukkit hasn't fixed it for 6 months now)
 * @param item      Item to add
 * @param inventory Inventory
 * @return Number of leftover items
 */
public static int add(ItemStack item,Inventory inventory){
  if (item.getAmount() < 1) {
    return 0;
  }
  int amountLeft=item.getAmount();
  int maxStackSize=item.getMaxStackSize();
  for (int currentSlot=0; currentSlot < inventory.getSize() && amountLeft > 0; currentSlot++) {
    ItemStack currentItem=inventory.getItem(currentSlot);
    ItemStack duplicate=item.clone();
    if (MaterialUtil.isEmpty(currentItem)) {
      duplicate.setAmount(Math.min(amountLeft,maxStackSize));
      duplicate.addEnchantments(item.getEnchantments());
      amountLeft-=duplicate.getAmount();
      inventory.setItem(currentSlot,duplicate);
    }
 else     if (currentItem.getAmount() < maxStackSize && MaterialUtil.equals(currentItem,item)) {
      int currentAmount=currentItem.getAmount();
      int neededToAdd=Math.min(maxStackSize - currentAmount,amountLeft);
      duplicate.setAmount(currentAmount + neededToAdd);
      duplicate.addEnchantments(item.getEnchantments());
      amountLeft-=neededToAdd;
      inventory.setItem(currentSlot,duplicate);
    }
  }
  return amountLeft;
}
Program: 17173
Project: 17173
Buggy source:
private static boolean canDestroyShop(Player player,String name){
  return player == null || hasShopBreakingPermission(player) || canUseName(player,name);
}

Fixed version (ground truth):
private static boolean canDestroyShop(Player player,String name){
  return player != null && (hasShopBreakingPermission(player) || canUseName(player,name));
}
Program: 17174
Project: 17174
Buggy source:
/** 
 * Returns enchantments this itemName contains
 * @param base32 The encoded enchantment
 * @return Enchantments found
 */
public static Map<org.bukkit.enchantments.Enchantment,Integer> getEnchantments(String base32){
  if (base32 == null || base32.isEmpty()) {
    return new HashMap<org.bukkit.enchantments.Enchantment,Integer>();
  }
  Map<org.bukkit.enchantments.Enchantment,Integer> map=new HashMap<org.bukkit.enchantments.Enchantment,Integer>();
  StringBuilder number=new StringBuilder(Long.toString(Long.parseLong(base32,32)));
  while (number.length() % 3 != 0) {
    number.insert(0,'0');
  }
  for (int i=0; i < number.length() / 3; i++) {
    String item=number.substring(i * 3,i * 3 + 3);
    org.bukkit.enchantments.Enchantment enchantment=org.bukkit.enchantments.Enchantment.getById(Integer.parseInt(item.substring(0,2)));
    if (enchantment == null) {
      continue;
    }
    int level=Integer.parseInt(item.substring(2));
    if (level > enchantment.getMaxLevel() || level < enchantment.getStartLevel()) {
      continue;
    }
    map.put(enchantment,level);
  }
  return map;
}

Fixed version (ground truth):
/** 
 * Returns enchantments this itemName contains
 * @param base32 The encoded enchantment
 * @return Enchantments found
 */
public static Map<org.bukkit.enchantments.Enchantment,Integer> getEnchantments(String base32){
  if (base32 == null || base32.isEmpty() || !NumberUtil.isLong(base32)) {
    return new HashMap<org.bukkit.enchantments.Enchantment,Integer>();
  }
  Map<org.bukkit.enchantments.Enchantment,Integer> map=new HashMap<org.bukkit.enchantments.Enchantment,Integer>();
  StringBuilder number=new StringBuilder(Long.toString(Long.parseLong(base32,32)));
  while (number.length() % 3 != 0) {
    number.insert(0,'0');
  }
  for (int i=0; i < number.length() / 3; i++) {
    String item=number.substring(i * 3,i * 3 + 3);
    org.bukkit.enchantments.Enchantment enchantment=org.bukkit.enchantments.Enchantment.getById(Integer.parseInt(item.substring(0,2)));
    if (enchantment == null) {
      continue;
    }
    int level=Integer.parseInt(item.substring(2));
    if (level > enchantment.getMaxLevel() || level < enchantment.getStartLevel()) {
      continue;
    }
    map.put(enchantment,level);
  }
  return map;
}
Program: 17175
Project: 17175
Buggy source:
@EventHandler public static void onSellItemCheck(PreTransactionEvent event){
  if (event.isCancelled() || event.getTransactionType() != SELL) {
    return;
  }
  ItemStack[] stock=event.getStock();
  Inventory clientInventory=event.getClientInventory();
  if (!Economy.hasEnough(event.getOwner().getName(),event.getPrice())) {
    event.setCancelled(SHOP_DOES_NOT_HAVE_ENOUGH_MONEY);
    return;
  }
  if (!hasItems(clientInventory,stock)) {
    event.setCancelled(NOT_ENOUGH_STOCK_IN_INVENTORY);
  }
}

Fixed version (ground truth):
@EventHandler public static void onSellItemCheck(PreTransactionEvent event){
  if (event.isCancelled() || event.getTransactionType() != SELL) {
    return;
  }
  ItemStack[] stock=event.getStock();
  Inventory clientInventory=event.getClientInventory();
  if (isOwnerEconomicalyActive(event) && !Economy.hasEnough(event.getOwner().getName(),event.getPrice())) {
    event.setCancelled(SHOP_DOES_NOT_HAVE_ENOUGH_MONEY);
    return;
  }
  if (!hasItems(clientInventory,stock)) {
    event.setCancelled(NOT_ENOUGH_STOCK_IN_INVENTORY);
  }
}
Program: 17177
Project: 17177
Buggy source:
private Language sell(Player player){
  double price=getSellPrice(sign.getLine(PRICE_LINE));
  if (container == null) {
    return NO_CHEST_DETECTED;
  }
  if (price == PriceUtil.NO_PRICE) {
    return NO_SELLING_HERE;
  }
  if (!hasPermission(player,stock.getType(),false)) {
    return NO_PERMISSION;
  }
  String ownerAccount=getOwnerAccount();
  if (!Economy.hasEnough(ownerAccount,price)) {
    int possiblePartialItemCount=calculateItemAmount(Economy.balance(ownerAccount),price);
    if (!partialTransactionAllowed(possiblePartialItemCount)) {
      return NOT_ENOUGH_MONEY_SHOP;
    }
 else {
      price=(price / stock.getAmount()) * possiblePartialItemCount;
      stock.setAmount(possiblePartialItemCount);
    }
  }
  if (!playerHasEnoughItems(player)) {
    int possiblePartialItemCount=InventoryUtil.getAmount(stock,player.getInventory());
    if (!partialTransactionAllowed(possiblePartialItemCount)) {
      return NOT_ENOUGH_ITEMS_TO_SELL;
    }
 else {
      price=(price / stock.getAmount()) * possiblePartialItemCount;
      stock.setAmount(possiblePartialItemCount);
    }
  }
  if (!stockFitsChest()) {
    return NOT_ENOUGH_SPACE_IN_CHEST;
  }
  Economy.subtract(ownerAccount,price);
  Economy.add(player.getName(),price);
  container.addItem(stock);
  InventoryUtil.remove(stock,player.getInventory());
  player.updateInventory();
  TransactionEvent event=new TransactionEvent(SELL,container,sign,player,this.owner,stock,price);
  ChestShop.callEvent(event);
  return null;
}

Fixed version (ground truth):
private Language sell(Player player){
  double price=getSellPrice(sign.getLine(PRICE_LINE));
  if (container == null) {
    return NO_CHEST_DETECTED;
  }
  if (price == PriceUtil.NO_PRICE) {
    return NO_SELLING_HERE;
  }
  if (!hasPermission(player,stock.getType(),false)) {
    return NO_PERMISSION;
  }
  String ownerAccount=getOwnerAccount();
  if (!Economy.hasEnough(ownerAccount,price)) {
    int possiblePartialItemCount=calculateItemAmount(Economy.balance(ownerAccount),price);
    if (!partialTransactionAllowed(possiblePartialItemCount)) {
      return NOT_ENOUGH_MONEY_SHOP;
    }
 else {
      price=(price / stock.getAmount()) * possiblePartialItemCount;
      stock.setAmount(possiblePartialItemCount);
    }
  }
  if (!playerHasEnoughItems(player)) {
    int possiblePartialItemCount=InventoryUtil.getAmount(stock,player.getInventory());
    if (!partialTransactionAllowed(possiblePartialItemCount)) {
      return NOT_ENOUGH_ITEMS_TO_SELL;
    }
 else {
      price=(price / stock.getAmount()) * possiblePartialItemCount;
      stock.setAmount(possiblePartialItemCount);
    }
  }
  if (!stockFitsChest()) {
    return NOT_ENOUGH_SPACE_IN_CHEST;
  }
  Economy.subtract(ownerAccount,price);
  Economy.add(player.getName(),price);
  container.addItem(stock.clone());
  InventoryUtil.remove(stock.clone(),player.getInventory());
  player.updateInventory();
  TransactionEvent event=new TransactionEvent(SELL,container,sign,player,this.owner,stock,price);
  ChestShop.callEvent(event);
  return null;
}
Program: 17178
Project: 17178
Buggy source:
public Shop(Container container,ItemStack stock,Sign sign){
  this.container=container;
  this.owner=sign.getLine(NAME_LINE);
  this.stock=stock;
  this.sign=sign;
}

Fixed version (ground truth):
public Shop(Container container,ItemStack stock,Sign sign){
  this.container=container;
  this.sign=sign;
  this.owner=sign.getLine(NAME_LINE);
  this.stock=stock;
}
Program: 17179
Project: 17179
Buggy source:
public static void add(String name,double amount){
  if (!hasAccount(name)) {
    return;
  }
  String serverAccount=Config.getString(Property.SERVER_ECONOMY_ACCOUNT);
  Property taxAmount=name.equals(serverAccount) ? Property.SERVER_TAX_AMOUNT : Property.TAX_AMOUNT;
  if (Config.getFloat(taxAmount) != 0) {
    double tax=getTax(taxAmount,amount);
    if (!serverAccount.isEmpty()) {
      economy.add(serverAccount,tax);
    }
    amount-=tax;
  }
  economy.add(uName.getName(name),roundUp(amount));
}

Fixed version (ground truth):
public static void add(String name,double amount){
  Property taxAmount=isServerAccount(name) ? Property.SERVER_TAX_AMOUNT : Property.TAX_AMOUNT;
  double tax=getTax(taxAmount,amount);
  if (tax != 0) {
    if (!serverAccount().isEmpty()) {
      economy.add(serverAccount(),tax);
    }
    amount-=tax;
  }
  if (name.isEmpty())   return;
  economy.add(uName.getName(name),amount);
}
Program: 17180
Project: 17180
Buggy source:
public static boolean hasEnough(String name,double amount){
  if (!hasAccount(name)) {
    return true;
  }
  return economy.hasEnough(uName.getName(name),roundUp(amount));
}

Fixed version (ground truth):
public static boolean hasEnough(String name,double amount){
  if (isServerAccount(name)) {
    return true;
  }
  return economy.hasEnough(uName.getName(name),roundUp(amount));
}
Program: 17181
Project: 17181
Buggy source:
public static void subtract(String name,double amount){
  if (!hasAccount(name)) {
    return;
  }
  economy.subtract(uName.getName(name),roundUp(amount));
}

Fixed version (ground truth):
public static void subtract(String name,double amount){
  if (name.isEmpty())   return;
  economy.subtract(uName.getName(name),roundUp(amount));
}
Program: 17182
Project: 17182
Buggy source:
public static double getTax(Property tax,double price){
  return (Config.getFloat(tax) / 100F) * price;
}

Fixed version (ground truth):
public static double getTax(Property tax,double price){
  return roundDown((Config.getFloat(tax) / 100F) * price);
}
Program: 17183
Project: 17183
Buggy source:
/** 
 * Has the server owner denied plugin metrics?
 * @return
 */
public boolean isOptOut(){
synchronized (optOutLock) {
    try {
      configuration.load(CONFIG_FILE);
    }
 catch (    IOException ex) {
      Bukkit.getLogger().log(Level.INFO,"String_Node_Str",ex.getMessage());
      return true;
    }
catch (    InvalidConfigurationException ex) {
      Bukkit.getLogger().log(Level.INFO,"String_Node_Str",ex.getMessage());
      return true;
    }
    return configuration.getBoolean("String_Node_Str",false);
  }
}

Fixed version (ground truth):
/** 
 * Has the server owner denied plugin metrics?
 * @return
 */
public boolean isOptOut(){
synchronized (optOutLock) {
    try {
      configuration.load(CONFIG_FILE);
    }
 catch (    IOException ex) {
      Bukkit.getLogger().log(Level.INFO,"String_Node_Str" + ex.getMessage());
      return true;
    }
catch (    InvalidConfigurationException ex) {
      Bukkit.getLogger().log(Level.INFO,"String_Node_Str" + ex.getMessage());
      return true;
    }
    return configuration.getBoolean("String_Node_Str",false);
  }
}
Program: 17184
Project: 17184
Buggy source:
public static boolean cancellingBlockBreak(Block block,Player player){
  if (block == null)   return false;
  if (player != null && (Permission.has(player,Permission.ADMIN) || Permission.has(player,Permission.MOD)))   return false;
  if (uSign.isSign(block))   block.getState().update();
  if (restrictedSign(block))   return !restrictedSign.canDestroy(player,uBlock.findRestrictedSign(block));
  Sign sign=uBlock.findSign(block,(player != null ? uLongName.stripName(player.getName()) : null));
  if (!isCorrectSign(sign,block))   return false;
  if (playerIsNotOwner(player,sign))   return true;
  if (weShouldReturnMoney() && !Permission.has(player,Permission.NOFEE)) {
    float refundPrice=Config.getFloat(Property.SHOP_REFUND_PRICE);
    Economy.add(uLongName.getName(sign.getLine(0)),refundPrice);
    player.sendMessage(Config.getLocal(Language.SHOP_REFUNDED).replace("String_Node_Str",Economy.formatBalance(refundPrice)));
  }
  return false;
}

Fixed version (ground truth):
public static boolean cancellingBlockBreak(Block block,Player player){
  if (block == null)   return false;
  if (uSign.isSign(block))   block.getState().update();
  if (restrictedSign(block))   return !restrictedSign.canDestroy(player,uBlock.findRestrictedSign(block));
  Sign sign=uBlock.findSign(block,(player != null ? uLongName.stripName(player.getName()) : null));
  if (!isCorrectSign(sign,block))   return false;
  if (playerIsNotOwner(player,sign))   return !isAdmin(player);
  if (weShouldReturnMoney() && !Permission.has(player,Permission.NOFEE)) {
    float refundPrice=Config.getFloat(Property.SHOP_REFUND_PRICE);
    Economy.add(uLongName.getName(sign.getLine(0)),refundPrice);
    player.sendMessage(Config.getLocal(Language.SHOP_REFUNDED).replace("String_Node_Str",Economy.formatBalance(refundPrice)));
  }
  return false;
}
Program: 17185
Project: 17185
Buggy source:
public boolean protect(String name,Block block){
  if (lwc.findProtection(block) != null)   return false;
  Player player=ChestShop.getBukkitServer().getPlayer(name);
  if (player != null && limitsModule.hasReachedLimit(player,block))   return false;
  lwc.getPhysicalDatabase().registerProtection(block.getTypeId(),com.griefcraft.model.Protection.Type.PUBLIC,block.getWorld().getName(),name,"String_Node_Str",block.getX(),block.getY(),block.getZ());
  return true;
}

Fixed version (ground truth):
public boolean protect(String name,Block block){
  if (lwc.findProtection(block) != null)   return false;
  Player player=ChestShop.getBukkitServer().getPlayer(name);
  if (player != null && limitsModule.hasReachedLimit(player,block))   return false;
  lwc.getPhysicalDatabase().registerProtection(block.getTypeId(),com.griefcraft.model.Protection.Type.PRIVATE,block.getWorld().getName(),name,"String_Node_Str",block.getX(),block.getY(),block.getZ());
  return true;
}
Program: 17186
Project: 17186
Buggy source:
private static boolean isCorrectSign(Sign sign,Block block){
  return sign != null && sign.getBlock() == block || getAttachedFace(sign) == block;
}

Fixed version (ground truth):
private static boolean isCorrectSign(Sign sign,Block block){
  return sign != null && (sign.getBlock() == block || getAttachedFace(sign) == block);
}
Program: 17187
Project: 17187
Buggy source:
public void onBlockPistonRetract(BlockPistonRetractEvent event){
  if (!uSign.isSign(event.getRetractLocation().getBlock()) && cancellingBlockBreak(event.getRetractLocation().getBlock(),null))   event.setCancelled(true);
}

Fixed version (ground truth):
public void onBlockPistonRetract(BlockPistonRetractEvent event){
  try {
    if (!uSign.isSign(event.getRetractLocation().getBlock()) && cancellingBlockBreak(event.getRetractLocation().getBlock(),null))     event.setCancelled(true);
  }
 catch (  Exception ignored) {
  }
}
Program: 17188
Project: 17188
Buggy source:
private static boolean isCorrectSign(Sign sign,Block block){
  return sign.getBlock() == block || getAttachedFace(sign) == block;
}

Fixed version (ground truth):
private static boolean isCorrectSign(Sign sign,Block block){
  return sign != null && sign.getBlock() == block || getAttachedFace(sign) == block;
}
Program: 17189
Project: 17189
Buggy source:
public static boolean cancellingBlockBreak(Block block,Player player){
  if (player != null && (Permission.has(player,Permission.ADMIN) || Permission.has(player,Permission.MOD)))   return false;
  if (uSign.isSign(block))   block.getState().update();
  Sign sign=uBlock.findRestrictedSign(block);
  if (sign != null && isCorrectSign(sign,block))   return true;
  sign=uBlock.findSign(block);
  return sign != null && (isCorrectSign(sign,block) && playerIsNotOwner(player,sign));
}

Fixed version (ground truth):
public static boolean cancellingBlockBreak(Block block,Player player){
  if (player != null && (Permission.has(player,Permission.ADMIN) || Permission.has(player,Permission.MOD)))   return false;
  if (uSign.isSign(block))   block.getState().update();
  Sign sign=uBlock.findRestrictedSign(block);
  if (isCorrectSign(sign,block))   return true;
  sign=uBlock.findSign(block);
  return isCorrectSign(sign,block) && playerIsNotOwner(player,sign);
}
Program: 17191
Project: 17191
Buggy source:
public boolean setMethod(Plugin method){
  PluginManager manager=method.getServer().getPluginManager();
  if (method != null && method.isEnabled()) {
    Method plugin=MethodFactory.createMethod(method);
    if (plugin != null)     Method=plugin;
  }
 else {
    for (    String name : MethodFactory.getDependencies()) {
      if (hasMethod())       break;
      method=manager.getPlugin(name);
      if (method == null)       continue;
      if (!method.isEnabled())       manager.enablePlugin(method);
      if (!method.isEnabled())       continue;
      Method plugin=MethodFactory.createMethod(method);
      if (plugin != null)       Method=plugin;
    }
  }
  return hasMethod();
}

Fixed version (ground truth):
public boolean setMethod(Plugin method){
  if (hasMethod())   return true;
  PluginManager manager=method.getServer().getPluginManager();
  Plugin plugin=null;
  for (  String name : this.getDependencies()) {
    if (hasMethod())     break;
    if (method.getDescription().getName().equals(name))     plugin=method;
 else     plugin=manager.getPlugin(name);
    if (plugin == null)     continue;
    if (!plugin.isEnabled())     continue;
    Method current=this.createMethod(plugin);
    if (current != null)     this.Method=current;
  }
  return hasMethod();
}
Program: 17192
Project: 17192
Buggy source:
public boolean hasMethod(){
  return (Method != null);
}

Fixed version (ground truth):
public boolean hasMethod(){
  return (this.Method != null);
}
Program: 17193
Project: 17193
Buggy source:
public double balance(){
  return (double)this.BOSEconomy.getBankMoney(name);
}

Fixed version (ground truth):
public double balance(){
  return Double.valueOf(this.BOSEconomy.getBankMoney(name));
}
Program: 17194
Project: 17194
Buggy source:
public boolean isCompatible(Plugin plugin){
  return plugin.getDescription().getName().equalsIgnoreCase("String_Node_Str") && plugin instanceof Essentials;
}

Fixed version (ground truth):
public boolean isCompatible(Plugin plugin){
  try {
    Class.forName("String_Node_Str");
  }
 catch (  Exception e) {
    return false;
  }
  return plugin.getDescription().getName().equalsIgnoreCase("String_Node_Str") && plugin instanceof Essentials;
}
Program: 17195
Project: 17195
Buggy source:
public boolean isCompatible(Plugin plugin){
  return plugin.getDescription().getName().equalsIgnoreCase("String_Node_Str") && plugin instanceof iConomy;
}

Fixed version (ground truth):
public boolean isCompatible(Plugin plugin){
  return plugin.getDescription().getName().equalsIgnoreCase("String_Node_Str") && !plugin.getClass().getName().equals("String_Node_Str") && plugin instanceof iConomy;
}
Program: 17196
Project: 17196
Buggy source:
public boolean isCompatible(Plugin plugin){
  return plugin.getDescription().getName().equalsIgnoreCase("String_Node_Str") && plugin instanceof iConomy;
}

Fixed version (ground truth):
public boolean isCompatible(Plugin plugin){
  return plugin.getDescription().getName().equalsIgnoreCase("String_Node_Str") && plugin.getClass().getName().equals("String_Node_Str") && plugin instanceof iConomy;
}
Program: 17197
Project: 17197
Buggy source:
public boolean hasBank(String bank){
  return (hasBanks()) && this.iConomy.Banks.exists(bank);
}

Fixed version (ground truth):
public boolean hasBank(String bank){
  return (!hasBanks()) ? false : this.iConomy.Banks.exists(bank);
}
Program: 17198
Project: 17198
Buggy source:
public boolean hasBankAccount(String bank,String name){
  return (!hasBank(bank)) && this.iConomy.getBank(name).hasAccount(name);
}

Fixed version (ground truth):
public boolean hasBankAccount(String bank,String name){
  return (hasBank(bank)) ? false : this.iConomy.getBank(name).hasAccount(name);
}
Program: 17199
Project: 17199
Buggy source:
public void onPluginEnable(PluginEnableEvent event){
  LinkedList<String> toRemove=new LinkedList();
  if (!methods.hasMethod()) {
    if (methods.setMethod(event.getPlugin())) {
      Economy.economy=methods.getMethod();
      System.out.println("String_Node_Str" + Economy.economy.getName() + ' '+ Economy.economy.getVersion()+ "String_Node_Str");
    }
  }
  for (  String pluginName : pluginsToLoad) {
    Plugin plugin=ChestShop.getBukkitServer().getPluginManager().getPlugin(pluginName);
    if (plugin == null)     continue;
    initializePlugin(pluginName,plugin);
    toRemove.add(pluginName);
  }
  for (  String pluginName : toRemove)   pluginsToLoad.remove(pluginName);
}

Fixed version (ground truth):
public void onPluginEnable(PluginEnableEvent event){
  LinkedList<String> toRemove=new LinkedList();
  if (!methods.hasMethod()) {
    if (methods.setMethod(event.getPlugin())) {
      Economy.economy=methods.getMethod();
      System.out.println(lineStart + Economy.economy.getName() + ' '+ Economy.economy.getVersion()+ "String_Node_Str");
    }
  }
  for (  String pluginName : pluginsToLoad) {
    Plugin plugin=ChestShop.getBukkitServer().getPluginManager().getPlugin(pluginName);
    if (plugin == null)     continue;
    initializePlugin(pluginName,plugin);
    toRemove.add(pluginName);
  }
  for (  String pluginName : toRemove)   pluginsToLoad.remove(pluginName);
}
Program: 17201
Project: 17201
Buggy source:
@Test public void testGetLocalizedNameMap() throws Exception {
  Language locale=Language.ENGLISH;
  Map<String,Language> result=Language.values(locale);
  assertEquals(38,result.size());
}

Fixed version (ground truth):
@Test public void testGetLocalizedNameMap() throws Exception {
  Language locale=Language.ENGLISH;
  Map<String,Language> result=Language.values(locale);
  assertEquals(39,result.size());
}
Program: 17202
Project: 17202
Buggy source:
/** 
 * Forms an HTTP request, sends it using GET method and returns the result of the request as a String.
 * @param url The URL to query for a String response.
 * @return The translated String.
 * @throws Exception on error.
 */
private static String retrieveResponse(final URL url) throws Exception {
  final HttpURLConnection uc=(HttpURLConnection)url.openConnection();
  if (referrer != null)   uc.setRequestProperty("String_Node_Str",referrer);
  uc.setRequestMethod("String_Node_Str");
  uc.setDoOutput(true);
  try {
    final int responseCode=uc.getResponseCode();
    if (responseCode == 414) {
      throw new RuntimeException("String_Node_Str");
    }
    final String result=inputStreamToString(uc.getInputStream());
    return result;
  }
  finally {
    uc.getInputStream().close();
    if (uc.getErrorStream() != null) {
      uc.getErrorStream().close();
    }
  }
}

Fixed version (ground truth):
/** 
 * Forms an HTTP request, sends it using GET method and returns the result of the request as a String.
 * @param url The URL to query for a String response.
 * @return The translated String.
 * @throws Exception on error.
 */
private static String retrieveResponse(final URL url) throws Exception {
  final HttpURLConnection uc=(HttpURLConnection)url.openConnection();
  if (referrer != null)   uc.setRequestProperty("String_Node_Str",referrer);
  uc.setRequestProperty("String_Node_Str","String_Node_Str" + ENCODING);
  uc.setRequestProperty("String_Node_Str",ENCODING);
  uc.setRequestMethod("String_Node_Str");
  uc.setDoOutput(true);
  try {
    final int responseCode=uc.getResponseCode();
    if (responseCode == 414) {
      throw new RuntimeException("String_Node_Str");
    }
    final String result=inputStreamToString(uc.getInputStream());
    return result;
  }
  finally {
    uc.getInputStream().close();
    if (uc.getErrorStream() != null) {
      uc.getErrorStream().close();
    }
  }
}
Program: 17203
Project: 17203
Buggy source:
private static void validateServiceState(final String[] texts) throws Exception {
  for (  String text : texts) {
    if (text.length() > 10240) {
      throw new RuntimeException("String_Node_Str");
    }
  }
  validateServiceState();
}

Fixed version (ground truth):
private static void validateServiceState(final String[] texts) throws Exception {
  int length=0;
  for (  String text : texts) {
    length+=text.getBytes(ENCODING).length;
  }
  if (length > 10240) {
    throw new RuntimeException("String_Node_Str");
  }
  validateServiceState();
}
Program: 17204
Project: 17204
Buggy source:
private static void validateServiceState(final String text,final Language fromLang) throws Exception {
  if (text.length() > 10240) {
    throw new RuntimeException("String_Node_Str");
  }
  if (Language.AUTO_DETECT.equals(fromLang)) {
    throw new RuntimeException("String_Node_Str");
  }
  validateServiceState();
}

Fixed version (ground truth):
private static void validateServiceState(final String text,final Language fromLang) throws Exception {
  final int byteLength=text.getBytes(ENCODING).length;
  if (byteLength > 10240) {
    throw new RuntimeException("String_Node_Str");
  }
  if (Language.AUTO_DETECT.equals(fromLang)) {
    throw new RuntimeException("String_Node_Str");
  }
  validateServiceState();
}
Program: 17205
Project: 17205
Buggy source:
private static void validateServiceState(final String text) throws Exception {
  if (text.length() > 2000) {
    throw new RuntimeException("String_Node_Str");
  }
  validateServiceState();
}

Fixed version (ground truth):
private static void validateServiceState(final String text) throws Exception {
  final int byteLength=text.getBytes(ENCODING).length;
  if (byteLength > 2000) {
    throw new RuntimeException("String_Node_Str");
  }
  validateServiceState();
}
Program: 17206
Project: 17206
Buggy source:
private static void validateServiceState(final String text) throws Exception {
  if (text.length() > 10240) {
    throw new RuntimeException("String_Node_Str");
  }
  validateServiceState();
}

Fixed version (ground truth):
private static void validateServiceState(final String text) throws Exception {
  final int byteLength=text.getBytes(ENCODING).length;
  if (byteLength > 10240) {
    throw new RuntimeException("String_Node_Str");
  }
  validateServiceState();
}
Program: 17207
Project: 17207
Buggy source:
@Test public void testLargeLimitArray() throws Exception {
  String[] sourceTexts=new String[42];
  String largeText="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
  for (int i=0; i < sourceTexts.length; i++)   sourceTexts[i]=largeText;
  String[] results=Translate.execute(sourceTexts,Language.ENGLISH,Language.FRENCH);
  assertEquals(sourceTexts.length,results.length);
}

Fixed version (ground truth):
@Test public void testLargeLimitArray() throws Exception {
  String[] sourceTexts=new String[30];
  String largeText="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
  for (int i=0; i < sourceTexts.length; i++)   sourceTexts[i]=largeText;
  String[] results=Translate.execute(sourceTexts,Language.ENGLISH,Language.FRENCH);
  assertEquals(sourceTexts.length,results.length);
}
Program: 17208
Project: 17208
Buggy source:
/** 
 * Detects the language of a supplied String.
 * @param text The String to detect the language of.
 * @return A DetectResult object containing the language, confidence and reliability.
 * @throws Exception on error.
 */
public static String execute(final Language target,final Language locale) throws Exception {
  final URL url=new URL(SERVICE_URL + URLEncoder.encode(locale.toString(),ENCODING) + "String_Node_Str"+ URLEncoder.encode("String_Node_Str" + target.toString() + "String_Node_Str",ENCODING)+ "String_Node_Str"+ apiKey);
  final String json=retrieveJSON(url);
  if (json != null && json.length() > 0)   return json.substring(1,json.length() - 1);
 else   return json;
}

Fixed version (ground truth):
/** 
 * Detects the language of a supplied String.
 * @param text The String to detect the language of.
 * @return A DetectResult object containing the language, confidence and reliability.
 * @throws Exception on error.
 */
public static String[] execute(final Language[] targets,final Language locale) throws Exception {
  String[] localizedNames=new String[0];
  if (locale == Language.AUTO_DETECT) {
    return localizedNames;
  }
  StringBuilder targetString=new StringBuilder("String_Node_Str");
  for (  Language lang : targets) {
    if (lang != Language.AUTO_DETECT) {
      if (targetString.length() > 1)       targetString.append("String_Node_Str");
      targetString.append(lang.toString());
      targetString.append("String_Node_Str");
    }
  }
  final URL url=new URL(SERVICE_URL + URLEncoder.encode(locale.toString(),ENCODING) + "String_Node_Str"+ URLEncoder.encode("String_Node_Str" + targetString.toString() + "String_Node_Str",ENCODING)+ "String_Node_Str"+ apiKey);
  localizedNames=retrieveStringArr(url);
  return localizedNames;
}
Program: 17209
Project: 17209
Buggy source:
/** 
 * Get the   {@link AbstractInternalCacheKeyInvocationContext} for the CDI invocation
 * @param invocation The CDI invocation context
 * @return The keyed cache invocation context
 * @throws UnsupportedOperationException if the invocation context is not for a method that has an annotation for which CacheInvocationContext exists.
 */
@Override public InternalCacheKeyInvocationContext<? extends Annotation> getCacheKeyInvocationContext(I invocation){
  final Method method=this.getMethod(invocation);
  final Class<?> targetClass=this.getTargetClass(invocation);
  final StaticCacheInvocationContext<? extends Annotation> staticCacheInvocationContext=this.getMethodDetails(method,targetClass);
  if (staticCacheInvocationContext == null) {
    throw new AnnotationFormatError("String_Node_Str" + method + "String_Node_Str"+ invocation);
  }
switch (staticCacheInvocationContext.getInterceptorType()) {
case CACHE_RESULT:
case CACHE_PUT:
case CACHE_REMOVE_ENTRY:
{
      return createCacheKeyInvocationContextImpl((StaticCacheKeyInvocationContext<? extends Annotation>)staticCacheInvocationContext,invocation);
    }
default :
{
    throw new UnsupportedOperationException("String_Node_Str" + staticCacheInvocationContext.getInterceptorType());
  }
}
}

Fixed version (ground truth):
/** 
 * Get the   {@link InternalCacheKeyInvocationContext} for the CDI invocation.
 * @param invocation The CDI invocation context
 * @return The keyed cache invocation context
 * @throws UnsupportedOperationException if the invocation context is available for the invocation
 */
@Override public InternalCacheKeyInvocationContext<? extends Annotation> getCacheKeyInvocationContext(I invocation){
  final Method method=this.getMethod(invocation);
  final Class<?> targetClass=this.getTargetClass(invocation);
  final StaticCacheInvocationContext<? extends Annotation> staticCacheInvocationContext=this.getMethodDetails(method,targetClass);
  if (staticCacheInvocationContext == null) {
    throw new AnnotationFormatError("String_Node_Str" + method + "String_Node_Str"+ invocation);
  }
switch (staticCacheInvocationContext.getInterceptorType()) {
case CACHE_RESULT:
case CACHE_PUT:
case CACHE_REMOVE_ENTRY:
{
      return createCacheKeyInvocationContextImpl((StaticCacheKeyInvocationContext<? extends Annotation>)staticCacheInvocationContext,invocation);
    }
default :
{
    throw new UnsupportedOperationException("String_Node_Str" + staticCacheInvocationContext.getInterceptorType());
  }
}
}
Program: 17210
Project: 17210
Buggy source:
/** 
 * Get the concrete annotation object for the method which will be invoked on the target class. <p/> Subclasses may override this to provide their own annotation resolution logic, the default implementation uses   {@link Method#getAnnotation(Class)}
 * @param annotationClass The annotation class
 * @param method          Target method
 * @param targetClass     Target Class
 * @return The concrete annotation from the method
 */
protected <T extends Annotation>T getAnnotation(Class<T> annotationClass,Method method,Class<? extends Object> targetClass){
  return method.getAnnotation(annotationClass);
}

Fixed version (ground truth):
/** 
 * Get the concrete annotation object for the method that will be invoked on the target class. <p/> Subclasses may override this to provide their own annotation resolution logic, the default implementation uses   {@link Method#getAnnotation(Class)}
 * @param annotationClass The annotation class
 * @param method          Target method
 * @param targetClass     Target Class
 * @return The concrete annotation from the method
 */
protected <T extends Annotation>T getAnnotation(Class<T> annotationClass,Method method,Class<? extends Object> targetClass){
  return method.getAnnotation(annotationClass);
}
Program: 17211
Project: 17211
Buggy source:
private void removeListener(CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration){
  if (cacheEntryListenerConfiguration == null) {
    throw new NullPointerException("String_Node_Str" + "String_Node_Str");
  }
  for (  RICacheEntryListenerRegistration<K,V> listenerRegistration : listenerRegistrations) {
    if (cacheEntryListenerConfiguration.equals(listenerRegistration.getConfiguration())) {
      listenerRegistrations.remove(listenerRegistration);
      configuration.getCacheEntryListenerConfigurations().remove(cacheEntryListenerConfiguration);
    }
  }
}

Fixed version (ground truth):
private void removeListener(CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration){
  if (cacheEntryListenerConfiguration == null) {
    throw new NullPointerException("String_Node_Str" + "String_Node_Str");
  }
  for (  RICacheEntryListenerRegistration<K,V> listenerRegistration : listenerRegistrations) {
    if (cacheEntryListenerConfiguration.equals(listenerRegistration.getConfiguration())) {
      listenerRegistrations.remove(listenerRegistration);
      configuration.removeCacheEntryListenerConfiguration(cacheEntryListenerConfiguration);
    }
  }
}
Program: 17212
Project: 17212
Buggy source:
/** 
 * Get the concrete annotation object for the method that will be invoked on the target class. <p/> Subclasses may override this to provide their own annotation resolution logic, the default implementation uses   {@link Method#getAnnotation(Class)}
 * @param annotationClass The annotation class
 * @param method          Target method
 * @param targetClass     Target Class
 * @return The concrete annotation from the method
 */
protected <T extends Annotation>T getAnnotation(Class<T> annotationClass,Method method,Class<? extends Object> targetClass){
  return method.getAnnotation(annotationClass);
}

Fixed version (ground truth):
/** 
 * Get the concrete annotation object for the method that will be invoked on the target class. <p> Subclasses may override this to provide their own annotation resolution logic, the default implementation uses   {@link Method#getAnnotation(Class)}</p>
 * @param annotationClass The annotation class
 * @param method          Target method
 * @param targetClass     Target Class
 * @return The concrete annotation from the method
 */
protected <T extends Annotation>T getAnnotation(Class<T> annotationClass,Method method,Class<? extends Object> targetClass){
  return method.getAnnotation(annotationClass);
}
Program: 17215
Project: 17215
Buggy source:
/** 
 * The total number of requests to the cache. This will be equal to the sum of the hits and misses. <p/> A "get" is an operation that returns the current or previous value.
 * @return the number of hits
 */
@Override public long getCacheGets(){
  return getCacheHits() + getCacheMisses();
}

Fixed version (ground truth):
/** 
 * The total number of requests to the cache. This will be equal to the sum of the hits and misses. <p> A "get" is an operation that returns the current or previous value. </p>
 * @return the number of hits
 */
@Override public long getCacheGets(){
  return getCacheHits() + getCacheMisses();
}
Program: 17216
Project: 17216
Buggy source:
/** 
 * {@inheritDoc}<p/> Statistics will also automatically be cleared if internal counters overflow.
 */
@Override public void clear(){
  cachePuts.set(0);
  cacheMisses.set(0);
  cacheRemovals.set(0);
  cacheExpiries.set(0);
  cacheHits.set(0);
  cacheEvictions.set(0);
  cacheGetTimeTakenNanos.set(0);
  cachePutTimeTakenNanos.set(0);
  cacheRemoveTimeTakenNanos.set(0);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}<p> Statistics will also automatically be cleared if internal counters overflow. </p>
 */
@Override public void clear(){
  cachePuts.set(0);
  cacheMisses.set(0);
  cacheRemovals.set(0);
  cacheExpiries.set(0);
  cacheHits.set(0);
  cacheEvictions.set(0);
  cacheGetTimeTakenNanos.set(0);
  cachePutTimeTakenNanos.set(0);
  cacheRemoveTimeTakenNanos.set(0);
}
Program: 17217
Project: 17217
Buggy source:
/** 
 * The total number of removals from the cache. This does not include evictions, where the cache itself initiates the removal to make space. <p/> A replace invcludes a put and remove.
 * @return the number of hits
 */
@Override public long getCacheRemovals(){
  return cacheRemovals.longValue();
}

Fixed version (ground truth):
/** 
 * The total number of removals from the cache. This does not include evictions, where the cache itself initiates the removal to make space. <p> A replace invcludes a put and remove. </p>
 * @return the number of hits
 */
@Override public long getCacheRemovals(){
  return cacheRemovals.longValue();
}
Program: 17218
Project: 17218
Buggy source:
/** 
 * The total number of puts to the cache. <p/> A put is counted even if it is immediately evicted. A replace includes a put and remove.
 * @return the number of hits
 */
@Override public long getCachePuts(){
  return cachePuts.longValue();
}

Fixed version (ground truth):
/** 
 * The total number of puts to the cache. <p> A put is counted even if it is immediately evicted. A replace includes a put and remove. </p>
 * @return the number of hits
 */
@Override public long getCachePuts(){
  return cachePuts.longValue();
}