nus-yam/ex-repair huggingface dataset:
Program: 17130
Project: 17130
Buggy source:
public static boolean canAccess(Player player,Sign sign){
  if (player == null)   return false;
  if (sign == null)   return true;
  return NameManager.canUseName(player,sign.getLine(NAME_LINE));
}

Fixed version (ground truth):
public static boolean canAccess(Player player,Sign sign){
  if (player == null)   return false;
  if (sign == null)   return true;
  String name=sign.getLine(NAME_LINE);
  if (name == null || name.isEmpty())   return true;
  return NameManager.canUseName(player,name);
}
Program: 17131
Project: 17131
Buggy source:
@Override public void run(){
  String playerName=NameUtil.stripUsername(playerDTO.getName());
  UUID uuid=NameManager.getUUID(playerName);
  NameManager.storeUsername(playerDTO);
}

Fixed version (ground truth):
@Override public void run(){
  NameManager.storeUsername(playerDTO);
}
Program: 17132
Project: 17132
Buggy source:
@EventHandler(priority=EventPriority.MONITOR,ignoreCancelled=true) public static void onPlayerConnect(final PlayerJoinEvent event){
  final PlayerDTO playerDTO=new PlayerDTO(event.getPlayer());
  Bukkit.getScheduler().runTaskAsynchronously(ChestShop.getPlugin(),new Runnable(){
    @Override public void run(){
      String playerName=NameUtil.stripUsername(playerDTO.getName());
      UUID uuid=NameManager.getUUID(playerName);
      NameManager.storeUsername(playerDTO);
    }
  }
);
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.MONITOR,ignoreCancelled=true) public static void onPlayerConnect(final PlayerJoinEvent event){
  final PlayerDTO playerDTO=new PlayerDTO(event.getPlayer());
  Bukkit.getScheduler().runTaskAsynchronously(ChestShop.getPlugin(),new Runnable(){
    @Override public void run(){
      NameManager.storeUsername(playerDTO);
    }
  }
);
}
Program: 17134
Project: 17134
Buggy source:
@EventHandler(priority=EventPriority.MONITOR) public static void onShopDestroy(ShopDestroyedEvent event){
  double refundPrice=Properties.SHOP_REFUND_PRICE;
  if (event.getDestroyer() == null || Permission.has(event.getDestroyer(),NOFEE) || refundPrice == 0) {
    return;
  }
  String ownerName=NameManager.getFullUsername(event.getSign().getLine(NAME_LINE));
  UUID owner=NameManager.getUUID(ownerName);
  CurrencyAddEvent currencyEvent=new CurrencyAddEvent(BigDecimal.valueOf(refundPrice),owner,event.getSign().getWorld());
  ChestShop.callEvent(currencyEvent);
  if (!Economy.getServerAccountName().isEmpty()) {
    CurrencySubtractEvent currencySubtractEvent=new CurrencySubtractEvent(BigDecimal.valueOf(refundPrice),NameManager.getUUID(Economy.getServerAccountName()),event.getSign().getWorld());
    ChestShop.callEvent(currencySubtractEvent);
  }
  String message=Messages.SHOP_REFUNDED.replace("String_Node_Str",Economy.formatBalance(refundPrice));
  event.getDestroyer().sendMessage(Messages.prefix(message));
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.MONITOR) public static void onShopDestroy(ShopDestroyedEvent event){
  double refundPrice=Properties.SHOP_REFUND_PRICE;
  if (event.getDestroyer() == null || Permission.has(event.getDestroyer(),NOFEE) || refundPrice == 0) {
    return;
  }
  String ownerName=NameManager.getFullUsername(event.getSign().getLine(NAME_LINE));
  if (ownerName.isEmpty()) {
    return;
  }
  UUID owner=NameManager.getUUID(ownerName);
  CurrencyAddEvent currencyEvent=new CurrencyAddEvent(BigDecimal.valueOf(refundPrice),owner,event.getSign().getWorld());
  ChestShop.callEvent(currencyEvent);
  if (!Economy.getServerAccountName().isEmpty()) {
    CurrencySubtractEvent currencySubtractEvent=new CurrencySubtractEvent(BigDecimal.valueOf(refundPrice),NameManager.getUUID(Economy.getServerAccountName()),event.getSign().getWorld());
    ChestShop.callEvent(currencySubtractEvent);
  }
  String message=Messages.SHOP_REFUNDED.replace("String_Node_Str",Economy.formatBalance(refundPrice));
  event.getDestroyer().sendMessage(Messages.prefix(message));
}
Program: 17135
Project: 17135
Buggy source:
public static UUID getUUID(String username){
  if (usernameToUUID.containsKey(username)) {
    return usernameToUUID.get(username);
  }
  String shortenedName=NameUtil.stripUsername(username);
  Account account=null;
  try {
    account=accounts.queryBuilder().selectColumns("String_Node_Str").where().eq("String_Node_Str",shortenedName).queryForFirst();
  }
 catch (  SQLException e) {
    e.printStackTrace();
    return null;
  }
  if (account == null) {
    return Bukkit.getOfflinePlayer(username).getUniqueId();
  }
  UUID uuid=account.getUuid();
  if (uuid != null && !usernameToUUID.containsValue(uuid)) {
    usernameToUUID.put(account.getName(),uuid);
  }
  return uuid;
}

Fixed version (ground truth):
public static UUID getUUID(String username){
  Validate.notEmpty(username,"String_Node_Str");
  if (usernameToUUID.containsKey(username)) {
    return usernameToUUID.get(username);
  }
  String shortenedName=NameUtil.stripUsername(username);
  Account account=null;
  try {
    account=accounts.queryBuilder().selectColumns("String_Node_Str").where().eq("String_Node_Str",shortenedName).queryForFirst();
  }
 catch (  SQLException e) {
    e.printStackTrace();
    return null;
  }
  if (account == null) {
    return Bukkit.getOfflinePlayer(username).getUniqueId();
  }
  UUID uuid=account.getUuid();
  if (uuid != null && !usernameToUUID.containsValue(uuid)) {
    usernameToUUID.put(account.getName(),uuid);
  }
  return uuid;
}
Program: 17136
Project: 17136
Buggy source:
public static boolean canUseName(Player player,String name){
  String shortenedName=NameUtil.stripUsername(getUsername(player.getUniqueId()));
  if (ChestShopSign.isAdminShop(name)) {
    return false;
  }
  return shortenedName.equals(name) || Permission.otherName(player,name) || player.getUniqueId().equals(getUUID(name));
}

