nus-yam/ex-repair huggingface dataset:
Program: 51423
Project: 51423
Buggy source:
/** 
 * Load the inventory. It will automatically try to load it from a file, or import it from another plugin, or use the default chest.
 * @param chestOwner Owner of the inventory.
 * @param worldGroup Name of the world group the inventory is in.
 * @return The Inventory. {@link BetterEnderInventoryHolder} will be theholder of the inventory.
 */
public void loadFromFileOrImport(ChestOwner chestOwner,WorldGroup worldGroup,Consumer<Inventory> callback){
  try {
    callback.consume(loadFromFileOrError0(chestOwner,worldGroup));
  }
 catch (  ChestNotFoundException e) {
    plugin.getEmptyInventoryProvider().getFallbackInventory(chestOwner,worldGroup,callback);
  }
catch (  IOException e) {
    plugin.severe("String_Node_Str" + chestOwner.getDisplayName(),e);
    plugin.disableSaveAndLoad("String_Node_Str" + chestOwner.getDisplayName(),e);
    callback.consume(plugin.getEmptyInventoryProvider().loadEmptyInventory(chestOwner,worldGroup));
  }
}

Fixed version (ground truth):
/** 
 * Load the inventory. It will automatically try to load it from a file, or import it from another plugin, or use the default chest.
 * @param chestOwner Owner of the inventory.
 * @param worldGroup Name of the world group the inventory is in.
 * @param callback Called with the Inventory as parameter. {@link BetterEnderInventoryHolder} will be the holder of theinventory.
 */
public void loadFromFileOrImport(ChestOwner chestOwner,WorldGroup worldGroup,Consumer<Inventory> callback){
  try {
    callback.consume(loadFromFileOrError0(chestOwner,worldGroup));
  }
 catch (  ChestNotFoundException e) {
    plugin.getEmptyInventoryProvider().getFallbackInventory(chestOwner,worldGroup,callback);
  }
catch (  IOException e) {
    plugin.severe("String_Node_Str" + chestOwner.getDisplayName(),e);
    plugin.disableSaveAndLoad("String_Node_Str" + chestOwner.getDisplayName(),e);
    callback.consume(plugin.getEmptyInventoryProvider().loadEmptyInventory(chestOwner,worldGroup));
  }
}
Program: 51424
Project: 51424
Buggy source:
/** 
 * Saves an inventory to a file. It should cache things like the number of rows, the number of disabled slots and the inventory name. The holder of this inventory name is always a   {@link BetterEnderInventoryHolder}.
 * @param inventory The inventory to save.
 * @param chestOwner The owner of the inventory.
 * @param group The group the inventory is in.
 */
public void saveInventory(Inventory inventory,ChestOwner chestOwner,WorldGroup group) throws IOException {
  File file=getChestFile(chestOwner,group);
  plugin.getNMSHandlers().getSelectedRegistration().saveInventoryToFile(file,inventory);
}

Fixed version (ground truth):
/** 
 * Saves an inventory to a file. It should cache things like the number of rows, the number of disabled slots and the inventory name. The holder of this inventory name is always a   {@link BetterEnderInventoryHolder}.
 * @param inventory The inventory to save.
 * @param chestOwner The owner of the inventory.
 * @param group The group the inventory is in.
 * @throws IOException When saving fails.
 */
public void saveInventory(Inventory inventory,ChestOwner chestOwner,WorldGroup group) throws IOException {
  File file=getChestFile(chestOwner,group);
  plugin.getNMSHandlers().getSelectedRegistration().saveInventoryToFile(file,inventory);
}
Program: 51425
Project: 51425
Buggy source:
/** 
 * Calls the callback on the main thread. This method can be called from any thread.
 * @param plugin The plugin, needed for Bukkit's scheduler.
 * @param jsonData The raw bytes of the inventory that was just loaded.
 */
public void callback(final BetterEnderChest plugin,final BetterEnderSQLCache cache,final String jsonData){
  if (Bukkit.isPrimaryThread()) {
    callbackOnMainThread(plugin,cache,jsonData);
  }
 else {
    Bukkit.getScheduler().runTask(plugin.getPlugin(),new Runnable(){
      @Override public void run(){
        callbackOnMainThread(plugin,cache,jsonData);
      }
    }
);
  }
}

Fixed version (ground truth):
/** 
 * Calls the callback on the main thread. This method can be called from any thread.
 * @param plugin The plugin, needed for Bukkit's scheduler.
 * @param cache The cache, to put the inventory in.
 * @param jsonData The raw bytes of the inventory that was just loaded.
 */
public void callback(final BetterEnderChest plugin,final BetterEnderSQLCache cache,final String jsonData){
  if (Bukkit.isPrimaryThread()) {
    callbackOnMainThread(plugin,cache,jsonData);
  }
 else {
    Bukkit.getScheduler().runTask(plugin.getPlugin(),new Runnable(){
      @Override public void run(){
        callbackOnMainThread(plugin,cache,jsonData);
      }
    }
);
  }
}
Program: 51426
Project: 51426
Buggy source:
/** 
 * Gets the world group of the inventory that should be loaded.
 * @return
 */
public WorldGroup getWorldGroup(){
  return worldGroup;
}

Fixed version (ground truth):
/** 
 * Gets the world group of the inventory that should be loaded.
 * @return The world group.
 */
public WorldGroup getWorldGroup(){
  return worldGroup;
}
Program: 51427
Project: 51427
Buggy source:
/** 
 * Saves a BetterEnderChest inventory to a NBT formatted file.
 * @param file The NBT file to save to. If the file does not exist, it is created.
 * @param inventory The inventory to save to. It must have BetterEnderInventoryHolder as it's holder.
 */
public abstract void saveInventoryToFile(File file,Inventory inventory) throws IOException ;

Fixed version (ground truth):
/** 
 * Saves a BetterEnderChest inventory to a NBT formatted file.
 * @param file The NBT file to save to. If the file does not exist, it is created.
 * @param inventory The inventory to save to. It must have BetterEnderInventoryHolder as it's holder.
 * @throws IOException When an IO error occurs.
 */