Fixed version (ground truth):
public static boolean canUseName(Player player,String name){
  String shortenedName=NameUtil.stripUsername(getUsername(player.getUniqueId()));
  if (ChestShopSign.isAdminShop(name)) {
    return false;
  }
  return shortenedName.equals(name) || Permission.otherName(player,name) || (!name.isEmpty() && player.getUniqueId().equals(getUUID(name)));
}
Program: 17137
Project: 17137
Buggy source:
@EventHandler public static void onSignChange(SignChangeEvent event){
  Block signBlock=event.getBlock();
  String[] line=event.getLines();
  if (!BlockUtil.isSign(signBlock)) {
    return;
  }
  if (!ChestShopSign.isValidPreparedSign(line)) {
    return;
  }
  PreShopCreationEvent preEvent=new PreShopCreationEvent(event.getPlayer(),(Sign)signBlock.getState(),line);
  ChestShop.callEvent(preEvent);
  if (preEvent.isCancelled()) {
    return;
  }
  for (byte i=0; i < event.getLines().length; ++i) {
    event.setLine(i,preEvent.getSignLine(i));
  }
  ShopCreatedEvent postEvent=new ShopCreatedEvent(preEvent.getPlayer(),preEvent.getSign(),uBlock.findConnectedChest(preEvent.getSign()),preEvent.getSignLines());
  ChestShop.callEvent(postEvent);
}

Fixed version (ground truth):
@EventHandler public static void onSignChange(SignChangeEvent event){
  Block signBlock=event.getBlock();
  String[] line=StringUtil.stripColourCodes(event.getLines());
  if (!BlockUtil.isSign(signBlock)) {
    return;
  }
  if (!ChestShopSign.isValidPreparedSign(line)) {
    return;
  }
  PreShopCreationEvent preEvent=new PreShopCreationEvent(event.getPlayer(),(Sign)signBlock.getState(),line);
  ChestShop.callEvent(preEvent);
  if (preEvent.isCancelled()) {
    return;
  }
  for (byte i=0; i < event.getLines().length; ++i) {
    event.setLine(i,preEvent.getSignLine(i));
  }
  ShopCreatedEvent postEvent=new ShopCreatedEvent(preEvent.getPlayer(),preEvent.getSign(),uBlock.findConnectedChest(preEvent.getSign()),preEvent.getSignLines());
  ChestShop.callEvent(postEvent);
}
Program: 17138
Project: 17138
Buggy source:
/** 
 * Returns item's name, just like on the sign
 * @param itemStack ItemStack to name
 * @return ItemStack's name
 */
public static String getSignName(ItemStack itemStack){
  StringBuilder name=new StringBuilder(15);
  name.append(itemStack.getType().name());
  if (itemStack.getDurability() != 0) {
    name.append(':').append(itemStack.getDurability());
  }
  if (itemStack.hasItemMeta()) {
    name.append('#').append(Metadata.getItemCode(itemStack));
  }
  return StringUtil.capitalizeFirstLetter(name.toString(),'_');
}

Fixed version (ground truth):
/** 
 * Returns item's name, just like on the sign
 * @param itemStack ItemStack to name
 * @return ItemStack's name
 */
public static String getSignName(ItemStack itemStack){
  StringBuilder name=new StringBuilder(15);
  String itemName=itemStack.getType().name();
  itemName=StringUtil.capitalizeFirstLetter(itemName,'_');
  name.append(itemName);
  if (itemStack.getDurability() != 0) {
    name.append(':').append(itemStack.getDurability());
  }
  if (itemStack.hasItemMeta()) {
    name.append('#').append(Metadata.getItemCode(itemStack));
  }
  return name.toString();
}
Program: 17139
Project: 17139
Buggy source:
@EventHandler public void onAmountCheck(CurrencyAmountEvent event){
  if (!event.getAmount().equals(BigDecimal.ZERO)) {
    return;
  }
  double balance=provider.getBalance(Bukkit.getOfflinePlayer(event.getAccount()),event.getWorld().getName());
  if (balance > Double.MAX_VALUE) {
    balance=Double.MAX_VALUE;
  }
  event.setAmount(balance);
}

Fixed version (ground truth):
@EventHandler public void onAmountCheck(CurrencyAmountEvent event){
  if (!event.getAmount().equals(BigDecimal.ZERO)) {
    return;
  }
  double balance=provider.getBalance(NameManager.getUsername(event.getAccount()),event.getWorld().getName());
  if (balance > Double.MAX_VALUE) {
    balance=Double.MAX_VALUE;
  }
  event.setAmount(balance);
}
Program: 17140
Project: 17140
Buggy source:
@EventHandler public void onCurrencyCheck(CurrencyCheckEvent event){
  if (event.hasEnough()) {
    return;
  }
  World world=event.getWorld();
  if (provider.has(Bukkit.getOfflinePlayer(event.getAccount()),world.getName(),event.getDoubleAmount())) {
    event.hasEnough(true);
  }
}

Fixed version (ground truth):
@EventHandler public void onCurrencyCheck(CurrencyCheckEvent event){
  if (event.hasEnough()) {
    return;
  }
  World world=event.getWorld();
  if (provider.has(NameManager.getUsername(event.getAccount()),world.getName(),event.getDoubleAmount())) {
    event.hasEnough(true);
  }
}
Program: 17141
Project: 17141
Buggy source:
@EventHandler public void onCurrencyAdd(CurrencyAddEvent event){
  if (event.isAdded()) {
    return;
  }
  World world=event.getWorld();
  provider.depositPlayer(Bukkit.getOfflinePlayer(event.getTarget()),world.getName(),event.getDoubleAmount());
}

Fixed version (ground truth):
@EventHandler public void onCurrencyAdd(CurrencyAddEvent event){
  if (event.isAdded()) {
    return;
  }
  World world=event.getWorld();
  provider.depositPlayer(NameManager.getUsername(event.getTarget()),world.getName(),event.getDoubleAmount());
}
Program: 17142
Project: 17142
Buggy source:
@EventHandler public void onCurrencySubtraction(CurrencySubtractEvent event){
  if (event.isSubtracted()) {
    return;
  }
  World world=event.getWorld();
  provider.withdrawPlayer(Bukkit.getOfflinePlayer(event.getTarget()),world.getName(),event.getDoubleAmount());
}

Fixed version (ground truth):
@EventHandler public void onCurrencySubtraction(CurrencySubtractEvent event){
  if (event.isSubtracted()) {
    return;
  }
  World world=event.getWorld();
  provider.withdrawPlayer(NameManager.getUsername(event.getTarget()),world.getName(),event.getDoubleAmount());
}
Program: 17143
Project: 17143
Buggy source:
@EventHandler public void onCurrencyHoldCheck(CurrencyHoldEvent event){
  if (event.getAccount() == null || !transactionCanFail()) {
    return;
  }
  if (!provider.hasAccount(Bukkit.getOfflinePlayer(event.getAccount()),event.getWorld().getName())) {
    event.canHold(false);
    return;
  }
  EconomyResponse response=provider.depositPlayer(Bukkit.getOfflinePlayer(event.getAccount()),event.getWorld().getName(),event.getDoubleAmount());
  if (!response.transactionSuccess()) {
    event.canHold(false);
    return;
  }
  provider.withdrawPlayer(Bukkit.getOfflinePlayer(event.getAccount()),event.getWorld().getName(),event.getDoubleAmount());
}

Fixed version (ground truth):
@EventHandler public void onCurrencyHoldCheck(CurrencyHoldEvent event){
  if (event.getAccount() == null || !transactionCanFail()) {
    return;
  }
  if (!provider.hasAccount(NameManager.getUsername(event.getAccount()),event.getWorld().getName())) {
    event.canHold(false);
    return;
  }
  EconomyResponse response=provider.depositPlayer(NameManager.getUsername(event.getAccount()),event.getWorld().getName(),event.getDoubleAmount());
  if (!response.transactionSuccess()) {
    event.canHold(false);
    return;
  }
  provider.withdrawPlayer(NameManager.getUsername(event.getAccount()),event.getWorld().getName(),event.getDoubleAmount());
}
Program: 17144
Project: 17144
Buggy source:
@EventHandler public void onAccountCheck(AccountCheckEvent event){
  if (event.hasAccount()) {
    return;
  }
  World world=event.getWorld();
  if (!provider.hasAccount(Bukkit.getOfflinePlayer(event.getAccount()),world.getName())) {
    event.hasAccount(false);
  }
}

Fixed version (ground truth):
@EventHandler public void onAccountCheck(AccountCheckEvent event){
  if (event.hasAccount()) {
    return;
  }
  World world=event.getWorld();
  if (!provider.hasAccount(NameManager.getUsername(event.getAccount()),world.getName())) {
    event.hasAccount(false);
  }
}
Program: 17145
Project: 17145
Buggy source:
@EventHandler(priority=EventPriority.LOW) public static void onCurrencyAdd(CurrencyAddEvent event){
  if (event.isAdded()) {
    return;
  }
  UUID target=event.getTarget();
  if (Bukkit.getOfflinePlayer(target).getName().equals(Economy.getServerAccountName())) {
    return;
  }
  float taxAmount=isServerAccount(target) ? Properties.SERVER_TAX_AMOUNT : Properties.TAX_AMOUNT;
  if (taxAmount == 0) {
    return;
  }
  BigDecimal tax=getTax(event.getAmount(),taxAmount);
  if (!Economy.getServerAccountName().isEmpty()) {
    CurrencyAddEvent currencyAddEvent=new CurrencyAddEvent(tax,NameManager.getUUID(Economy.getServerAccountName()),event.getWorld());
    ChestShop.callEvent(currencyAddEvent);
  }
  event.setAmount(event.getAmount().subtract(tax));
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOW) public static void onCurrencyAdd(CurrencyAddEvent event){
  if (event.isAdded()) {
    return;
  }
  UUID target=event.getTarget();
  if (NameManager.getUsername(target).equals(Economy.getServerAccountName())) {
    return;
  }
  float taxAmount=isServerAccount(target) ? Properties.SERVER_TAX_AMOUNT : Properties.TAX_AMOUNT;
  if (taxAmount == 0) {
    return;
  }
  BigDecimal tax=getTax(event.getAmount(),taxAmount);
  if (!Economy.getServerAccountName().isEmpty()) {
    CurrencyAddEvent currencyAddEvent=new CurrencyAddEvent(tax,NameManager.getUUID(Economy.getServerAccountName()),event.getWorld());
    ChestShop.callEvent(currencyAddEvent);
  }
  event.setAmount(event.getAmount().subtract(tax));
}
Program: 17146
Project: 17146
Buggy source:
public static UUID getUUID(String username){
  if (usernameToUUID.containsKey(username)) {
    return usernameToUUID.get(username);
  }
  String shortenedName=NameUtil.stripUsername(username);
  Account account=null;
  try {
    account=accounts.queryBuilder().selectColumns("String_Node_Str").where().eq("String_Node_Str",shortenedName).queryForFirst();
  }
 catch (  SQLException e) {
    e.printStackTrace();
    return null;
  }
  if (account == null) {
    UUID uuid=Bukkit.getOfflinePlayer(username).getUniqueId();
    usernameToUUID.put(username,uuid);
    return uuid;
  }
  UUID uuid=account.getUuid();
  if (uuid != null) {
    usernameToUUID.put(account.getName(),uuid);
  }
  return uuid;
}

Fixed version (ground truth):
public static UUID getUUID(String username){
  if (usernameToUUID.containsKey(username)) {
    return usernameToUUID.get(username);
  }
  String shortenedName=NameUtil.stripUsername(username);
  Account account=null;
  try {
    account=accounts.queryBuilder().selectColumns("String_Node_Str").where().eq("String_Node_Str",shortenedName).queryForFirst();
  }
 catch (  SQLException e) {
    e.printStackTrace();
    return null;
  }
  if (account == null) {
    UUID uuid=Bukkit.getOfflinePlayer(username).getUniqueId();
    usernameToUUID.put(username,uuid);
    return uuid;
  }
  UUID uuid=account.getUuid();
  if (uuid != null && !usernameToUUID.containsValue(uuid)) {
    usernameToUUID.put(account.getName(),uuid);
  }
  return uuid;
}
Program: 17147
Project: 17147
Buggy source:
public static boolean canUseName(Player player,String name){
  String shortenedName=NameUtil.stripUsername(getUsername(player.getUniqueId()));
  return shortenedName.equals(name) || Permission.otherName(player,name);
}