public abstract void saveInventoryToFile(File file,Inventory inventory) throws IOException ;
Program: 51428
Project: 51428
Buggy source:
/** 
 * Saves a BetterEnderChest inventory to a JSON-formatted String, based on the NBT representation of the inventory.
 * @param file The NBT file to save to. If the file does not exist, it is created.
 * @param inventory The inventory to save to. It must have BetterEnderInventoryHolder as it's holder.
 */
public abstract String saveInventoryToJson(Inventory inventory) throws IOException ;

Fixed version (ground truth):
/** 
 * Saves a BetterEnderChest inventory to a JSON-formatted String, based on the NBT representation of the inventory.
 * @param inventory The inventory to save to. It must have BetterEnderInventoryHolder as it's holder.
 * @throws IOException When the NBT can somehow not be converted to JSON.
 * @return The JSON string.
 */
public abstract String saveInventoryToJson(Inventory inventory) throws IOException ;
Program: 51429
Project: 51429
Buggy source:
/** 
 * Loads a BetterEnderChest inventory from the JSON String, which represents the NBT format of the inventory. The inventory will have the specified name and will be loaded from the specified child tag (vanilla uses EnderItems and BeterEnderChest uses Inventory). It will also search for the chest size tag in the root of the file, but it should guess them if they are not provided. <p /> It is not permitted to use another load format than NBT, as for example the vanilla importing process depends on it.
 * @param chestOwner The owner of the inventory.
 * @param worldGroup The world group the inventory is in.
 * @param nbtFile The array to load from.
 * @throws IOException If the byte array is corrupted.
 * @return The inventory. The holder of the inventory must beBetterEnderInventoryHolder.
 */
public abstract Inventory loadNBTInventoryFromJson(String jsonString,ChestOwner chestOwner,WorldGroup worldGroup) throws IOException ;

Fixed version (ground truth):
/** 
 * Loads a BetterEnderChest inventory from the JSON String, which represents the NBT format of the inventory. The inventory will have the specified name and will be loaded from the specified child tag (vanilla uses EnderItems and BeterEnderChest uses Inventory). It will also search for the chest size tag in the root of the file, but it should guess them if they are not provided. <p /> It is not permitted to use another load format than NBT, as for example the vanilla importing process depends on it.
 * @param chestOwner The owner of the inventory.
 * @param worldGroup The world group the inventory is in.
 * @param jsonString The json to load from.
 * @throws IOException If the byte array is corrupted.
 * @return The inventory. The holder of the inventory must beBetterEnderInventoryHolder.
 */
public abstract Inventory loadNBTInventoryFromJson(String jsonString,ChestOwner chestOwner,WorldGroup worldGroup) throws IOException ;
Program: 51430
Project: 51430
Buggy source:
private NBTTagCompound saveInventoryToTag(Inventory inventory) throws IOException {
  BetterEnderInventoryHolder holder=BetterEnderInventoryHolder.of(inventory);
  NBTTagCompound baseTag=new NBTTagCompound();
  NBTTagList inventoryTag=new NBTTagList();
  baseTag.setByte("String_Node_Str",(byte)(inventory.getSize() / 9));
  baseTag.setByte("String_Node_Str",(byte)holder.getDisabledSlots());
  baseTag.setString("String_Node_Str",holder.getChestOwner().getDisplayName());
  for (int i=0; i < inventory.getSize(); i++) {
    ItemStack stack=inventory.getItem(i);
    if (stack != null && stack.getType() != Material.AIR) {
      NBTTagCompound item=new NBTTagCompound();
      item.setByte("String_Node_Str",(byte)i);
      inventoryTag.add(CraftItemStack.asNMSCopy(stack).save(item));
    }
  }
  baseTag.set("String_Node_Str",inventoryTag);
  return baseTag;
}

Fixed version (ground truth):
private NBTTagCompound saveInventoryToTag(Inventory inventory){
  BetterEnderInventoryHolder holder=BetterEnderInventoryHolder.of(inventory);
  NBTTagCompound baseTag=new NBTTagCompound();
  NBTTagList inventoryTag=new NBTTagList();
  baseTag.setByte("String_Node_Str",(byte)(inventory.getSize() / 9));
  baseTag.setByte("String_Node_Str",(byte)holder.getDisabledSlots());
  baseTag.setString("String_Node_Str",holder.getChestOwner().getDisplayName());
  for (int i=0; i < inventory.getSize(); i++) {
    ItemStack stack=inventory.getItem(i);
    if (stack != null && stack.getType() != Material.AIR) {
      NBTTagCompound item=new NBTTagCompound();
      item.setByte("String_Node_Str",(byte)i);
      inventoryTag.add(CraftItemStack.asNMSCopy(stack).save(item));
    }
  }
  baseTag.set("String_Node_Str",inventoryTag);
  return baseTag;
}
Program: 51431
Project: 51431
Buggy source:
/** 
 * Converts from a List<Number>, as found in the JSON, to int[].
 * @param boxed List from the JSON. return The int array.
 */
private static final int[] unboxIntegers(List<Number> boxed){
  int[] ints=new int[boxed.size()];
  for (int i=0; i < ints.length; i++) {
    ints[i]=boxed.get(i).intValue();
  }
  return ints;
}

Fixed version (ground truth):
/** 
 * Converts from a List<Number>, as found in the JSON, to int[].
 * @param boxed List from the JSON. return The int array.
 * @return The unboxed ints.
 */
private static final int[] unboxIntegers(List<Number> boxed){
  int[] ints=new int[boxed.size()];
  for (int i=0; i < ints.length; i++) {
    ints[i]=boxed.get(i).intValue();
  }
  return ints;
}
Program: 51432
Project: 51432
Buggy source:
/** 
 * Converts from a List<Number>, as found in the JSON, to byte[].
 * @param boxed List from the JSON. return The byte array.
 */
private static final byte[] unboxBytes(List<Number> boxed){
  byte[] bytes=new byte[boxed.size()];
  for (int i=0; i < bytes.length; i++) {
    bytes[i]=boxed.get(i).byteValue();
  }
  return bytes;
}

Fixed version (ground truth):
/** 
 * Converts from a List<Number>, as found in the JSON, to byte[].
 * @param boxed List from the JSON. return The byte array.
 * @return The unboxed bytes.
 */