Fixed version (ground truth):
public static boolean canUseName(Player player,String name){
  String shortenedName=NameUtil.stripUsername(getUsername(player.getUniqueId()));
  return shortenedName.equals(name) || Permission.otherName(player,name) || player.getUniqueId().equals(getUUID(name));
}
Program: 17148
Project: 17148
Buggy source:
@EventHandler(priority=EventPriority.MONITOR) public static void onShopDestroy(ShopDestroyedEvent event){
  double refundPrice=Properties.SHOP_REFUND_PRICE;
  if (event.getDestroyer() == null || Permission.has(event.getDestroyer(),NOFEE) || refundPrice == 0) {
    return;
  }
  UUID owner=NameManager.getUUID(event.getSign().getLine(NAME_LINE));
  CurrencyAddEvent currencyEvent=new CurrencyAddEvent(BigDecimal.valueOf(refundPrice),owner,event.getSign().getWorld());
  ChestShop.callEvent(currencyEvent);
  String message=Messages.SHOP_REFUNDED.replace("String_Node_Str",Economy.formatBalance(refundPrice));
  event.getDestroyer().sendMessage(Messages.prefix(message));
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.MONITOR) public static void onShopDestroy(ShopDestroyedEvent event){
  double refundPrice=Properties.SHOP_REFUND_PRICE;
  if (event.getDestroyer() == null || Permission.has(event.getDestroyer(),NOFEE) || refundPrice == 0) {
    return;
  }
  String ownerName=NameManager.getFullUsername(event.getSign().getLine(NAME_LINE));
  UUID owner=NameManager.getUUID(ownerName);
  CurrencyAddEvent currencyEvent=new CurrencyAddEvent(BigDecimal.valueOf(refundPrice),owner,event.getSign().getWorld());
  ChestShop.callEvent(currencyEvent);
  String message=Messages.SHOP_REFUNDED.replace("String_Node_Str",Economy.formatBalance(refundPrice));
  event.getDestroyer().sendMessage(Messages.prefix(message));
}
Program: 17149
Project: 17149
Buggy source:
public static UUID getUUID(String username){
  if (usernameToUUID.containsKey(username)) {
    return usernameToUUID.get(username);
  }
  String shortenedName=NameUtil.stripUsername(username);
  Account account=null;
  try {
    account=accounts.queryBuilder().selectColumns("String_Node_Str").where().eq("String_Node_Str",shortenedName).queryForFirst();
  }
 catch (  SQLException e) {
    e.printStackTrace();
    return null;
  }
  if (account == null) {
    UUID uuid=Bukkit.getOfflinePlayer(username).getUniqueId();
    usernameToUUID.put(username,uuid);
    return uuid;
  }
  UUID uuid=account.getUuid();
  if (uuid != null) {
    usernameToUUID.put(username,uuid);
  }
  return uuid;
}

Fixed version (ground truth):
public static UUID getUUID(String username){
  if (usernameToUUID.containsKey(username)) {
    return usernameToUUID.get(username);
  }
  String shortenedName=NameUtil.stripUsername(username);
  Account account=null;
  try {
    account=accounts.queryBuilder().selectColumns("String_Node_Str").where().eq("String_Node_Str",shortenedName).queryForFirst();
  }
 catch (  SQLException e) {
    e.printStackTrace();
    return null;
  }
  if (account == null) {
    UUID uuid=Bukkit.getOfflinePlayer(username).getUniqueId();
    usernameToUUID.put(username,uuid);
    return uuid;
  }
  UUID uuid=account.getUuid();
  if (uuid != null) {
    usernameToUUID.put(account.getName(),uuid);
  }
  return uuid;
}
Program: 17150
Project: 17150
Buggy source:
public static boolean canUseName(Player player,String name){
  String shortenedName=NameUtil.stripUsername(getUsername(player.getUniqueId()));
  return shortenedName.equals(name) || Permission.otherName(player,name) || player.getUniqueId().equals(getUUID(name));
}

Fixed version (ground truth):
public static boolean canUseName(Player player,String name){
  String shortenedName=NameUtil.stripUsername(getUsername(player.getUniqueId()));
  if (ChestShopSign.isAdminShop(name)) {
    return false;
  }
  return shortenedName.equals(name) || Permission.otherName(player,name) || player.getUniqueId().equals(getUUID(name));
}
Program: 17151
Project: 17151
Buggy source:
public static String getLastSeenName(UUID uuid){
  if (lastSeenName.containsKey(uuid)) {
    return lastSeenName.get(uuid);
  }
  Account account=null;
  try {
    account=accounts.queryBuilder().selectColumns("String_Node_Str","String_Node_Str").where().eq("String_Node_Str",uuid).queryForFirst();
  }
 catch (  SQLException e) {
    e.printStackTrace();
    return null;
  }
  if (account == null) {
    return "String_Node_Str";
  }
  if (account.getLastSeenName() != null) {
    lastSeenName.put(uuid,account.getLastSeenName());
  }
 else   if (account.getName() != null) {
    lastSeenName.put(uuid,account.getName());
  }
  return account.getLastSeenName();
}

Fixed version (ground truth):
public static String getLastSeenName(UUID uuid){
  if (lastSeenName.containsKey(uuid)) {
    return lastSeenName.get(uuid);
  }
  if (Bukkit.getOfflinePlayer(uuid).getName() != null) {
    String lastSeen=Bukkit.getOfflinePlayer(uuid).getName();
    lastSeenName.put(uuid,lastSeen);
    return lastSeen;
  }
  Account account=null;
  try {
    account=accounts.queryBuilder().selectColumns("String_Node_Str","String_Node_Str").where().eq("String_Node_Str",uuid).queryForFirst();
  }
 catch (  SQLException e) {
    e.printStackTrace();
    return null;
  }
  if (account == null) {
    return "String_Node_Str";
  }
  if (account.getLastSeenName() != null) {
    lastSeenName.put(uuid,account.getLastSeenName());
  }
 else   if (account.getName() != null) {
    lastSeenName.put(uuid,account.getName());
  }
  return account.getLastSeenName();
}
Program: 17152
Project: 17152
Buggy source:
public static void load(){
  File databaseFile=ChestShop.loadFile("String_Node_Str");
  String uri=ConnectionManager.getURI(databaseFile);
  ConnectionSource connection;
  try {
    connection=new JdbcConnectionSource(uri);
    accounts=DaoManager.createDao(connection,Account.class);
    TableUtils.createTableIfNotExists(connection,Account.class);
    Account adminAccount=new Account(Properties.ADMIN_SHOP_NAME,Bukkit.getOfflinePlayer(Properties.ADMIN_SHOP_NAME).getUniqueId());
    accounts.createIfNotExists(adminAccount);
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public static void load(){
  File databaseFile=ChestShop.loadFile("String_Node_Str");
  String uri=ConnectionManager.getURI(databaseFile);
  ConnectionSource connection;
  try {
    connection=new JdbcConnectionSource(uri);
    accounts=DaoManager.createDao(connection,Account.class);
    TableUtils.createTableIfNotExists(connection,Account.class);
    Account adminAccount=new Account(Properties.ADMIN_SHOP_NAME,Bukkit.getOfflinePlayer(Properties.ADMIN_SHOP_NAME).getUniqueId());
    accounts.createOrUpdate(adminAccount);
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
}
Program: 17153
Project: 17153
Buggy source:
@Override public void run(){
  Account account=null;
  try {
    account=accounts.queryBuilder().selectColumns("String_Node_Str").where().eq("String_Node_Str",uuid).queryForFirst();
  }
 catch (  SQLException e) {
    e.printStackTrace();
    return;
  }
  if (account != null) {
    return;
  }
  account=new Account(player.getName(),player.getUniqueId());
  try {
    accounts.create(account);
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Override public void run(){
  Account account=null;
  try {
    account=accounts.queryBuilder().selectColumns("String_Node_Str").where().eq("String_Node_Str",uuid).queryForFirst();
  }
 catch (  SQLException e) {
    e.printStackTrace();
    return;
  }
  if (account != null) {
    return;
  }
  account=new Account(player.getName(),player.getUniqueId());
  try {
    accounts.createOrUpdate(account);
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
}
Program: 17154
Project: 17154
Buggy source:
public static void storeUsername(final Player player){
  final UUID uuid=player.getUniqueId();
  if (!usernameToUUID.inverse().containsKey(uuid)) {
    usernameToUUID.inverse().put(uuid,player.getName());
  }
  Bukkit.getScheduler().runTaskAsynchronously(ChestShop.getPlugin(),new Runnable(){
    @Override public void run(){
      Account account=null;
      try {
        account=accounts.queryBuilder().selectColumns("String_Node_Str").where().eq("String_Node_Str",uuid).queryForFirst();
      }
 catch (      SQLException e) {
        e.printStackTrace();
        return;
      }
      if (account != null) {
        return;
      }
      account=new Account(player.getName(),player.getUniqueId());
      try {
        accounts.create(account);
      }
 catch (      SQLException e) {
        e.printStackTrace();
      }
    }
  }
);
}

Fixed version (ground truth):
public static void storeUsername(final Player player){
  final UUID uuid=player.getUniqueId();
  if (!usernameToUUID.inverse().containsKey(uuid)) {
    usernameToUUID.inverse().put(uuid,player.getName());
  }
  Bukkit.getScheduler().runTaskAsynchronously(ChestShop.getPlugin(),new Runnable(){
    @Override public void run(){
      Account account=null;
      try {
        account=accounts.queryBuilder().selectColumns("String_Node_Str").where().eq("String_Node_Str",uuid).queryForFirst();
      }
 catch (      SQLException e) {
        e.printStackTrace();
        return;
      }
      if (account != null) {
        return;
      }
      account=new Account(player.getName(),player.getUniqueId());
      try {
        accounts.createOrUpdate(account);
      }
 catch (      SQLException e) {
        e.printStackTrace();
      }
    }
  }
);
}
Program: 17155
Project: 17155
Buggy source:
/** 
 * Gets the price from the text
 * @param text      Text to check
 * @param indicator Price indicator (for example, B for buy)
 * @return price
 */
public static double get(String text,char indicator){
  String[] split=text.replace("String_Node_Str","String_Node_Str").toLowerCase().split("String_Node_Str");
  String character=String.valueOf(indicator).toLowerCase();
  for (  String part : split) {
    if (!part.contains(character)) {
      continue;
    }
    part=part.replace(character,"String_Node_Str");
    if (part.equals(FREE_TEXT)) {
      return FREE;
    }
    if (NumberUtil.isDouble(part)) {
      double price=Double.valueOf(part);
      if (price <= 0) {
        return NO_PRICE;
      }
 else {
        return price;
      }
    }
  }
  return NO_PRICE;
}

Fixed version (ground truth):
/** 
 * Gets the price from the text
 * @param text      Text to check
 * @param indicator Price indicator (for example, B for buy)
 * @return price
 */
public static double get(String text,char indicator){
  String[] split=text.replace("String_Node_Str","String_Node_Str").toLowerCase().split("String_Node_Str");
  String character=String.valueOf(indicator).toLowerCase();
  for (  String part : split) {
    if (!part.contains(character)) {
      continue;
    }
    part=part.replace(character,"String_Node_Str");
    if (part.equals(FREE_TEXT)) {
      return FREE;
    }
    if (NumberUtil.isDouble(part)) {
      double price=Double.valueOf(part);
      if (Double.isInfinite(price) || price <= 0) {
        return NO_PRICE;
      }
 else {
        return price;
      }
    }
  }
  return NO_PRICE;
}
Program: 17156
Project: 17156
Buggy source:
/** 
 * Checks if the string is a valid price
 * @param text Text to check
 * @return Is the string a valid price
 */
public static boolean isPrice(String text){
  if (NumberUtil.isFloat(text)) {
    return true;
  }
  return text.trim().equalsIgnoreCase(FREE_TEXT);
}

Fixed version (ground truth):
/** 
 * Checks if the string is a valid price
 * @param text Text to check
 * @return Is the string a valid price
 */
public static boolean isPrice(String text){
  if (NumberUtil.isDouble(text)) {
    return true;
  }
  return text.trim().equalsIgnoreCase(FREE_TEXT);
}
Program: 17157
Project: 17157
Buggy source:
/** 
 * Gets the item code for this item
 * @param item Item
 * @return Item code for this item
 */
public String getItemCode(ItemStack item){
  try {
    ItemStack clone=item.clone();
    clone.setAmount(1);
    String code=Base64.encodeObject(yaml.dump(clone));
    table.insertRow("String_Node_Str" + code + '\'');
    int id=Integer.parseInt(table.getRow("String_Node_Str" + code + '\'').get("String_Node_Str"));
    return Base62.encode(id);
  }
 catch (  IOException e) {
    e.printStackTrace();
    return null;
  }
catch (  SQLException e) {
    e.printStackTrace();
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Gets the item code for this item
 * @param item Item
 * @return Item code for this item
 */
public String getItemCode(ItemStack item){
  try {
    ItemStack clone=new ItemStack(item);
    clone.setAmount(1);
    String code=Base64.encodeObject(yaml.dump(clone));
    table.insertRow("String_Node_Str" + code + '\'');
    int id=Integer.parseInt(table.getRow("String_Node_Str" + code + '\'').get("String_Node_Str"));
    return Base62.encode(id);
  }
 catch (  IOException e) {
    e.printStackTrace();
    return null;
  }
catch (  SQLException e) {
    e.printStackTrace();
    return null;
  }
catch (  IllegalArgumentException e) {
    return null;
  }
}
Program: 17158
Project: 17158
Buggy source:
@EventHandler public static void onPlayerTeleport(PlayerTeleportEvent event){
  if (!event.getPlayer().isConversing()) {
    event.getPlayer().closeInventory();
  }
}

Fixed version (ground truth):
@EventHandler public static void onPlayerTeleport(PlayerTeleportEvent event){
  if (event.getPlayer().getOpenInventory().getType() != InventoryType.CRAFTING) {
    event.getPlayer().closeInventory();
  }
}
Program: 17159
Project: 17159
Buggy source:
@EventHandler public static void onPlayerTeleport(PlayerTeleportEvent event){
  event.getPlayer().closeInventory();
}

Fixed version (ground truth):
@EventHandler public static void onPlayerTeleport(PlayerTeleportEvent event){
  if (!event.getPlayer().isConversing()) {
    event.getPlayer().closeInventory();
  }
}
Program: 17160
Project: 17160
Buggy source:
@EventHandler public void onCurrencyHoldCheck(CurrencyHoldEvent event){
  EconomyResponse response=provider.depositPlayer(event.getAccount(),event.getWorld().getName(),event.getDoubleAmount());
  if (!response.transactionSuccess()) {
    event.canHold(false);
  }
  provider.withdrawPlayer(event.getAccount(),event.getWorld().getName(),event.getDoubleAmount());
}

Fixed version (ground truth):
@EventHandler public void onCurrencyHoldCheck(CurrencyHoldEvent event){
  if (event.getAccount().isEmpty() || !transactionCanFail()) {
    return;
  }
  if (!provider.hasAccount(event.getAccount(),event.getWorld().getName())) {
    event.canHold(false);
    return;
  }
  EconomyResponse response=provider.depositPlayer(event.getAccount(),event.getWorld().getName(),event.getDoubleAmount());
  if (!response.transactionSuccess()) {
    event.canHold(false);
    return;
  }
  provider.withdrawPlayer(event.getAccount(),event.getWorld().getName(),event.getDoubleAmount());
}
Program: 17161
Project: 17161
Buggy source:
private void setupDB(){
  Database DB;
  DB=new Database(this){
    protected java.util.List<Class<?>> getDatabaseClasses(){
      List<Class<?>> list=new ArrayList<Class<?>>();
      list.add(Transaction.class);
      return list;
    }
  }
;
  FileConfiguration config=YamlConfiguration.loadConfiguration(new File("String_Node_Str"));
  DB.initializeDatabase(config.getString("String_Node_Str"),config.getString("String_Node_Str"),config.getString("String_Node_Str"),config.getString("String_Node_Str"),config.getString("String_Node_Str"));
  database=DB.getDatabase();
  scheduleTask(new Queue(),200L,200L);
}

Fixed version (ground truth):
private void setupDB(){
  loadFile(new File("String_Node_Str"));
  Database DB;
  DB=new Database(this){
    protected java.util.List<Class<?>> getDatabaseClasses(){
      List<Class<?>> list=new ArrayList<Class<?>>();
      list.add(Transaction.class);
      return list;
    }
  }
;
  FileConfiguration config=YamlConfiguration.loadConfiguration(new File("String_Node_Str"));
  DB.initializeDatabase(config.getString("String_Node_Str"),config.getString("String_Node_Str"),config.getString("String_Node_Str"),config.getString("String_Node_Str"),config.getString("String_Node_Str"));
  database=DB.getDatabase();
  scheduleTask(new Queue(),200L,200L);
}
Program: 17162
Project: 17162
Buggy source:
public void onEnable(){
  plugin=this;
  logger=getLogger();
  dataFolder=getDataFolder();
  description=getDescription();
  server=getServer();
  itemDatabase=new ItemDatabase();
  Configuration.pairFileAndClass(loadFile("String_Node_Str"),Properties.class);
  Configuration.pairFileAndClass(loadFile("String_Node_Str"),Messages.class);
  uName.file=loadFile("String_Node_Str");
  uName.load();
  Methods.setPreferred(Properties.PREFERRED_ECONOMY_PLUGIN);
  Dependencies.load();
  registerEvents();
  if (Properties.LOG_TO_DATABASE || Properties.GENERATE_STATISTICS_PAGE) {
    setupDB();
  }
  if (Properties.GENERATE_STATISTICS_PAGE) {
    File htmlFolder=new File(Properties.STATISTICS_PAGE_PATH);
    scheduleTask(new Generator(htmlFolder),300L,Properties.STATISTICS_PAGE_GENERATION_INTERVAL * 20L);
  }
  if (Properties.LOG_TO_FILE) {
    File log=loadFile("String_Node_Str");
    FileHandler handler=loadHandler(log.getAbsolutePath());
    handler.setFormatter(new FileFormatter());
    this.handler=handler;
    logger.addHandler(handler);
  }
  if (!Properties.LOG_TO_CONSOLE) {
    logger.setUseParentHandlers(false);
  }
  getCommand("String_Node_Str").setExecutor(new ItemInfo());
  getCommand("String_Node_Str").setExecutor(new Version());
  startStatistics();
}

Fixed version (ground truth):
public void onEnable(){
  plugin=this;
  logger=getLogger();
  dataFolder=getDataFolder();
  description=getDescription();
  server=getServer();
  Configuration.pairFileAndClass(loadFile("String_Node_Str"),Properties.class);
  Configuration.pairFileAndClass(loadFile("String_Node_Str"),Messages.class);
  itemDatabase=new ItemDatabase();
  uName.file=loadFile("String_Node_Str");
  uName.load();
  Methods.setPreferred(Properties.PREFERRED_ECONOMY_PLUGIN);
  Dependencies.load();
  registerEvents();
  if (Properties.LOG_TO_DATABASE || Properties.GENERATE_STATISTICS_PAGE) {
    setupDB();
  }
  if (Properties.GENERATE_STATISTICS_PAGE) {
    File htmlFolder=new File(Properties.STATISTICS_PAGE_PATH);
    scheduleTask(new Generator(htmlFolder),300L,Properties.STATISTICS_PAGE_GENERATION_INTERVAL * 20L);
  }
  if (Properties.LOG_TO_FILE) {
    File log=loadFile("String_Node_Str");
    FileHandler handler=loadHandler(log.getAbsolutePath());
    handler.setFormatter(new FileFormatter());
    this.handler=handler;
    logger.addHandler(handler);
  }
  if (!Properties.LOG_TO_CONSOLE) {
    logger.setUseParentHandlers(false);
  }
  getCommand("String_Node_Str").setExecutor(new ItemInfo());
  getCommand("String_Node_Str").setExecutor(new Version());
  startStatistics();
}
Program: 17163
Project: 17163
Buggy source:
public ItemDatabase(){
  try {
    Class.forName("String_Node_Str");
  }
 catch (  ClassNotFoundException e) {
    e.printStackTrace();
    ChestShop.getBukkitLogger().severe("String_Node_Str");
  }
  Database database=new Database("String_Node_Str" + new File(ChestShop.getFolder(),"String_Node_Str").getAbsolutePath());
  yaml=new Yaml(new YamlConstructor(),new YamlRepresenter(),new DumperOptions());
  try {
    Statement statement=database.getConnection().createStatement();
    statement.executeUpdate("String_Node_Str");
    statement.close();
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
  try {
    table=database.getTable("String_Node_Str");
    table.create("String_Node_Str");
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public ItemDatabase(){
  try {
    Class.forName("String_Node_Str");
  }
 catch (  ClassNotFoundException e) {
    e.printStackTrace();
    ChestShop.getBukkitLogger().severe("String_Node_Str");
  }
  Database database=new Database("String_Node_Str" + ChestShop.loadFile("String_Node_Str").getAbsolutePath());
  yaml=new Yaml(new YamlConstructor(),new YamlRepresenter(),new DumperOptions());
  try {
    Statement statement=database.getConnection().createStatement();
    statement.executeUpdate("String_Node_Str");
    statement.close();
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
  try {
    table=database.getTable("String_Node_Str");
    table.create("String_Node_Str");
  }
 catch (  SQLException e) {
    e.printStackTrace();
  }
}
Program: 17164
Project: 17164
Buggy source:
private void registerEvents(){
  registerEvent(new com.Acrobot.ChestShop.Plugins.ChestShop());
  registerPreShopCreationEvents();
  registerPreTransactionEvents();
  registerPostShopCreationEvents();
  registerPostTransactionEvents();
  registerEvent(new SignBreak());
  registerEvent(new SignCreate());
  registerEvent(new ChestBreak());
  registerEvent(new BlockPlace());
  registerEvent(new PlayerConnect());
  registerEvent(new PlayerInteract());
  registerEvent(new PlayerInventory());
  registerEvent(new ItemInfoListener());
  registerEvent(new RestrictedSign());
  registerEvent(new ShopRefundListener());
  registerEvent(new ShortNameSaver());
  registerEvent(new TeleportFixListener());
}

Fixed version (ground truth):
private void registerEvents(){
  registerEvent(new com.Acrobot.ChestShop.Plugins.ChestShop());
  registerPreShopCreationEvents();
  registerPreTransactionEvents();
  registerPostShopCreationEvents();
  registerPostTransactionEvents();
  registerEvent(new SignBreak());
  registerEvent(new SignCreate());
  registerEvent(new ChestBreak());
  registerEvent(new BlockPlace());
  registerEvent(new PlayerConnect());
  registerEvent(new PlayerInteract());
  registerEvent(new PlayerInventory());
  registerEvent(new ItemInfoListener());
  registerEvent(new RestrictedSign());
  registerEvent(new ShopRefundListener());
  registerEvent(new ShortNameSaver());
  if (!Properties.TURN_OFF_CRAFTBUKKIT_TELEPORTATION_BUGFIX) {
    registerEvent(new TeleportFixListener());
  }
}
Program: 17165
Project: 17165
Buggy source:
private void registerEvents(){
  registerEvent(new com.Acrobot.ChestShop.Plugins.ChestShop());
  registerPreShopCreationEvents();
  registerPreTransactionEvents();
  registerPostShopCreationEvents();
  registerPostTransactionEvents();
  registerEvent(new SignBreak());
  registerEvent(new SignCreate());
  registerEvent(new ChestBreak());
  registerEvent(new BlockPlace());
  registerEvent(new PlayerConnect());
  registerEvent(new PlayerInteract());
  registerEvent(new PlayerInventory());
  registerEvent(new ItemInfoListener());
  registerEvent(new RestrictedSign());
  registerEvent(new ShopRefundListener());
  registerEvent(new ShortNameSaver());
  if (!Properties.TURN_OFF_CRAFTBUKKIT_TELEPORTATION_BUGFIX) {
    registerEvent(new TeleportFixListener());
  }
}

Fixed version (ground truth):
private void registerEvents(){
  registerEvent(new com.Acrobot.ChestShop.Plugins.ChestShop());
  registerPreShopCreationEvents();
  registerPreTransactionEvents();
  registerPostShopCreationEvents();
  registerPostTransactionEvents();
  registerEvent(new SignBreak());
  registerEvent(new SignCreate());
  registerEvent(new ChestBreak());
  registerEvent(new BlockPlace());
  registerEvent(new PlayerConnect());
  registerEvent(new PlayerInteract());
  registerEvent(new PlayerInventory());
  registerEvent(new ItemInfoListener());
  registerEvent(new RestrictedSign());
  registerEvent(new ShopRefundListener());
  registerEvent(new ShortNameSaver());
}
Program: 17166
Project: 17166
Buggy source:
@EventHandler(priority=EventPriority.LOW) public static void onPreBuyTransaction(PreTransactionEvent event){
  if (event.isCancelled() || event.getTransactionType() != BUY) {
    return;
  }
  Player client=event.getClient();
  String clientName=client.getName();
  ItemStack[] stock=event.getStock();
  double price=event.getPrice();
  double pricePerItem=event.getPrice() / InventoryUtil.countItems(stock);
  double walletMoney=Economy.getBalance(clientName);
  if (!Economy.hasEnough(clientName,price)) {
    int amountAffordable=getAmountOfAffordableItems(walletMoney,pricePerItem);
    if (amountAffordable < 1) {
      event.setCancelled(CLIENT_DOES_NOT_HAVE_ENOUGH_MONEY);
      return;
    }
    event.setPrice(amountAffordable * pricePerItem);
    event.setStock(getCountedItemStack(stock,amountAffordable));
  }
  String seller=event.getOwner().getName();
  if (Economy.transactionCanFail()) {
    if (Economy.add(seller,price)) {
      Economy.subtract(seller,price);
    }
 else {
      event.setCancelled(SHOP_DEPOSIT_FAILED);
      return;
    }
  }
  stock=event.getStock();
  if (!InventoryUtil.hasItems(stock,event.getOwnerInventory())) {
    ItemStack[] itemsHad=getItems(stock,event.getOwnerInventory());
    int posessedItemCount=InventoryUtil.countItems(itemsHad);
    if (posessedItemCount <= 0) {
      event.setCancelled(NOT_ENOUGH_STOCK_IN_CHEST);
      return;
    }
    event.setPrice(pricePerItem * posessedItemCount);
    event.setStock(itemsHad);
  }
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOW) public static void onPreBuyTransaction(PreTransactionEvent event){
  if (event.isCancelled() || event.getTransactionType() != BUY) {
    return;
  }
  Player client=event.getClient();
  String clientName=client.getName();
  ItemStack[] stock=event.getStock();
  double price=event.getPrice();
  double pricePerItem=event.getPrice() / InventoryUtil.countItems(stock);
  double walletMoney=Economy.getBalance(clientName);
  if (!Economy.hasEnough(clientName,price)) {
    int amountAffordable=getAmountOfAffordableItems(walletMoney,pricePerItem);
    if (amountAffordable < 1) {
      event.setCancelled(CLIENT_DOES_NOT_HAVE_ENOUGH_MONEY);
      return;
    }
    event.setPrice(amountAffordable * pricePerItem);
    event.setStock(getCountedItemStack(stock,amountAffordable));
  }
  String seller=event.getOwner().getName();
  if (!Economy.canHold(seller,price)) {
    event.setCancelled(SHOP_DEPOSIT_FAILED);
    return;
  }
  stock=event.getStock();
  if (!InventoryUtil.hasItems(stock,event.getOwnerInventory())) {
    ItemStack[] itemsHad=getItems(stock,event.getOwnerInventory());
    int posessedItemCount=InventoryUtil.countItems(itemsHad);
    if (posessedItemCount <= 0) {
      event.setCancelled(NOT_ENOUGH_STOCK_IN_CHEST);
      return;
    }
    event.setPrice(pricePerItem * posessedItemCount);
    event.setStock(itemsHad);
  }
}
Program: 17167
Project: 17167
Buggy source:
@EventHandler(priority=EventPriority.LOW) public static void onPreSellTransaction(PreTransactionEvent event){
  if (event.isCancelled() || event.getTransactionType() != SELL) {
    return;
  }
  String player=event.getClient().getName();
  String ownerName=event.getOwner().getName();
  ItemStack[] stock=event.getStock();
  double price=event.getPrice();
  double pricePerItem=event.getPrice() / InventoryUtil.countItems(stock);
  double walletMoney=Economy.getBalance(ownerName);
  if (Economy.isOwnerEconomicallyActive(event.getOwnerInventory()) && !Economy.hasEnough(ownerName,price)) {
    int amountAffordable=getAmountOfAffordableItems(walletMoney,pricePerItem);
    if (amountAffordable < 1) {
      event.setCancelled(SHOP_DOES_NOT_HAVE_ENOUGH_MONEY);
      return;
    }
    event.setPrice(amountAffordable * pricePerItem);
    event.setStock(getCountedItemStack(stock,amountAffordable));
  }
  stock=event.getStock();
  if (Economy.add(player,price)) {
    Economy.subtract(player,price);
  }
 else {
    event.setCancelled(CLIENT_DEPOSIT_FAILED);
    return;
  }
  if (!InventoryUtil.hasItems(stock,event.getClientInventory())) {
    ItemStack[] itemsHad=getItems(stock,event.getClientInventory());
    int posessedItemCount=InventoryUtil.countItems(itemsHad);
    if (posessedItemCount <= 0) {
      event.setCancelled(NOT_ENOUGH_STOCK_IN_INVENTORY);
      return;
    }
    event.setPrice(pricePerItem * posessedItemCount);
    event.setStock(itemsHad);
  }
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOW) public static void onPreSellTransaction(PreTransactionEvent event){
  if (event.isCancelled() || event.getTransactionType() != SELL) {
    return;
  }
  String player=event.getClient().getName();
  String ownerName=event.getOwner().getName();
  ItemStack[] stock=event.getStock();
  double price=event.getPrice();
  double pricePerItem=event.getPrice() / InventoryUtil.countItems(stock);
  double walletMoney=Economy.getBalance(ownerName);
  if (Economy.isOwnerEconomicallyActive(event.getOwnerInventory()) && !Economy.hasEnough(ownerName,price)) {
    int amountAffordable=getAmountOfAffordableItems(walletMoney,pricePerItem);
    if (amountAffordable < 1) {
      event.setCancelled(SHOP_DOES_NOT_HAVE_ENOUGH_MONEY);
      return;
    }
    event.setPrice(amountAffordable * pricePerItem);
    event.setStock(getCountedItemStack(stock,amountAffordable));
  }
  stock=event.getStock();
  if (!Economy.canHold(player,price)) {
    event.setCancelled(CLIENT_DEPOSIT_FAILED);
    return;
  }
  if (!InventoryUtil.hasItems(stock,event.getClientInventory())) {
    ItemStack[] itemsHad=getItems(stock,event.getClientInventory());
    int posessedItemCount=InventoryUtil.countItems(itemsHad);
    if (posessedItemCount <= 0) {
      event.setCancelled(NOT_ENOUGH_STOCK_IN_INVENTORY);
      return;
    }
    event.setPrice(pricePerItem * posessedItemCount);
    event.setStock(itemsHad);
  }
}
Program: 17168
Project: 17168
Buggy source:
@EventHandler(priority=EventPriority.LOWEST) public static void onPreShopCreation(PreShopCreationEvent event){
  String line=event.getSignLine(PRICE_LINE).toUpperCase();
  String[] part=line.split("String_Node_Str");
  if (isPrice(part[0])) {
    line="String_Node_Str" + line;
  }
  if (part.length > 1 && isPrice(part[1])) {
    line+="String_Node_Str";
  }
  line=line.replace('b','B').replace('s','S');
  if (line.length() > 15) {
    line=line.replace("String_Node_Str","String_Node_Str");
  }
  if (line.length() > 15) {
    event.setOutcome(INVALID_PRICE);
    return;
  }
  event.setSignLine(PRICE_LINE,line);
  double buyPrice=PriceUtil.getBuyPrice(line);
  double sellPrice=PriceUtil.getSellPrice(line);
  if (buyPrice == 0 && sellPrice == 0) {
    event.setOutcome(INVALID_PRICE);
  }
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOWEST) public static void onPreShopCreation(PreShopCreationEvent event){
  String line=event.getSignLine(PRICE_LINE).toUpperCase();
  String[] part=line.split("String_Node_Str");
  if (isPrice(part[0])) {
    line="String_Node_Str" + line;
  }
  if (part.length > 1 && isPrice(part[1])) {
    line+="String_Node_Str";
  }
  line=line.replace('b','B').replace('s','S');
  if (line.length() > 15) {
    line=line.replace("String_Node_Str","String_Node_Str");
  }
  if (line.length() > 15) {
    event.setOutcome(INVALID_PRICE);
    return;
  }
  event.setSignLine(PRICE_LINE,line);
  if (!PriceUtil.hasBuyPrice(line) && !PriceUtil.hasSellPrice(line)) {
    event.setOutcome(INVALID_PRICE);
  }
}