private static final byte[] unboxBytes(List<Number> boxed){
  byte[] bytes=new byte[boxed.size()];
  for (int i=0; i < bytes.length; i++) {
    bytes[i]=boxed.get(i).byteValue();
  }
  return bytes;
}
Program: 51434
Project: 51434
Buggy source:
@SuppressWarnings("String_Node_Str") public void handleDisabledSlots(InventoryClickEvent event){
  Inventory inventory=event.getInventory();
  BetterEnderInventoryHolder holder=(BetterEnderInventoryHolder)inventory.getHolder();
  if (holder.getDisabledSlots() == 0) {
    return;
  }
  if (event.isShiftClick()) {
    if (event.getSlot() == event.getRawSlot()) {
      return;
    }
    if (event.getCurrentItem() == null || event.getCurrentItem().getType().equals(Material.AIR)) {
      return;
    }
    event.setCancelled(true);
    ItemStack adding=event.getCurrentItem();
    for (int i=0; i < inventory.getSize() - holder.getDisabledSlots(); i++) {
      ItemStack inSlot=inventory.getItem(i);
      if (inSlot == null || inSlot.getType().equals(Material.AIR)) {
        inventory.setItem(i,adding);
        event.setCurrentItem(new ItemStack(Material.AIR,0));
        return;
      }
      if (inSlot.isSimilar(adding)) {
        int itemsToAdd=Math.min(inventory.getMaxStackSize(),inSlot.getMaxStackSize()) - inSlot.getAmount();
        itemsToAdd=Math.min(adding.getAmount(),itemsToAdd);
        if (itemsToAdd > 0) {
          inSlot.setAmount(inSlot.getAmount() + itemsToAdd);
          inventory.setItem(i,inSlot);
        }
        if (itemsToAdd >= adding.getAmount()) {
          event.setCurrentItem(new ItemStack(Material.AIR,0));
          return;
        }
 else {
          adding.setAmount(adding.getAmount() - itemsToAdd);
        }
      }
    }
    event.setCurrentItem(adding);
  }
 else {
    if (event.getSlot() != event.getRawSlot()) {
      return;
    }
    if (inventory.getSize() - event.getSlot() <= holder.getDisabledSlots()) {
      if (event.getCursor().getType() != Material.AIR) {
        if (event.getWhoClicked() instanceof Player) {
          ((Player)event.getWhoClicked()).updateInventory();
        }
        event.setCancelled(true);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Makes sure that players cannot put items in disabled slots. Assumes that the inventory has   {@link BetterEnderInventoryHolder} as the holder.
 * @param event The inventory click event.
 */
protected void handleDisabledSlots(InventoryClickEvent event){
  Inventory inventory=event.getInventory();
  BetterEnderInventoryHolder holder=(BetterEnderInventoryHolder)inventory.getHolder();
  if (holder.getDisabledSlots() == 0) {
    return;
  }
  if (event.isShiftClick()) {
    handleDisabledSlotsShiftClick(event);
  }
 else {
    handleDisabledSlotsNormalClick(event);
  }
}
Program: 51435
Project: 51435
Buggy source:
@Override public void saveInventoryAsNBT(File file,Inventory inventory){
  try {
    BetterEnderInventoryHolder holder=(BetterEnderInventoryHolder)inventory.getHolder();
    NBTTagCompound baseTag=new NBTTagCompound();
    NBTTagList inventoryTag=new NBTTagList();
    baseTag.setByte("String_Node_Str",(byte)(inventory.getSize() / 9));
    baseTag.setByte("String_Node_Str",(byte)holder.getDisabledSlots());
    baseTag.setString("String_Node_Str",holder.getName());
    baseTag.setByte("String_Node_Str",(byte)(holder.isOwnerNameCaseCorrect() ? 1 : 0));
    for (int i=0; i < inventory.getSize(); i++) {
      ItemStack stack=inventory.getItem(i);
      if (stack != null && stack.getType() != Material.AIR) {
        NBTTagCompound item=new NBTTagCompound();
        item.setByte("String_Node_Str",(byte)i);
        inventoryTag.add(CraftItemStack.asNMSCopy(stack).save(item));
      }
    }
    baseTag.set("String_Node_Str",inventoryTag);
    file.getParentFile().mkdirs();
    FileOutputStream stream;
    file.createNewFile();
    stream=new FileOutputStream(file);
    NBTCompressedStreamTools.a(baseTag,stream);
    stream.flush();
    stream.close();
    throw new IOException("String_Node_Str");
  }
 catch (  IOException e) {
    plugin.log("String_Node_Str",Level.SEVERE);
    e.printStackTrace();
    plugin.getNMSHandlers().selectRegistration(null);
  }
catch (  Throwable t) {
    plugin.log("String_Node_Str",Level.SEVERE);
    t.printStackTrace();
  }
}

Fixed version (ground truth):
@Override public void saveInventoryAsNBT(File file,Inventory inventory){
  try {
    BetterEnderInventoryHolder holder=(BetterEnderInventoryHolder)inventory.getHolder();
    NBTTagCompound baseTag=new NBTTagCompound();
    NBTTagList inventoryTag=new NBTTagList();
    baseTag.setByte("String_Node_Str",(byte)(inventory.getSize() / 9));
    baseTag.setByte("String_Node_Str",(byte)holder.getDisabledSlots());
    baseTag.setString("String_Node_Str",holder.getName());
    baseTag.setByte("String_Node_Str",(byte)(holder.isOwnerNameCaseCorrect() ? 1 : 0));
    for (int i=0; i < inventory.getSize(); i++) {
      ItemStack stack=inventory.getItem(i);
      if (stack != null && stack.getType() != Material.AIR) {
        NBTTagCompound item=new NBTTagCompound();
        item.setByte("String_Node_Str",(byte)i);
        inventoryTag.add(CraftItemStack.asNMSCopy(stack).save(item));
      }
    }
    baseTag.set("String_Node_Str",inventoryTag);
    file.getParentFile().mkdirs();
    FileOutputStream stream;
    file.createNewFile();
    stream=new FileOutputStream(file);
    NBTCompressedStreamTools.a(baseTag,stream);
    stream.flush();
    stream.close();
  }
 catch (  IOException e) {
    plugin.log("String_Node_Str",Level.SEVERE);
    e.printStackTrace();
    plugin.getNMSHandlers().selectRegistration(null);
  }
catch (  Throwable t) {
    plugin.log("String_Node_Str",Level.SEVERE);
    t.printStackTrace();
  }
}
Program: 51436
Project: 51436
Buggy source:
/** 
 * Returns the import of the group, none if it has no import
 * @param group
 * @return
 */
public String getImport(String groupName){
  if (!imports.containsKey(groupName)) {
    return plugin.getConverter().none;
  }
  return imports.get(groupName);
}

Fixed version (ground truth):
/** 
 * Returns the import of the group, none if it has no import
 * @param group
 * @return
 */
public String getImport(String groupName){
  groupName=groupName.toLowerCase();
  if (!imports.containsKey(groupName)) {
    return plugin.getConverter().none;
  }
  return imports.get(groupName);
}
Program: 51437
Project: 51437
Buggy source:
/** 
 * Get the group this world belongs to, default if it isn't listed
 * @param world
 * @return
 */
public String getGroup(String worldName){
  String groupName=worlds.get(worldName);
  if (groupName == null) {
    groupName=BetterEnderChest.defaultGroupName;
  }
  return groupName;
}

Fixed version (ground truth):
/** 
 * Get the group this world belongs to, default if it isn't listed
 * @param world
 * @return
 */
public String getGroup(String worldName){
  worldName=worldName.toLowerCase();
  String groupName=worlds.get(worldName);
  if (groupName == null) {
    groupName=BetterEnderChest.defaultGroupName;
  }
  return groupName;
}
Program: 51438
Project: 51438
Buggy source:
/** 
 * Unloads the inventory from memory. Doesn't save! Also, make sure that no-one is viewing the inventory!
 * @param inventoryName
 */
public void unloadInventory(String inventoryName,String groupName){
  inventoryName=inventoryName.toLowerCase();
  if (inventories.containsKey(groupName)) {
    inventories.get(groupName).remove(inventoryName);
  }
}

Fixed version (ground truth):
/** 
 * Unloads the inventory from memory. Doesn't save! Also, make sure that no-one is viewing the inventory!
 * @param inventoryName
 */
public void unloadInventory(String inventoryName,String groupName){
  inventoryName=inventoryName.toLowerCase();
  groupName=groupName.toLowerCase();
  if (inventories.containsKey(groupName)) {
    inventories.get(groupName).remove(inventoryName);
  }
}
Program: 51439
Project: 51439
Buggy source:
public String toString(){
  StringBuilder builder=new StringBuilder();
  for (  String groupName : inventories.keySet()) {
    HashMap<String,Inventory> group=inventories.get(groupName);
    if (group.size() > 0) {
      builder.append("String_Node_Str" + groupName + "String_Node_Str");
      for (      String inventoryName : group.keySet()) {
        builder.append(((BetterEnderHolder)group.get(inventoryName).getHolder()).getOwnerName() + "String_Node_Str" + group.get(inventoryName).getSize() / 9 + "String_Node_Str");
        builder.append(',');
      }
    }
  }
  if (builder.length() == 0) {
    builder.append("String_Node_Str");
  }
  return builder.toString();
}

Fixed version (ground truth):
public String toString(){
  StringBuilder builder=new StringBuilder();
  for (  String groupName : inventories.keySet()) {
    HashMap<String,Inventory> group=inventories.get(groupName);
    if (group.size() > 0) {
      builder.append("String_Node_Str" + groupName + "String_Node_Str");
      for (      String inventoryName : group.keySet()) {
        builder.append(((BetterEnderHolder)group.get(inventoryName).getHolder()).getOwnerName());
        builder.append(',');
      }
    }
  }
  if (builder.length() == 0) {
    builder.append("String_Node_Str");
  }
  return builder.toString();
}
Program: 51440
Project: 51440
Buggy source:
/** 
 * Get a inventory. If it does not exist, an empty inventory will be returned.
 * @param inventoryName
 * @return
 */
public Inventory getInventory(String inventoryName,String groupName){
  inventoryName=inventoryName.toLowerCase();
  if (inventories.containsKey(groupName) && inventories.get(groupName).containsKey(inventoryName)) {
    return inventories.get(groupName).get(inventoryName);
  }
 else {
    Inventory enderInventory=plugin.getSaveAndLoadSystem().loadInventory(inventoryName,groupName);
    if (!inventories.containsKey(groupName)) {
      inventories.put(groupName,new HashMap<String,Inventory>());
    }
    inventories.get(groupName).put(inventoryName,enderInventory);
    return enderInventory;
  }
}

Fixed version (ground truth):
/** 
 * Get a inventory. If it does not exist, an empty inventory will be returned.
 * @param inventoryName
 * @return
 */
public Inventory getInventory(String inventoryName,String groupName){
  inventoryName=inventoryName.toLowerCase();
  groupName=groupName.toLowerCase();
  if (inventories.containsKey(groupName) && inventories.get(groupName).containsKey(inventoryName)) {
    return inventories.get(groupName).get(inventoryName);
  }
 else {
    Inventory enderInventory=plugin.getSaveAndLoadSystem().loadInventory(inventoryName,groupName);
    if (!inventories.containsKey(groupName)) {
      inventories.put(groupName,new HashMap<String,Inventory>());
    }
    inventories.get(groupName).put(inventoryName,enderInventory);
    return enderInventory;
  }
}
Program: 51441
Project: 51441
Buggy source:
/** 
 * Set a inventory. Make sure the name of the inventory (((EnderHolder)inventory.getHolder()).getOwnerName()) matches the inventoryName.
 * @param inventoryName Name to save the inventory in the list AND the filename
 * @param inventory The new inventory
 */
public void setInventory(String inventoryName,String groupName,Inventory enderInventory){
  inventoryName=inventoryName.toLowerCase();
  if (!inventories.containsKey(groupName)) {
    inventories.put(groupName,new HashMap<String,Inventory>());
  }
  inventories.get(groupName).put(inventoryName,enderInventory);
}

Fixed version (ground truth):
/** 
 * Set a inventory. Make sure the name of the inventory (((EnderHolder)inventory.getHolder()).getOwnerName()) matches the inventoryName.
 * @param inventoryName Name to save the inventory in the list AND the filename
 * @param inventory The new inventory
 */
public void setInventory(String inventoryName,String groupName,Inventory enderInventory){
  inventoryName=inventoryName.toLowerCase();
  groupName=groupName.toLowerCase();
  if (!inventories.containsKey(groupName)) {
    inventories.put(groupName,new HashMap<String,Inventory>());
  }
  inventories.get(groupName).put(inventoryName,enderInventory);
}
Program: 51442
Project: 51442
Buggy source:
/** 
 * Save an inventory, but keep it in memory
 * @param inventoryName
 */
public void saveInventory(String inventoryName,String groupName){
  inventoryName=inventoryName.toLowerCase();
  if (!inventories.containsKey(groupName) || !inventories.get(groupName).containsKey(inventoryName)) {
    return;
  }
  plugin.getSaveAndLoadSystem().saveInventory(inventories.get(groupName).get(inventoryName),inventoryName,groupName);
}

Fixed version (ground truth):
/** 
 * Save an inventory, but keep it in memory
 * @param inventoryName
 */
public void saveInventory(String inventoryName,String groupName){
  inventoryName=inventoryName.toLowerCase();
  groupName=groupName.toLowerCase();
  if (!inventories.containsKey(groupName) || !inventories.get(groupName).containsKey(inventoryName)) {
    return;
  }
  plugin.getSaveAndLoadSystem().saveInventory(inventories.get(groupName).get(inventoryName),inventoryName,groupName);
}
Program: 51443
Project: 51443
Buggy source:
/** 
 * Gets whether the string is a valid chest drop
 * @param drop
 * @return
 */
public boolean isValidChestDrop(String drop){
  if (chestDrop.equals("String_Node_Str"))   return true;
  if (chestDrop.equals("String_Node_Str"))   return true;
  if (chestDrop.equals("String_Node_Str"))   return true;
  if (chestDrop.equals("String_Node_Str"))   return true;
  if (chestDrop.equals("String_Node_Str"))   return true;
  if (chestDrop.equals("String_Node_Str"))   return true;
  if (chestDrop.equals("String_Node_Str"))   return true;
  return false;
}

Fixed version (ground truth):
/** 
 * Gets whether the string is a valid chest drop
 * @param drop
 * @return
 */
public boolean isValidChestDrop(String drop){
  if (drop.equals("String_Node_Str"))   return true;
  if (drop.equals("String_Node_Str"))   return true;
  if (drop.equals("String_Node_Str"))   return true;
  if (drop.equals("String_Node_Str"))   return true;
  if (drop.equals("String_Node_Str"))   return true;
  if (drop.equals("String_Node_Str"))   return true;
  if (drop.equals("String_Node_Str"))   return true;
  return false;
}
Program: 51444
Project: 51444
Buggy source:
private void convertConfig(){
  getConfig().set("String_Node_Str",getConfig().getString("String_Node_Str","String_Node_Str"));
  getConfig().set("String_Node_Str",getConfig().getInt("String_Node_Str",0));
  getConfig().set("String_Node_Str",getConfig().getBoolean("String_Node_Str",false));
  getConfig().set("String_Node_Str",null);
  getConfig().set("String_Node_Str",null);
  getConfig().set("String_Node_Str",null);
}

Fixed version (ground truth):
private void convertConfig(){
  getConfig().set("String_Node_Str",getConfig().getString("String_Node_Str","String_Node_Str"));
  getConfig().set("String_Node_Str",getConfig().getInt("String_Node_Str",3));
  getConfig().set("String_Node_Str",getConfig().getBoolean("String_Node_Str",false));
  getConfig().set("String_Node_Str",null);
  getConfig().set("String_Node_Str",null);
  getConfig().set("String_Node_Str",null);
}
Program: 51446
Project: 51446
Buggy source:
private Route getRouteForJourney(JourneyHeaderElement journey){
  AgencyAndId routeId=getRouteIdForJourney(journey);
  Route route=_dao.getRouteForId(routeId);
  if (route == null) {
    route=new Route();
    route.setAgency(getAgencyForId(routeId.getAgencyId()));
    route.setId(routeId);
    route.setShortName(routeId.getId());
    route.setType(getRouteTypeForJourney(journey));
    _dao.saveEntity(route);
  }
  return route;
}

Fixed version (ground truth):
private Route getRouteForJourney(JourneyHeaderElement journey){
  AgencyAndId routeId=getRouteIdForJourney(journey);
  Route route=_dao.getRouteForId(routeId);
  if (route == null) {
    route=new Route();
    route.setAgency(getAgencyForId(routeId.getAgencyId()));
    route.setId(routeId);
    route.setShortName(journey.getRouteIdentifier());
    route.setType(getRouteTypeForJourney(journey));
    RouteMetadata metaData=_routeMetadataById.get(routeId);
    if (metaData != null) {
      System.currentTimeMillis();
    }
    _dao.saveEntity(route);
  }
  return route;
}
Program: 51447
Project: 51447
Buggy source:
public void addRouteDescription(RouteDescriptionElement route){
  RouteDescriptionElement existing=_routeDescriptionsByDirection.put(route.getRouteDescription(),route);
  if (existing != null) {
    _log.warn("String_Node_Str");
  }
}

Fixed version (ground truth):
public void addRouteDescription(RouteDescriptionElement route){
  RouteDescriptionElement existing=_routeDescriptionsByDirection.put(route.getRouteDirection(),route);
  if (existing != null) {
    _log.warn("String_Node_Str");
  }
}
Program: 51448
Project: 51448
Buggy source:
private ResourceImpl createResource(URL url,String uri) throws BundleException, IOException {
  Map<String,String> headers=getHeaders(url);
  try {
    return ResourceBuilder.build(uri,headers);
  }
 catch (  BundleException e) {
    throw new BundleException("String_Node_Str" + uri + "String_Node_Str"+ e.getMessage(),e);
  }
}

Fixed version (ground truth):
private ResourceImpl createResource(URL url,String uri) throws BundleException, IOException {
  Map<String,String> headers=getHeaders(url);
  try {
    ResourceImpl resource=ResourceBuilder.build(uri,headers);
    useResourceRelativeUri(resource);
    return resource;
  }
 catch (  BundleException e) {
    throw new BundleException("String_Node_Str" + uri + "String_Node_Str"+ e.getMessage(),e);
  }
}
Program: 51449
Project: 51449
Buggy source:
/** 
 * Upload an artifact from the given URL.
 * @param url the URL of the artifact.
 * @throws Exception in case of upload failure.
 */
public void upload(URL url) throws Exception {
  LOGGER.debug("String_Node_Str",url);
  String artifactName="String_Node_Str" + System.currentTimeMillis();
  Path temp=getLocationPath().resolve(artifactName);
  try (InputStream is=url.openStream()){
    Files.copy(is,temp);
  }
   ResourceImpl resource=createResource(temp.toUri().toURL());
  Path destination=getLocationPath().resolve(ResolverUtil.getSymbolicName(resource) + "String_Node_Str" + ResolverUtil.getVersion(resource)+ "String_Node_Str");
  if (Files.exists(destination)) {
    Files.delete(temp);
    LOGGER.warn("String_Node_Str",url);
    throw new IllegalArgumentException("String_Node_Str" + url.toString() + "String_Node_Str");
  }
  Files.move(temp,destination);
  resource=createResource(destination.toUri().toURL());
  addResource(resource);
  generateRepositoryXml();
}

Fixed version (ground truth):
/** 
 * Upload an artifact from the given URL.
 * @param url the URL of the artifact.
 * @throws Exception in case of upload failure.
 */
public void upload(URL url) throws Exception {
  LOGGER.debug("String_Node_Str",url);
  String artifactName="String_Node_Str" + System.currentTimeMillis();
  Path temp=getLocationPath().resolve(artifactName);
  try (InputStream is=url.openStream()){
    Files.copy(is,temp);
  }
   ResourceImpl resource=createResource(temp.toUri().toURL());
  Path destination=getLocationPath().resolve(ResolverUtil.getSymbolicName(resource) + "String_Node_Str" + ResolverUtil.getVersion(resource)+ "String_Node_Str");
  if (Files.exists(destination)) {
    Files.delete(temp);
    LOGGER.warn("String_Node_Str",url);
    throw new IllegalArgumentException("String_Node_Str" + url.toString() + "String_Node_Str");
  }
  Files.move(temp,destination);
  resource=createResource(destination.toUri().toURL());
  addResources(Collections.<Resource>singletonList(resource));
}
Program: 51450
Project: 51450
Buggy source:
/** 
 * Recursive method to traverse all files in the repository.
 * @param entry the
 * @throws Exception
 */
private void scan(File entry) throws Exception {
  if (entry.isDirectory()) {
    File[] children=entry.listFiles();
    if (children != null) {
      for (      File child : children) {
        scan(child);
      }
    }
  }
 else {
    try {
      URL bundleUrl=entry.toURI().toURL();
      if (isPotentialBundle(bundleUrl.toString())) {
        ResourceImpl resource=createResource(bundleUrl);
        addResource(resource);
      }
    }
 catch (    BundleException e) {
      LOGGER.warn(e.getMessage());
    }
  }
}

Fixed version (ground truth):
/** 
 * Recursive method to traverse all files in the repository.
 * @param entry the
 * @throws Exception
 */
private void scan(File entry,List<Resource> resources) throws Exception {
  if (entry.isDirectory()) {
    File[] children=entry.listFiles();
    if (children != null) {
      for (      File child : children) {
        scan(child,resources);
      }
    }
  }
 else {
    try {
      URL bundleUrl=entry.toURI().toURL();
      if (isPotentialBundle(bundleUrl.toString())) {
        ResourceImpl resource=createResource(bundleUrl);
        resources.add(resource);
      }
    }
 catch (    BundleException e) {
      LOGGER.warn(e.getMessage());
    }
  }
}
Program: 51451
Project: 51451
Buggy source:
/** 
 * Proxy a HTTP URL locally.
 * @param url    the HTTP URL to proxy.
 * @param filter regex filter. Only artifacts URL matching the filter will be considered.
 * @throws Exception in case of proxy failure.
 */
private void proxyHttp(String url,String filter) throws Exception {
  LOGGER.debug("String_Node_Str",url);
  HttpURLConnection conn=(HttpURLConnection)new URL(url).openConnection();
  try (InputStream is=conn.getInputStream()){
    String type=conn.getContentType();
    if ("String_Node_Str".equals(type) || "String_Node_Str".equals(type)) {
      try {
        if ((filter == null) || (url.matches(filter))) {
          Resource resource=createResource(new URL(url));
          repository.addResource(resource);
          repository.setIncrement(System.currentTimeMillis());
        }
      }
 catch (      BundleException e) {
        LOGGER.warn(e.getMessage());
      }
    }
 else {
      try {
        Document document=Jsoup.connect(url).get();
        for (        Element link : document.select("String_Node_Str")) {
          String absoluteHref=link.attr("String_Node_Str");
          if (absoluteHref.startsWith(url)) {
            proxyHttp(absoluteHref,filter);
          }
        }
      }
 catch (      UnsupportedMimeTypeException e) {
      }
    }
  }
 }

Fixed version (ground truth):
/** 
 * Proxy a HTTP URL locally.
 * @param url    the HTTP URL to proxy.
 * @param filter regex filter. Only artifacts URL matching the filter will be considered.
 * @throws Exception in case of proxy failure.
 */
private void proxyHttp(String url,String filter,List<Resource> resources) throws Exception {
  LOGGER.debug("String_Node_Str",url);
  HttpURLConnection conn=(HttpURLConnection)new URL(url).openConnection();
  try (InputStream is=conn.getInputStream()){
    String type=conn.getContentType();
    if ("String_Node_Str".equals(type) || "String_Node_Str".equals(type)) {
      try {
        if ((filter == null) || (url.matches(filter))) {
          Resource resource=createResource(new URL(url));
          resources.add(resource);
        }
      }
 catch (      BundleException e) {
        LOGGER.warn(e.getMessage());
      }
    }
 else {
      try {
        Document document=Jsoup.connect(url).get();
        for (        Element link : document.select("String_Node_Str")) {
          String absoluteHref=link.attr("String_Node_Str");
          if (absoluteHref.startsWith(url)) {
            proxyHttp(absoluteHref,filter,resources);
          }
        }
      }
 catch (      UnsupportedMimeTypeException e) {
      }
    }
  }
 }
Program: 51452
Project: 51452
Buggy source:
/** 
 * Convert the Resource absolute URI to an URI relative to the repository one.
 * @param resource the Resource to manipulate.
 * @throws Exception in cave of URI conversion failure.
 */
private void useResourceRelativeUri(ResourceImpl resource) throws Exception {
  for (  Capability cap : resource.getCapabilities(null)) {
    if (cap.getNamespace().equals(CONTENT_NAMESPACE)) {
      String resourceURI=cap.getAttributes().get(CAPABILITY_URL_ATTRIBUTE).toString();
      String locationURI="String_Node_Str" + getLocation();
      LOGGER.debug("String_Node_Str",resourceURI,locationURI);
      if (resourceURI.startsWith(locationURI)) {
        resourceURI=resourceURI.substring(locationURI.length() + 1);
        LOGGER.debug("String_Node_Str" + resourceURI);
        cap.getAttributes().put(CAPABILITY_URL_ATTRIBUTE,resourceURI);
      }
      break;
    }
  }
}

Fixed version (ground truth):
/** 
 * Convert the Resource absolute URI to an URI relative to the repository one.
 * @param resource the Resource to manipulate.
 */
private void useResourceRelativeUri(ResourceImpl resource){
  for (  Capability cap : resource.getCapabilities(null)) {
    if (cap.getNamespace().equals(CONTENT_NAMESPACE)) {
      String resourceURI=cap.getAttributes().get(CAPABILITY_URL_ATTRIBUTE).toString();
      String locationURI="String_Node_Str" + getLocation();
      LOGGER.debug("String_Node_Str",resourceURI,locationURI);
      if (resourceURI.startsWith(locationURI)) {
        resourceURI=resourceURI.substring(locationURI.length() + 1);
        LOGGER.debug("String_Node_Str" + resourceURI);
        cap.getAttributes().put(CAPABILITY_URL_ATTRIBUTE,resourceURI);
      }
      break;
    }
  }
}
Program: 51453
Project: 51453
Buggy source:
public CaveRepositoryImpl(String name,String location,boolean scan) throws Exception {
  super();
  this.name=name;
  this.location=location;
  createRepositoryDirectory();
  if (scan) {
    scan();
  }
 else   if (!Files.exists(getRepositoryXmlFile())) {
    generateRepositoryXml();
  }
}

Fixed version (ground truth):
public CaveRepositoryImpl(String name,String location,boolean scan) throws Exception {
  super();
  this.name=name;
  this.location=location;
  createRepositoryDirectory();
  if (scan) {
    scan();
  }
 else   if (!Files.exists(getRepositoryXmlFile())) {
    try (Writer writer=Files.newBufferedWriter(getRepositoryXmlFile(),StandardCharsets.UTF_8)){
      repository.writeRepository(writer);
    }
   }
}
Program: 51454
Project: 51454
Buggy source:
/** 
 * Populate the Cave repository using a filesystem directory.
 * @param filesystem the "source" directory.
 * @param filter     regex filter. Only artifacts URL matching the filter will be considered.
 * @param update     if true, the resources are added into the OBR metadata, false else.
 * @throws Exception in case of populate failure.
 */
private void populateFromFilesystem(File filesystem,String filter,boolean update) throws Exception {
  LOGGER.debug("String_Node_Str",filesystem.getAbsolutePath());
  if (filesystem.isDirectory()) {
    File[] children=filesystem.listFiles();
    if (children != null) {
      for (      File child : children) {
        populateFromFilesystem(child,filter,update);
      }
    }
  }
 else {
    try {
      if ((filter == null) || (filesystem.toURI().toURL().toString().matches(filter))) {
        ResourceImpl resource=createResource(filesystem.toURI().toURL());
        Path destination=getLocationPath().resolve(filesystem.getName());
        LOGGER.debug("String_Node_Str",filesystem.getAbsolutePath(),destination.toAbsolutePath().toString());
        Files.copy(filesystem.toPath(),destination);
        if (update) {
          resource=createResource(destination.toUri().toURL());
          LOGGER.debug("String_Node_Str",ResolverUtil.getSymbolicName(resource),ResolverUtil.getVersion(resource));
          addResource(resource);
        }
      }
    }
 catch (    BundleException e) {
      LOGGER.warn(e.getMessage());
    }
  }
}

Fixed version (ground truth):
/** 
 * Populate the Cave repository using a filesystem directory.
 * @param filesystem the "source" directory.
 * @param filter     regex filter. Only artifacts URL matching the filter will be considered.
 * @param update     if true, the resources are added into the OBR metadata, false else.
 * @throws Exception in case of populate failure.
 */
private void populateFromFilesystem(File filesystem,String filter,boolean update,List<Resource> resources) throws Exception {
  LOGGER.debug("String_Node_Str",filesystem.getAbsolutePath());
  if (filesystem.isDirectory()) {
    File[] children=filesystem.listFiles();
    if (children != null) {
      for (      File child : children) {
        populateFromFilesystem(child,filter,update,resources);
      }
    }
  }
 else {
    try {
      if ((filter == null) || (filesystem.toURI().toURL().toString().matches(filter))) {
        ResourceImpl resource=createResource(filesystem.toURI().toURL());
        Path destination=getLocationPath().resolve(filesystem.getName());
        LOGGER.debug("String_Node_Str",filesystem.getAbsolutePath(),destination.toAbsolutePath().toString());
        Files.copy(filesystem.toPath(),destination);
        if (update) {
          resource=createResource(destination.toUri().toURL());
          LOGGER.debug("String_Node_Str",ResolverUtil.getSymbolicName(resource),ResolverUtil.getVersion(resource));
          resources.add(resource);
        }
      }
    }
 catch (    BundleException e) {
      LOGGER.warn(e.getMessage());
    }
  }
}
Program: 51455
Project: 51455
Buggy source:
/** 
 * Get the File object of the OBR repository.xml file.
 * @return the File corresponding to the OBR repository.xml.
 * @throws Exception
 */
private Path getRepositoryXmlFile() throws Exception {
  return getLocationPath().resolve("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Get the File object of the OBR repository.xml file.
 * @return the File corresponding to the OBR repository.xml.
 * @throws Exception
 */
private Path getRepositoryXmlFile(){
  return getLocationPath().resolve("String_Node_Str");
}
Program: 51456
Project: 51456
Buggy source:
/** 
 * Proxy a local filesystem (folder).
 * @param entry  the filesystem to proxyFilesystem.
 * @param filter regex filter. Only the artifacts URL matching the filter will be considered.
 * @throws Exception in case of proxyFilesystem failure
 */
private void proxyFilesystem(File entry,String filter) throws Exception {
  LOGGER.debug("String_Node_Str",entry.getAbsolutePath());
  if (entry.isDirectory()) {
    File[] children=entry.listFiles();
    if (children != null) {
      for (      File child : children) {
        proxyFilesystem(child,filter);
      }
    }
  }
 else {
    try {
      if ((filter == null) || (entry.toURI().toURL().toString().matches(filter))) {
        Resource resource=createResource(entry.toURI().toURL());
        repository.addResource(resource);
        repository.setIncrement(System.currentTimeMillis());
      }
    }
 catch (    BundleException e) {
      LOGGER.warn(e.getMessage());
    }
  }
}

Fixed version (ground truth):
/** 
 * Proxy a local filesystem (folder).
 * @param entry  the filesystem to proxyFilesystem.
 * @param filter regex filter. Only the artifacts URL matching the filter will be considered.
 * @throws Exception in case of proxyFilesystem failure
 */
private void proxyFilesystem(File entry,String filter,List<Resource> resources) throws Exception {
  LOGGER.debug("String_Node_Str",entry.getAbsolutePath());
  if (entry.isDirectory()) {
    File[] children=entry.listFiles();
    if (children != null) {
      for (      File child : children) {
        proxyFilesystem(child,filter,resources);
      }
    }
  }
 else {
    try {
      if ((filter == null) || (entry.toURI().toURL().toString().matches(filter))) {
        Resource resource=createResource(entry.toURI().toURL());
        resources.add(resource);
      }
    }
 catch (    BundleException e) {
      LOGGER.warn(e.getMessage());
    }
  }
}
Program: 51458
Project: 51458
Buggy source:
public UserDetails loadUserByUsername(final String userName) throws UsernameNotFoundException, DataAccessException {
  return new DummyUserDetails(userName);
}

Fixed version (ground truth):
public UserDetails loadUserByUsername(final String userName) throws UsernameNotFoundException {
  return new DummyUserDetails(userName);
}
Program: 51459
Project: 51459
Buggy source:
public synchronized TableModel put(final DataCacheKey key,final TableModel model){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str");
  }
  final IPentahoSession session=PentahoSessionHolder.getSession();
  if (cacheManager != null) {
    if (model.getRowCount() > maximumRows) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + model.getRowCount() + "String_Node_Str"+ maximumRows+ "String_Node_Str");
      }
      return model;
    }
    if (CachableTableModel.isSafeToCache(model) == false) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str");
      }
      return model;
    }
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + session.getId() + "String_Node_Str"+ model.getColumnCount()+ "String_Node_Str");
    }
    final TableModel cacheModel=new CachableTableModel(model);
    cacheManager.putInRegionCache(CACHE_NAME,new CompositeKey(session.getId(),key),cacheModel);
  }
  return model;
}

Fixed version (ground truth):
public synchronized TableModel put(final DataCacheKey key,final TableModel model){
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str");
  }
  final IPentahoSession session=PentahoSessionHolder.getSession();
  if (cacheManager != null) {
    if (model.getRowCount() > maximumRows) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str" + model.getRowCount() + "String_Node_Str"+ maximumRows+ "String_Node_Str");
      }
      return model;
    }
    if (CachableTableModel.isSafeToCache(model) == false) {
      if (log.isDebugEnabled()) {
        log.debug("String_Node_Str");
      }
      return model;
    }
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + session.getId() + "String_Node_Str"+ model.getColumnCount()+ "String_Node_Str");
    }
    final TableModel cacheModel=new CachableTableModel(model);
    cacheManager.putInRegionCache(CACHE_NAME,new CompositeKey(session.getId(),key),cacheModel);
    return cacheModel;
  }
  return model;
}
Program: 51461
Project: 51461
Buggy source:
protected FastHtmlContentItems computeContentItems(final OutputStream outputStream) throws ReportProcessingException, ContentIOException {
  IUnifiedRepository repo=PentahoSystem.get(IUnifiedRepository.class);
  final RepositoryFile outputFolder=repo.getFile(jcrOutputPath);
  final ReportContentRepository repository=new ReportContentRepository(outputFolder);
  final ContentLocation dataLocation=repository.getRoot();
  final PentahoNameGenerator dataNameGenerator=createPentahoNameGenerator();
  dataNameGenerator.initialize(dataLocation,isSafeToDelete());
  final StreamRepository targetRepository=new StreamRepository(null,outputStream,"String_Node_Str");
  final ContentLocation targetRoot=targetRepository.getRoot();
  FastHtmlContentItems contentItems=new FastHtmlContentItems();
  contentItems.setContentWriter(targetRoot,new DefaultNameGenerator(targetRoot,"String_Node_Str","String_Node_Str"));
  contentItems.setDataWriter(dataLocation,dataNameGenerator);
  contentItems.setUrlRewriter(new PentahoURLRewriter(getContentHandlerPattern(),true));
  return super.computeContentItems(outputStream);
}

Fixed version (ground truth):
protected FastHtmlContentItems computeContentItems(final OutputStream outputStream) throws ReportProcessingException, ContentIOException {
  IUnifiedRepository repo=PentahoSystem.get(IUnifiedRepository.class);
  final RepositoryFile outputFolder=repo.getFile(jcrOutputPath);
  final ReportContentRepository repository=new ReportContentRepository(outputFolder);
  final ContentLocation dataLocation=repository.getRoot();
  final PentahoNameGenerator dataNameGenerator=createPentahoNameGenerator();
  dataNameGenerator.initialize(dataLocation,isSafeToDelete());
  final StreamRepository targetRepository=new StreamRepository(null,outputStream,"String_Node_Str");
  final ContentLocation targetRoot=targetRepository.getRoot();
  FastHtmlContentItems contentItems=new FastHtmlContentItems();
  contentItems.setContentWriter(targetRoot,new DefaultNameGenerator(targetRoot,"String_Node_Str","String_Node_Str"));
  contentItems.setDataWriter(dataLocation,dataNameGenerator);
  contentItems.setUrlRewriter(new PentahoURLRewriter(getContentHandlerPattern(),true));
  return contentItems;
}