nus-yam/ex-repair huggingface dataset:
Program: 44820
Project: 44820
Buggy source:
@Test public void testCreateBlob1() throws Exception {
  expect(mockStore.openHDFSConnection()).andReturn(mockFs);
  expect(mockStore.getId()).andReturn(new URI("String_Node_Str")).times(2);
  expect(mockFs.exists((Path)anyObject())).andReturn(false);
  expect(mockFs.create((Path)anyObject())).andReturn(new FSDataOutputStream(new ByteArrayOutputStream(20),null));
  expect(mockFs.exists((Path)anyObject())).andReturn(true);
  replay(mockStore,mockFs);
  HDFSBlobStoreConnection connection=createTestConnection();
  byte[] buf=new byte[4096];
  new Random().nextBytes(buf);
  HDFSBlob b=(HDFSBlob)connection.getBlob(new ByteArrayInputStream(buf),4096,null);
  assertNotNull(b);
  assertTrue(b.getConnection() == connection);
  assertTrue(b.exists());
}

Fixed version (ground truth):
@Test public void testCreateBlob1() throws Exception {
  expect(mockStore.getFilesystem()).andReturn(mockFs);
  expect(mockStore.getId()).andReturn(mockId).times(3);
  expect(mockFs.exists((Path)anyObject())).andReturn(false);
  expect(mockFs.create((Path)anyObject())).andReturn(new FSDataOutputStream(new ByteArrayOutputStream(20),null));
  expect(mockFs.exists((Path)anyObject())).andReturn(true);
  replay(mockStore,mockFs);
  HDFSBlobStoreConnection connection=createTestConnection();
  byte[] buf=new byte[4096];
  new Random().nextBytes(buf);
  HDFSBlob b=(HDFSBlob)connection.getBlob(new ByteArrayInputStream(buf),4096,null);
  assertNotNull(b);
  assertTrue(b.getConnection() == connection);
  assertTrue(b.exists());
}
Program: 44821
Project: 44821
Buggy source:
/** 
 * removes an item from a given inventory. It also takes into account the amount of the item and removes only that much, even if there is less than the amount in two different stacks.
 * @param inventory-the inventory to remove it from
 * @param item-the itemstack to remove from the inventory
 * @return the last index the item was removed from
 */
public int removeFromInventory(PlayerInventory inventory,ItemStack item){
  int amountLeft=item.getAmount();
  if (inventory.contains(item.getType(),item.getAmount())) {
    while (amountLeft > 0) {
      int firstFound=inventory.first(item.getType());
      if (inventory.getItem(firstFound).getAmount() >= amountLeft) {
        inventory.getItem(firstFound).setAmount(inventory.getItem(firstFound).getAmount() - amountLeft);
        return firstFound;
      }
 else {
        amountLeft-=inventory.getItem(inventory.first(item.getType())).getAmount();
        inventory.clear(inventory.first(item.getType()));
      }
    }
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * removes an item from a given inventory. It also takes into account the amount of the item and removes only that much, even if there is less than the amount in two different stacks.
 * @param inventory-the inventory to remove it from
 * @param item-the itemstack to remove from the inventory
 * @return the last index the item was removed from
 */
public int removeFromInventory(PlayerInventory inventory,ItemStack item){
  int amountLeft=item.getAmount();
  if (inventory.contains(item.getType(),item.getAmount())) {
    while (amountLeft > 0) {
      int firstFound=inventory.first(item.getType());
      if (inventory.getItem(firstFound).getAmount() > amountLeft) {
        inventory.getItem(firstFound).setAmount(inventory.getItem(firstFound).getAmount() - amountLeft);
        return firstFound;
      }
 else {
        amountLeft-=inventory.getItem(inventory.first(item.getType())).getAmount();
        inventory.clear(inventory.first(item.getType()));
      }
    }
  }
  return -1;
}
Program: 44822
Project: 44822
Buggy source:
/** 
 * removes all of the spell's required items from the given inventory
 * @param inventory-the inventory to remove the items from
 * @return false-if the player did not have the neccesary items
 * @return true-if the items were removed from the player's inventory
 */
public boolean removeRequiredItemsFromInventory(PlayerInventory inventory){
  if (checkInventoryRequirements(inventory)) {
    for (int i=0; i < requiredItems.size(); i++) {
      removeFromInventory(inventory,requiredItems.get(i));
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * removes all of the spell's required items from the given inventory
 * @param inventory-the inventory to remove the items from
 * @return false-if the player did not have the neccesary items
 * @return true-if the items were removed from the player's inventory
 */
public boolean removeRequiredItemsFromInventory(PlayerInventory inventory){
  if (checkInventoryRequirements(inventory)) {
    for (int i=0; i <= requiredItems.size() - 1; i++) {
      removeFromInventory(inventory,requiredItems.get(i));
    }
    return true;
  }
  return false;
}
Program: 44824
Project: 44824
Buggy source:
public void castSpell(Player player){
  Random gen=new Random();
  globalPlayer=player;
  PlayerInventory inventory=player.getInventory();
  if (removeRequiredItemsFromInventory(inventory)) {
    List<Entity> nearbyEntities;
    nearbyEntities=player.getNearbyEntities(5,5,5);
    for (int i=0; i < nearbyEntities.size(); i++) {
      Vector newVelocity=new Vector(((gen.nextFloat() - .3) * .8),gen.nextFloat(),(gen.nextFloat() - .3) * .8);
      nearbyEntities.get(i).setVelocity(newVelocity);
    }
    for (int i=10; i < 16; i=i + 2) {
      delayedRun(i,0);
    }
  }
 else {
    player.sendMessage("String_Node_Str");
  }
}

Fixed version (ground truth):
public void castSpell(Player player){
  Random gen=new Random();
  globalPlayer=player;
  PlayerInventory inventory=player.getInventory();
  if (removeRequiredItemsFromInventory(inventory)) {
    List<Entity> nearbyEntities;
    nearbyEntities=player.getNearbyEntities(5,5,5);
    for (int i=0; i < nearbyEntities.size(); i++) {
      Vector newVelocity=new Vector(((gen.nextFloat() - .3) * .8),gen.nextFloat() * 20,(gen.nextFloat() - .3) * .8);
      nearbyEntities.get(i).setVelocity(newVelocity);
    }
    for (int i=200; i < 16; i=i + 4) {
      delayedRun(i,0);
    }
  }
 else {
    player.sendMessage("String_Node_Str");
  }
}
Program: 44825
Project: 44825
Buggy source:
public void run(Object... argument){
  Player player=globalPlayer;
  Random gen=new Random();
  List<Entity> nearbyEntities;
  nearbyEntities=player.getNearbyEntities(5,5,5);
  for (int i=0; i < nearbyEntities.size(); i++) {
    Vector newVelocity=new Vector(((gen.nextFloat() - .5) * .8),gen.nextFloat(),(gen.nextFloat() - .5) * .8);
    nearbyEntities.get(i).setVelocity(newVelocity);
  }
}

Fixed version (ground truth):
public void run(Object... argument){
  Player player=globalPlayer;
  Random gen=new Random();
  List<Entity> nearbyEntities;
  nearbyEntities=player.getNearbyEntities(5,5,5);
  for (int i=0; i < nearbyEntities.size(); i++) {
    Vector newVelocity=new Vector(((gen.nextFloat() - .5) * .8),gen.nextFloat() * 5,(gen.nextFloat() - .5) * .8);
    nearbyEntities.get(i).setVelocity(newVelocity);
  }
}
Program: 44826
Project: 44826
Buggy source:
public SpellBook(Player player,SimplePlugin instance){
  plugin=instance;
  registerSpell(new RapidfireSpell(plugin));
  registerSpell(new ExplosionSpell(plugin));
  registerSpell(new SpikeSpell(plugin));
  registerSpell(new Tornado(plugin));
  registerSpell(new SpikeWallSpell(plugin));
  registerSpell(new SpikeFortSpell(plugin));
}

Fixed version (ground truth):
public SpellBook(Player player,SimplePlugin instance){
  plugin=instance;
  registerSpell(new RapidfireSpell(plugin));
  registerSpell(new ExplosionSpell(plugin));
  registerSpell(new SpikeSpell(plugin));
  registerSpell(new Tornado(plugin));
  registerSpell(new SpikeWallSpell(plugin));
  registerSpell(new SpikeFortSpell(plugin));
  registerSpell(new DecoySpell(plugin));
}
Program: 44827
Project: 44827
Buggy source:
public void castSpell(Player player){
  PlayerInventory inventory=player.getInventory();
  if (checkInventoryRequirements(inventory)) {
    Block targetBlock=player.getTargetBlock(null,MAXDISTANCE);
    if (targetBlock.getType() != Material.AIR) {
      LivingEntity cow=player.getWorld().spawnCreature(targetBlock.getLocation(),CreatureType.COW);
      List<Entity> nearCow=cow.getNearbyEntities(10,10,10);
      for (int i=0; i < nearCow.size(); i++) {
        Creature currentCreature=(Creature)nearCow.get(i);
        currentCreature.setTarget(cow);
      }
    }
  }
 else {
    player.sendMessage("String_Node_Str");
  }
}

Fixed version (ground truth):
public void castSpell(Player player){
  PlayerInventory inventory=player.getInventory();
  if (checkInventoryRequirements(inventory)) {
    Block targetBlock=player.getTargetBlock(null,MAXDISTANCE);
    if (targetBlock.getType() != Material.AIR) {
      LivingEntity cow=player.getWorld().spawnCreature(targetBlock.getLocation(),CreatureType.COW);
      List<Entity> nearCow=cow.getNearbyEntities(10,10,10);
      for (int i=0; i < nearCow.size(); i++) {
        Entity currentCreature=nearCow.get(i);
        try {
          if (currentCreature.getClass() != CraftPlayer.class && currentCreature.getClass() != CraftItem.class) {
            ((Creature)currentCreature).setTarget(cow);
          }
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
    }
  }
 else {
    player.sendMessage("String_Node_Str");
  }
}
Program: 44828
Project: 44828
Buggy source:
/** 
 * removes an item from a given inventory. It also takes into account the amount of the item and removes only that much, even if there is less than the amount in two different stacks.
 * @param inventory-the inventory to remove it from
 * @param item-the itemstack to remove from the inventory
 * @return the last index the item was removed from
 */
public int removeFromInventory(PlayerInventory inventory,ItemStack item){
  int amountLeft=item.getAmount();
  if (inventory.contains(item.getType(),item.getAmount())) {
    while (amountLeft > 0) {
      int firstFound=inventory.first(item.getType());
      if (inventory.getItem(firstFound).getAmount() >= amountLeft) {
        inventory.getItem(firstFound).setAmount(inventory.getItem(firstFound).getAmount() - amountLeft);
        amountLeft=0;
        return firstFound;
      }
 else {
        amountLeft-=inventory.getItem(inventory.first(item.getType())).getAmount();
        inventory.clear(inventory.first(item.getType()));
      }
    }
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * removes an item from a given inventory. It also takes into account the amount of the item and removes only that much, even if there is less than the amount in two different stacks.
 * @param inventory-the inventory to remove it from
 * @param item-the itemstack to remove from the inventory
 * @return the last index the item was removed from
 */
public int removeFromInventory(PlayerInventory inventory,ItemStack item){
  int amountLeft=item.getAmount();
  if (inventory.contains(item.getType(),item.getAmount())) {
    while (amountLeft > 0) {
      int firstFound=inventory.first(item.getType());
      if (inventory.getItem(firstFound).getAmount() > amountLeft) {
        inventory.getItem(firstFound).setAmount(inventory.getItem(firstFound).getAmount() - amountLeft);
        return firstFound;
      }
 else       if (inventory.getItem(firstFound).getAmount()=amountLeft) {
        inventory.clear(inventory.first(item.getType()));
        return firstFound;
      }
 else {
        amountLeft-=inventory.getItem(inventory.first(item.getType())).getAmount();
        inventory.clear(inventory.first(item.getType()));
      }
    }
  }
  return -1;
}
Program: 44829
Project: 44829
Buggy source:
/** 
 * removes an item from a given inventory. It also takes into account the amount of the item and removes only that much, even if there is less than the amount in two different stacks.
 * @param inventory-the inventory to remove it from
 * @param item-the itemstack to remove from the inventory
 * @return the last index the item was removed from
 */
public int removeFromInventory(PlayerInventory inventory,ItemStack item){
  int amountLeft=item.getAmount();
  if (inventory.contains(item.getType(),item.getAmount())) {
    while (amountLeft > 0) {
      int firstFound=inventory.first(item.getType());
      if (inventory.getItem(firstFound).getAmount() > amountLeft) {
        inventory.getItem(firstFound).setAmount(inventory.getItem(firstFound).getAmount() - amountLeft);
        return firstFound;
      }
 else       if (inventory.getItem(firstFound).getAmount()=amountLeft) {
        inventory.clear(inventory.first(item.getType()));
        return firstFound;
      }
 else {
        amountLeft-=inventory.getItem(inventory.first(item.getType())).getAmount();
        inventory.clear(inventory.first(item.getType()));
      }
    }
  }
  return -1;
}

Fixed version (ground truth):
/** 
 * removes an item from a given inventory. It also takes into account the amount of the item and removes only that much, even if there is less than the amount in two different stacks.
 * @param inventory-the inventory to remove it from
 * @param item-the itemstack to remove from the inventory
 * @return the last index the item was removed from
 */
public int removeFromInventory(PlayerInventory inventory,ItemStack item){
  int amountLeft=item.getAmount();
  if (inventory.contains(item.getType(),item.getAmount())) {
    while (amountLeft > 0) {
      int firstFound=inventory.first(item.getType());
      if (inventory.getItem(firstFound).getAmount() > amountLeft) {
        inventory.getItem(firstFound).setAmount(inventory.getItem(firstFound).getAmount() - amountLeft);
        return firstFound;
      }
 else       if (inventory.getItem(firstFound).getAmount() == amountLeft) {
        inventory.clear(inventory.first(item.getType()));
        return firstFound;
      }
 else {
        amountLeft-=inventory.getItem(inventory.first(item.getType())).getAmount();
        inventory.clear(inventory.first(item.getType()));
      }
    }
  }
  return -1;
}
Program: 44830
Project: 44830
Buggy source:
public void castSpell(Player player){
  PlayerInventory inventory=player.getInventory();
  if (checkInventoryRequirements(inventory)) {
    removeRequiredItemsFromInventory(inventory);
    addItem(newItemStack(Material.BUCKET,1));
    List<Entity> nearbyEntities;
    nearbyEntities=getNearbyEntities(5,5,5);
    for (int i=0; i < nearbyEntities.length; i++) {
      Vector newVelocity=new Vector((randomGen.nextFloat() * 1.5 - 0.75),randomGen.nextFloat() / 2.5,randomGen.nextFloat() * 1.5 - 0.75);
      nearbyEntities.get(i).setVelocity(newVelocity);
    }
  }
 else {
    player.sendMessage("String_Node_Str");
  }
}

Fixed version (ground truth):
public void castSpell(Player player){
  Random gen=new Random();
  PlayerInventory inventory=player.getInventory();
  if (checkInventoryRequirements(inventory)) {
    removeRequiredItemsFromInventory(inventory);
    player.getInventory().addItem(new ItemStack(Material.BUCKET,1));
    List<Entity> nearbyEntities;
    nearbyEntities=player.getNearbyEntities(5,5,5);
    for (int i=0; i < nearbyEntities.size(); i++) {
      Vector newVelocity=new Vector((gen.nextFloat() * 1.5 - 0.75),gen.nextFloat() / 2.5,gen.nextFloat() * 1.5 - 0.75);
      nearbyEntities.get(i).setVelocity(newVelocity);
    }
  }
 else {
    player.sendMessage("String_Node_Str");
  }
}
Program: 44831
Project: 44831
Buggy source:
public void createExplosion(Block targetBlock,int size){
  ((CraftWorld)targetBlock.getWorld()).getHandle().createExplosion(null,targetBlock.getLocation().getX(),targetBlock.getLocation().getY(),targetBlock.getLocation().getZ(),size,false);
}

Fixed version (ground truth):
public void createExplosion(Block targetBlock,int size){
}
Program: 44832
Project: 44832
Buggy source:
public void onPlayerJoin(PlayerJoinEvent event){
  Player player=event.getPlayer();
  SimplePlugin.playerBooks.put(player.getName(),new SpellBook(player));
}

Fixed version (ground truth):
public void onPlayerJoin(PlayerJoinEvent event){
  Player player=event.getPlayer();
  SimplePlugin.playerBooks.put(player.getName(),new SpellBook(player,plugin));
}
Program: 44833
Project: 44833
Buggy source:
public void onEnable(){
  log.info("String_Node_Str");
  PluginManager pm=this.getServer().getPluginManager();
  ItemStack hoe=new ItemStack(Material.GOLD_HOE,1);
  ShapedRecipe sceptre=new ShapedRecipe(hoe);
  sceptre.shape("String_Node_Str","String_Node_Str","String_Node_Str");
  sceptre.setIngredient('1',Material.STICK);
  sceptre.setIngredient('2',Material.GOLD_BLOCK);
  sceptre.setIngredient('3',Material.STICK);
  sceptre.setIngredient('5',Material.STICK);
  sceptre.setIngredient('8',Material.STICK);
  this.getServer().addRecipe(sceptre);
  pm.registerEvent(Event.Type.PLAYER_QUIT,playerListener,Event.Priority.Normal,this);
  pm.registerEvent(Event.Type.PLAYER_JOIN,playerListener,Event.Priority.Normal,this);
  pm.registerEvent(Event.Type.PLAYER_INTERACT,playerListener,Event.Priority.Normal,this);
  Player[] onlinePlayers=this.getServer().getOnlinePlayers();
  for (int i=0; i < onlinePlayers.length; i++) {
    SimplePlugin.playerBooks.put(onlinePlayers[i].getName(),new SpellBook(onlinePlayers[i]));
  }
  log.info("String_Node_Str");
}

Fixed version (ground truth):
public void onEnable(){
  log.info("String_Node_Str");
  PluginManager pm=this.getServer().getPluginManager();
  ItemStack hoe=new ItemStack(Material.GOLD_HOE,1);
  ShapedRecipe sceptre=new ShapedRecipe(hoe);
  sceptre.shape("String_Node_Str","String_Node_Str","String_Node_Str");
  sceptre.setIngredient('1',Material.STICK);
  sceptre.setIngredient('2',Material.GOLD_BLOCK);
  sceptre.setIngredient('3',Material.STICK);
  sceptre.setIngredient('5',Material.STICK);
  sceptre.setIngredient('8',Material.STICK);
  this.getServer().addRecipe(sceptre);
  pm.registerEvent(Event.Type.PLAYER_QUIT,playerListener,Event.Priority.Normal,this);
  pm.registerEvent(Event.Type.PLAYER_JOIN,playerListener,Event.Priority.Normal,this);
  pm.registerEvent(Event.Type.PLAYER_INTERACT,playerListener,Event.Priority.Normal,this);
  Player[] onlinePlayers=this.getServer().getOnlinePlayers();
  for (int i=0; i < onlinePlayers.length; i++) {
    SimplePlugin.playerBooks.put(onlinePlayers[i].getName(),new SpellBook(onlinePlayers[i],this));
  }
  log.info("String_Node_Str");
}
Program: 44834
Project: 44834
Buggy source:
public SpellBook(Player player){
  registerSpell(new BedrockLightningSpell());
  registerSpell(new RapidfireArrowSpell());
  registerSpell(new ExplosionSpell());
}

Fixed version (ground truth):
public SpellBook(Player player,SimplePlugin instance){
  plugin=instance;
  registerSpell(new BedrockLightningSpell(plugin));
  registerSpell(new RapidfireArrowSpell(plugin));
  registerSpell(new ExplosionSpell(plugin));
}
Program: 44835
Project: 44835
Buggy source:
public BedrockLightningSpell(){
  spellName="String_Node_Str";
  spellDescription="String_Node_Str";
}

Fixed version (ground truth):
public BedrockLightningSpell(SimplePlugin instance){
  plugin=instance;
  spellName="String_Node_Str";
  spellDescription="String_Node_Str";
}
Program: 44836
Project: 44836
Buggy source:
public ExplosionSpell(){
  spellName="String_Node_Str";
  spellDescription="String_Node_Str";
}

Fixed version (ground truth):
public ExplosionSpell(SimplePlugin instance){
  plugin=instance;
  spellName="String_Node_Str";
  spellDescription="String_Node_Str";
}
Program: 44837
Project: 44837
Buggy source:
public void castSpell(Player player){
  PlayerInventory inventory=player.getInventory();
  ItemStack[] requiredItems=new ItemStack[2];
  requiredItems[0]=new ItemStack(Material.ARROW,8);
  requiredItems[1]=new ItemStack(Material.REDSTONE,4);
  if (checkInventoryRequirements(inventory,requiredItems)) {
    removeRequiredItemsFromInventory(inventory,requiredItems);
    player.shootArrow();
    for (int i=0; i < 7; i++) {
      try {
        Thread.sleep(150);
      }
 catch (      InterruptedException ae) {
        System.out.println(ae);
      }
      player.shootArrow();
    }
    player.sendMessage("String_Node_Str");
  }
 else {
    player.sendMessage("String_Node_Str");
  }
}

Fixed version (ground truth):
public void castSpell(Player player){
  PlayerInventory inventory=player.getInventory();
  ItemStack[] requiredItems=new ItemStack[2];
  requiredItems[0]=new ItemStack(Material.ARROW,8);
  requiredItems[1]=new ItemStack(Material.REDSTONE,4);
  if (checkInventoryRequirements(inventory,requiredItems)) {
    removeFromInventory(inventory,requiredItems[1]);
    player.shootArrow();
    removeFromInventory(inventory,new ItemStack(Material.ARROW,1));
    for (int i=2; i < 15; i=i + 2) {
      player.getServer().getScheduler().scheduleSyncDelayedTask(plugin,new RunnableShootArrow(player),i);
    }
    player.sendMessage("String_Node_Str");
  }
 else {
    player.sendMessage("String_Node_Str");
  }
}
Program: 44838
Project: 44838
Buggy source:
public RapidfireArrowSpell(){
  spellName="String_Node_Str";
  spellDescription="String_Node_Str";
}

Fixed version (ground truth):
public RapidfireArrowSpell(SimplePlugin instance){
  plugin=instance;
  spellName="String_Node_Str";
  spellDescription="String_Node_Str";
}
Program: 44839
Project: 44839
Buggy source:
public void onPlayerInteract(PlayerInteractEvent event){
  if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
    Player player=event.getPlayer();
    Block block=event.getClickedBlock();
    ItemStack itemInHand=player.getItemInHand();
    if (itemInHand.getType() == Material.GOLD_HOE) {
      block.setType(Material.BEDROCK);
    }
  }
}

Fixed version (ground truth):
public void onPlayerInteract(PlayerInteractEvent event){
  if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
    Player player=event.getPlayer();
    Block block=event.getClickedBlock();
    ItemStack itemInHand=player.getItemInHand();
    if (itemInHand.getType() == Material.GOLD_HOE) {
      block.setType(Material.BEDROCK);
    }
  }
}
Program: 44841
Project: 44841
Buggy source:
private static Downloader<MsDState> getBaseDownloader(final File file,final URI expectedSha1) throws URISyntaxException {
  final String[] urls={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  final Collection<URI> uris=new LinkedList<URI>();
  for (int i=0; i < urls.length; i++) {
    try {
      uris.add(new URI(urls[i]));
    }
 catch (    final URISyntaxException e) {
    }
  }
  final URI uri=new URI("String_Node_Str");
  final long size=3534076L;
  if (file.exists()) {
    assertTrue(file.delete());
  }
  assertFalse(file.isFile());
  file.deleteOnExit();
  final UriResolver resolver=new UriResolver(){
    public Collection<URI> resolve(    final URI uri) throws IOException {
      return uris;
    }
    public URI getSha1(){
      return null;
    }
  }
;
  final File downloadDir=new File("String_Node_Str");
  downloadDir.mkdir();
  downloadDir.deleteOnExit();
  final Downloader<MsDState> downloader=new MultiSourceDownloader("String_Node_Str",file,uri,size,"String_Node_Str",resolver,2,expectedSha1,downloadDir);
  return downloader;
}

Fixed version (ground truth):
private static Downloader<MsDState> getBaseDownloader(final File file,final URI expectedSha1) throws URISyntaxException {
  final String[] urls={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
  final Collection<URI> uris=new LinkedList<URI>();
  for (int i=0; i < urls.length; i++) {
    try {
      uris.add(new URI(urls[i]));
    }
 catch (    final URISyntaxException e) {
    }
  }
  final URI uri=new URI("String_Node_Str");
  final long size=3534076L;
  if (file.exists()) {
    assertTrue(file.delete());
  }
  assertFalse(file.isFile());
  file.deleteOnExit();
  final UriResolver resolver=new UriResolver(){
    public Collection<URI> resolve(    final URI uri) throws IOException {
      return uris;
    }
    public URI getSha1(){
      return null;
    }
  }
;
  final File downloadDir=new File("String_Node_Str");
  downloadDir.mkdir();
  downloadDir.deleteOnExit();
  final Downloader<MsDState> downloader=new MultiSourceDownloader(file,uri,size,"String_Node_Str",resolver,2,expectedSha1,downloadDir);
  return downloader;
}
Program: 44842
Project: 44842
Buggy source:
@Test public void testLauncher() throws Exception {
  final File file=new File(getClass().getSimpleName());
  file.deleteOnExit();
  final OutputStream os=new FileOutputStream(file);
  for (int i=0; i < 100000; i++) {
    os.write(i);
  }
  os.close();
  final RandomAccessFile raf=new RandomAccessFile(file,"String_Node_Str");
  final PriorityBlockingQueue<LongRange> completedRanges=createQueue();
  final URI sha1=Sha1Hasher.createSha1Urn(file);
  final DownloadingFileLauncher launcher=new DownloadingFileLauncher(raf,completedRanges,sha1);
  final File fileCopy=new File(file.getName() + "String_Node_Str");
  fileCopy.deleteOnExit();
  final OutputStream stream=new FileOutputStream(fileCopy);
  final Runnable runner=new Runnable(){
    public void run(){
      try {
        Thread.sleep(400);
      }
 catch (      final InterruptedException e) {
        e.printStackTrace();
      }
      final Collection<LongRange> ranges=createRanges(file.length());
      m_log.debug("String_Node_Str" + ranges);
      for (      final LongRange lr : ranges) {
        launcher.onRangeComplete(lr);
      }
      launcher.onFileComplete();
    }
  }
;
  final Thread thread=new Thread(runner,"String_Node_Str");
  thread.setDaemon(true);
  thread.start();
  launcher.write(stream,true);
  final URI sha1Copy=Sha1Hasher.createSha1Urn(fileCopy);
  assertEquals(sha1,sha1Copy);
  m_log.debug("String_Node_Str" + sha1Copy);
}

Fixed version (ground truth):
@Test public void testLauncher() throws Exception {
  final File file=new File(getClass().getSimpleName());
  file.deleteOnExit();
  final OutputStream os=new FileOutputStream(file);
  for (int i=0; i < 100000; i++) {
    os.write(i);
  }
  os.close();
  final RandomAccessFile raf=new RandomAccessFile(file,"String_Node_Str");
  final PriorityBlockingQueue<LongRange> completedRanges=createQueue();
  final URI sha1=Sha1Hasher.createSha1Urn(file);
  final DownloadingFileLauncher launcher=new DownloadingFileLauncher(raf,completedRanges,sha1,file);
  final File fileCopy=new File(file.getName() + "String_Node_Str");
  fileCopy.deleteOnExit();
  final OutputStream stream=new FileOutputStream(fileCopy);
  final Runnable runner=new Runnable(){
    public void run(){
      try {
        Thread.sleep(400);
      }
 catch (      final InterruptedException e) {
        e.printStackTrace();
      }
      final Collection<LongRange> ranges=createRanges(file.length());
      m_log.debug("String_Node_Str" + ranges);
      for (      final LongRange lr : ranges) {
        launcher.onRangeComplete(lr);
      }
      launcher.onFileComplete();
    }
  }
;
  final Thread thread=new Thread(runner,"String_Node_Str");
  thread.setDaemon(true);
  thread.start();
  launcher.write(stream,true);
  final URI sha1Copy=Sha1Hasher.createSha1Urn(fileCopy);
  assertEquals(sha1,sha1Copy);
  m_log.debug("String_Node_Str" + sha1Copy);
}
Program: 44844
Project: 44844
Buggy source:
public int compare(final RangeDownloader dl0,final RangeDownloader dl1){
  if (dl0.getKbs() > dl1.getKbs()) {
    return -1;
  }
  if (dl0.getKbs() < dl1.getKbs()) {
    return 1;
  }
  return 0;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public int compare(final RangeDownloader dl0,final RangeDownloader dl1){
  final int kbs0=canonicalize(dl0.getKbs());
  final int kbs1=canonicalize(dl1.getKbs());
  if (kbs0 < kbs1) {
    return 1;
  }
 else   if (kbs1 < kbs0) {
    return -1;
  }
 else {
    return 0;
  }
}
Program: 44845
Project: 44845
Buggy source:
/** 
 * Gets the speed of this downloader in kilobytes per second.
 * @return The speed of this downloader in kilobytes per second.
 */
int getKbs();

Fixed version (ground truth):
/** 
 * Gets the speed of this downloader in kilobytes per second.
 * @return The speed of this downloader in kilobytes per second.
 */
Optional<Integer> getKbs();
Program: 44846
Project: 44846
Buggy source:
public void onMessageBodyRead(){
  LOG.debug("String_Node_Str");
  this.m_completedTime=System.currentTimeMillis();
  this.m_launchFileTracker.onRangeComplete(this.m_assignedRange);
  this.m_rangeTracker.onRangeComplete(this.m_assignedRange);
  this.m_completedRanges++;
  this.m_sourceRanker.onAvailable(this);
}

Fixed version (ground truth):
public void onMessageBodyRead(){
  LOG.debug("String_Node_Str");
  this.m_completedTime=System.currentTimeMillis();
  LOG.debug("String_Node_Str" + m_completedTime);
  this.m_launchFileTracker.onRangeComplete(this.m_assignedRange);
  this.m_rangeTracker.onRangeComplete(this.m_assignedRange);
  this.m_completedRanges++;
  this.m_sourceRanker.onAvailable(this);
}
Program: 44847
Project: 44847
Buggy source:
public int getKbs(){
  if (this.m_contentLength == -1 || this.m_connectedTime == -1 || this.m_completedTime == -1) {
    LOG.debug("String_Node_Str" + "String_Node_Str" + this.m_contentLength + "String_Node_Str"+ this.m_connectedTime+ "String_Node_Str"+ "String_Node_Str"+ this.m_completedTime);
    return -1;
  }
  if (this.m_completedTime == this.m_connectedTime) {
    LOG.error("String_Node_Str" + this.m_completedTime);
  }
  final long downloadMs=this.m_completedTime - this.m_connectedTime;
  return (int)(this.m_contentLength * 1000 / downloadMs * 1024);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
public Optional<Integer> getKbs(){
  if (this.m_contentLength == -1 || this.m_connectedTime == -1 || this.m_completedTime == -1) {
    LOG.debug("String_Node_Str" + "String_Node_Str" + this.m_contentLength + "String_Node_Str"+ this.m_connectedTime+ "String_Node_Str"+ "String_Node_Str"+ this.m_completedTime);
    return new NoneImpl<Integer>();
  }
 else {
    if (m_completedTime == m_connectedTime) {
      LOG.warn("String_Node_Str" + m_completedTime);
    }
    final long safeCompletedTime=Math.max(m_completedTime,m_connectedTime + 1);
    final long downloadMs=safeCompletedTime - m_connectedTime;
    final int kbs=(int)(m_contentLength * 1000 / downloadMs * 1024);
    return new SomeImpl<Integer>(kbs);
  }
}
Program: 44848
Project: 44848
Buggy source:
public void onConnect(final long ms){
  this.m_connectedTime=System.currentTimeMillis();
}

Fixed version (ground truth):
public void onConnect(final long ms){
  this.m_connectedTime=System.currentTimeMillis();
  LOG.debug("String_Node_Str" + m_connectedTime);
}
Program: 44850
Project: 44850
Buggy source:
static ModFormat checkType(String id){
  if (id.equals("String_Node_Str") || id.equals("String_Node_Str"))   return new ModFormat(pt,4,31,ptText + "String_Node_Str" + id+ "String_Node_Str");
  if (id.equals("String_Node_Str") || id.equals("String_Node_Str") || id.equals("String_Node_Str")|| id.equals("String_Node_Str"))   return new ModFormat(trekker,digit(id,3),31,trekkerText + "String_Node_Str" + id+ "String_Node_Str");
  if (id.equals("String_Node_Str"))   return new ModFormat(generic,8,31,"String_Node_Str" + "String_Node_Str" + id + "String_Node_Str");
  if (id.equals("String_Node_Str"))   return new ModFormat(generic,8,31,"String_Node_Str" + "String_Node_Str" + id + "String_Node_Str");
  if (id.endsWith("String_Node_Str") && digit(id,0) >= 0)   return new ModFormat(generic,digit(id,0),31,ftText + "String_Node_Str" + id+ "String_Node_Str");
  if (id.endsWith("String_Node_Str") && digit(id,0) >= 0 && digit(id,1) >= 0)   return new ModFormat(ft_orpheus,digit(id,0) * 10 + digit(id,1),31,ftText + "String_Node_Str" + id+ "String_Node_Str");
  if (id.endsWith("String_Node_Str") && digit(id,0) >= 0 && digit(id,1) >= 0)   return new ModFormat(generic,digit(id,0) * 10 + digit(id,1),31,ttText + "String_Node_Str" + id+ "String_Node_Str");
  return null;
}

Fixed version (ground truth):
static ModFormat checkType(String id){
  if (id.equals("String_Node_Str") || id.equals("String_Node_Str"))   return new ModFormat(pt,4,31,ptText + "String_Node_Str" + id+ "String_Node_Str");
  if (id.equals("String_Node_Str") || id.equals("String_Node_Str") || id.equals("String_Node_Str")|| id.equals("String_Node_Str"))   return new ModFormat(trekker,digit(id,3),31,trekkerText + "String_Node_Str" + id+ "String_Node_Str");
  if (id.equals("String_Node_Str"))   return new ModFormat(generic,8,31,"String_Node_Str" + "String_Node_Str" + id + "String_Node_Str");
  if (id.equals("String_Node_Str"))   return new ModFormat(generic,8,31,"String_Node_Str" + "String_Node_Str" + id + "String_Node_Str");
  if (id.endsWith("String_Node_Str") && digit(id,0) >= 0)   return new ModFormat(generic,digit(id,0),31,ftText + "String_Node_Str" + id+ "String_Node_Str");
  if (id.endsWith("String_Node_Str") && digit(id,0) >= 0 && digit(id,1) >= 0)   return new ModFormat(ft_orpheus,number00(id),31,ftText + "String_Node_Str" + id+ "String_Node_Str");
  if (id.endsWith("String_Node_Str") && digit(id,0) >= 0 && digit(id,1) >= 0)   return new ModFormat(generic,number00(id),31,ttText + "String_Node_Str" + id+ "String_Node_Str");
  return null;
}
Program: 44851
Project: 44851
Buggy source:
private static Instrument readInstrument(ByteReader reader,int index,ModFormat.Type type){
  final String name=reader.string(22);
  final int length=reader.u2() * 2;
  final int finetune=reader.u1() & 15;
  final int volume=Math.min(64,reader.u1());
  final int loopStart=reader.u2() * (type == ust ? 1 : 2);
  final int loopLength=reader.u2() * (type == ust ? 1 : 2);
  final Instrument instrument=new SampledInstrument(index + 1,length);
  instrument.name(name);
  instrument.volume(volume);
  instrument.fineTune(finetune);
  instrument.loop(loopStart,loopLength);
  return instrument;
}

Fixed version (ground truth):
private static Instrument readInstrument(ByteReader reader,int index,ModFormat.Type type){
  final String name=reader.string(22);
  final int length=reader.u2() * 2;
  final int finetune=reader.u1() & 15;
  final int volume=reader.u1();
  final int loopStart=reader.u2() * (type == ust ? 1 : 2);
  final int loopLength=reader.u2() * (type == ust ? 1 : 2);
  final Instrument instrument=new SampledInstrument(index + 1,length);
  instrument.name(name);
  instrument.volume(volume);
  instrument.fineTune(finetune);
  instrument.loop(loopStart,loopLength);
  instrument.is16bit=type == ft_orpheus && (volume & 0x80) != 0;
  return instrument;
}
Program: 44852
Project: 44852
Buggy source:
public Mod parse(byte[] data){
  ByteReader reader=new ByteReader(data);
  reader.seek(1080);
  if (reader.available() < 4)   return null;
  String id=reader.string(4);
  ModFormat format=checkType(id);
  if (format == null)   format=testLegacy(reader);
  if (format == null)   return null;
  reader.seek(0);
  String title=reader.string(20);
  Instrument[] instruments=readInstruments(reader,format);
  if (instruments == null)   return null;
  int songLength=reader.u1();
  reader.skip(1);
  int[] order=readPatternOrder(reader);
  int totalPatterns=countPatterns(order,songLength);
  if (!format.isLegacy())   reader.skip(4);
  Block[] patterns=readPatterns(reader,totalPatterns,format,instruments);
  if (patterns == null)   return null;
  readInstrumentSamples(reader,instruments);
  Mod mod=new Mod(format.tracks);
  mod.tracker=format.description;
  mod.title=Tools.trimEnd(title,nulChar);
  mod.instruments=instruments;
  mod.songLength=songLength;
  mod.blockOrder=order;
  mod.blocks=patterns;
  return mod;
}

Fixed version (ground truth):
public Mod parse(byte[] data){
  ByteReader reader=new ByteReader(data);
  reader.seek(1080);
  if (reader.available() < 4)   return null;
  String id=reader.string(4);
  ModFormat format=checkType(id);
  if (format == null)   format=testLegacy(reader);
  if (format == null)   return null;
  reader.seek(0);
  String title=reader.string(20);
  Instrument[] instruments=readInstruments(reader,format);
  format=updateDescription(format,id,instruments);
  int songLength=reader.u1();
  reader.skip(1);
  int[] order=readPatternOrder(reader);
  if (format.type == trekker && format.tracks == 8)   format=format.changeTracks(adjustTrekker8Order(order));
  int totalPatterns=countPatterns(order,songLength);
  if (!format.isLegacy())   reader.skip(4);
  Block[] patterns=readPatterns(reader,totalPatterns,format,instruments);
  if (patterns == null)   return null;
  readInstrumentSamples(reader,instruments);
  Mod mod=new Mod(format.tracks);
  mod.tracker=format.description;
  mod.title=Tools.trimEnd(title,nulChar);
  mod.instruments=instruments;
  mod.songLength=songLength;
  mod.blockOrder=order;
  mod.blocks=patterns;
  return mod;
}
Program: 44853
Project: 44853
Buggy source:
private static void readInstrumentSamples(ByteReader reader,Instrument[] instruments){
  for (int i=0; i < instruments.length; i++) {
    for (int j=0, n=instruments[i].data().length; j < n; j++) {
      if (reader.available() == 0) {
        instruments[i].trimTo(j);
        break;
      }
      instruments[i].data()[j]=(byte)reader.s1();
    }
  }
}

Fixed version (ground truth):
private static void readInstrumentSamples(ByteReader reader,Instrument[] instruments){
  for (int i=0; i < instruments.length; i++) {
    for (int j=0, n=instruments[i].data().length; j < n; j++) {
      if (reader.available() == 0) {
        instruments[i].trimTo(j);
        break;
      }
      instruments[i].data()[j]=(byte)reader.s1();
      if (instruments[i].is16bit)       reader.skip(1);
    }
  }
}
Program: 44854
Project: 44854
Buggy source:
private static Block readPattern(ByteReader reader,ModFormat format,Instrument[] ins){
  if (reader.available() < 64 * format.tracks * 4)   return null;
  Block block=new Block(64,format.tracks);
  for (int row=0; row < 64; row++) {
    for (int track=0; track < format.tracks; track++) {
      int b0=reader.u1();
      int b1=reader.u1();
      int b2=reader.u1();
      int b3=reader.u1();
      int instrumentIndex=(b0 & 0xF0 | (b2 & 0xF0) >> 4) - 1;
      int period=(b0 << 8 | b1) & 0xFFF;
      int key=Period.getKeyForPeriod(period * 100);
      int effect=b2 & 0xF;
      int efx=b3 >> 4;
      int efy=b3 & 15;
      if (effect == 0x0E) {
        effect=effect << 4 | efx;
        efx=0;
      }
      if (effect == 0x0D) {
        int dec=efx * 10 + efy;
        efx=dec >> 4;
        efy=dec & 15;
      }
      boolean isOutOfRange=instrumentIndex < 0 || instrumentIndex >= ins.length;
      Instrument instrument=isOutOfRange ? null : ins[instrumentIndex];
      block.putNote(row,track,new Note(key,instrument,effect,efx,efy,false));
    }
  }
  return block;
}

Fixed version (ground truth):
private static Block readPattern(ByteReader reader,ModFormat.Type type,int tracks,Instrument[] ins){
  if (reader.available() < 64 * tracks * 4)   return null;
  Block block=new Block(64,tracks);
  for (int row=0; row < 64; row++) {
    for (int track=0; track < tracks; track++) {
      int b0=reader.u1();
      int b1=reader.u1();
      int b2=reader.u1();
      int b3=reader.u1();
      int i=(b0 & 0xF0 | (b2 & 0xF0) >> 4) - 1;
      int period=(b0 << 8 | b1) & 0xFFF;
      int key=Period.getKeyForPeriod(period * 100);
      int effect=type == ust ? ustEffect(b2 & 0xF,b3) : b2 & 0xF;
      int param=type == ust ? ustEffectParam(b2 & 0xF,b3) : b3;
      int paramX=param >> 4;
      int paramY=param & 15;
      if (effect == 0x0E) {
        effect=effect << 4 | paramX;
        paramX=0;
      }
      if (effect == 0x0D) {
        int dec=paramX * 10 + paramY;
        paramX=dec >> 4;
        paramY=dec & 15;
      }
      boolean isOutOfRange=i < 0 || i >= ins.length;
      Instrument instrument=isOutOfRange ? null : ins[i];
      block.putNote(row,track,new Note(key,instrument,effect,paramX,paramY,false));
    }
  }
  return block;
}
Program: 44855
Project: 44855
Buggy source:
private static Block[] readPatterns(ByteReader reader,int count,ModFormat format,Instrument[] ins){
  Block[] patterns=new Block[count];
  for (int i=0; i < count; i++) {
    patterns[i]=readPattern(reader,format,ins);
    if (patterns[i] == null)     return null;
  }
  return patterns;
}

Fixed version (ground truth):
private static Block[] readPatterns(ByteReader reader,int n,ModFormat format,Instrument[] ins){
  Block[] patterns=new Block[n];
  for (int i=0; i < n; i++) {
    if (format.type == trekker && format.tracks == 8) {
      Block pattern1=readPattern(reader,format.type,4,ins);
      Block pattern2=readPattern(reader,format.type,4,ins);
      if (pattern1 == null || pattern2 == null)       return null;
      patterns[i]=new Block(64,8);
      for (int row=0; row < 64; row++) {
        for (int track=0; track < 4; track++) {
          patterns[i].putNote(row,track,pattern1.getNote(row,track));
          patterns[i].putNote(row,track + 4,pattern2.getNote(row,track));
        }
      }
    }
 else {
      patterns[i]=readPattern(reader,format.type,format.tracks,ins);
      if (patterns[i] == null)       return null;
    }
  }
  return patterns;
}
Program: 44856
Project: 44856
Buggy source:
private static Instrument[] readInstruments(ByteReader reader,ModFormat format){
  if (reader.available() < 30 * format.samples)   ;
  final Instrument[] instruments=new Instrument[format.samples];
  for (int i=0; i < instruments.length; i++)   instruments[i]=readInstrument(reader,i,format.type);
  return instruments;
}

Fixed version (ground truth):
private static Instrument[] readInstruments(ByteReader reader,ModFormat format){
  final Instrument[] instruments=new Instrument[format.samples];
  for (int i=0; i < instruments.length; i++)   instruments[i]=readInstrument(reader,i,format.type);
  return instruments;
}
Program: 44857
Project: 44857
Buggy source:
private void playSong(final String filePath){
  final File file=new File(filePath);
  final byte[] data=new byte[(int)file.length()];
  try {
    final FileInputStream in=new FileInputStream(file);
    if (in.read(data) != data.length) {
      in.close();
      Log.e("String_Node_Str","String_Node_Str");
      return;
    }
    in.close();
  }
 catch (  final Exception e) {
    Log.e("String_Node_Str",e.getMessage(),e);
    return;
  }
  for (  Parser parser : parsers) {
    if (parser.test(data)) {
      Mod mod=parser.parse(data);
      if (mod == null) {
        Toast.makeText(this,"String_Node_Str" + parser.name(),Toast.LENGTH_SHORT);
      }
 else {
        playLoop(mod,file.getName());
        return;
      }
    }
  }
  Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT);
}

Fixed version (ground truth):
private void playSong(final String filePath){
  final File file=new File(filePath);
  final byte[] data=new byte[(int)file.length()];
  try {
    final FileInputStream in=new FileInputStream(file);
    if (in.read(data) != data.length) {
      in.close();
      Log.e("String_Node_Str","String_Node_Str");
      return;
    }
    in.close();
  }
 catch (  final Exception e) {
    Log.e("String_Node_Str",e.getMessage(),e);
    return;
  }
  for (  Parser parser : parsers) {
    if (parser.test(data)) {
      Mod mod=parser.parse(data);
      if (mod == null) {
        Toast.makeText(this,"String_Node_Str" + parser.name(),Toast.LENGTH_SHORT).show();
      }
 else {
        playLoop(mod,file.getName());
        return;
      }
    }
  }
  Toast.makeText(this,"String_Node_Str",Toast.LENGTH_SHORT).show();
}
Program: 44858
Project: 44858
Buggy source:
public Mod parse(byte[] data){
  ByteReader reader=new ByteReader(data);
  reader.seek(1080);
  if (reader.available() < 4)   return null;
  String id=reader.string(4);
  ModFormat format=checkType(id);
  if (format == null)   format=testLegacy(reader);
  if (format == null)   return null;
  reader.seek(0);
  String title=reader.string(20);
  Instrument[] instruments=readInstruments(reader,format);
  format=updateDescription(format,id,instruments);
  int songLength=reader.u1();
  reader.skip(1);
  int[] order=readPatternOrder(reader);
  if (format.type == trekker && format.tracks == 8)   format=format.changeTracks(adjustTrekker8Order(order));
  int totalPatterns=countPatterns(order,songLength);
  if (!format.isLegacy())   reader.skip(4);
  Pattern[] patterns=readPatterns(reader,totalPatterns,format,instruments);
  if (patterns == null)   return null;
  readInstrumentSamples(reader,instruments);
  Mod mod=new Mod(format.tracks);
  mod.tracker=format.description;
  mod.title=Tools.trimEnd(title,nulChar);
  mod.instruments=instruments;
  mod.songLength=songLength;
  mod.patternOrder=order;
  mod.patterns=patterns;
  return mod;
}

Fixed version (ground truth):
public Mod parse(byte[] data){
  ByteReader reader=new ByteReader(data);
  reader.seek(1080);
  if (reader.available() < 4)   return null;
  String id=reader.string(4);
  ModFormat format=checkType(id);
  if (format == null)   format=testLegacy(reader);
  if (format == null)   return null;
  reader.seek(0);
  String title=reader.string(20);
  Instrument[] instruments=readInstruments(reader,format);
  format=updateDescription(format,id,instruments);
  int songLength=reader.u1();
  reader.skip(1);
  int[] order=readPatternOrder(reader);
  if (format.type == trekker && format.tracks == 8)   format=format.changeTracks(adjustTrekker8Order(order));
  int totalPatterns=countPatterns(order,songLength);
  if (!format.isLegacy())   reader.skip(4);
  Pattern[] patterns=readPatterns(reader,totalPatterns,format);
  if (patterns == null)   return null;
  readInstrumentSamples(reader,instruments);
  Mod mod=new Mod(format.tracks);
  mod.tracker=format.description;
  mod.title=Tools.trimEnd(title,nulChar);
  mod.instruments=instruments;
  mod.songLength=songLength;
  mod.patternOrder=order;
  mod.patterns=patterns;
  return mod;
}
Program: 44859
Project: 44859
Buggy source:
private static Pattern readPattern(ByteReader reader,ModFormat.Type type,int tracks){
  if (reader.available() < 64 * tracks * 4)   return null;
  Pattern block=new Pattern(tracks,64);
  for (int row=0; row < 64; row++) {
    for (int track=0; track < tracks; track++) {
      int b0=reader.u1();
      int b1=reader.u1();
      int b2=reader.u1();
      int b3=reader.u1();
      int i=(b0 & 0xF0 | (b2 & 0xF0) >> 4) - 1;
      int period=(b0 << 8 | b1) & 0xFFF;
      int key=Period.getKeyForPeriod(period * 100);
      int effect=type == ust ? ustEffect(b2 & 0xF,b3) : b2 & 0xF;
      int param=type == ust ? ustEffectParam(b2 & 0xF,b3) : b3;
      int paramX=param >> 4;
      int paramY=param & 15;
      if (effect == 0x0E) {
        effect=effect << 4 | paramX;
        paramX=0;
      }
      if (effect == 0x0D) {
        int dec=paramX * 10 + paramY;
        paramX=dec >> 4;
        paramY=dec & 15;
      }
      block.setNote(track,row,Note.create(key,i,effect,param,false));
    }
  }
  return block;
}

Fixed version (ground truth):
private static Pattern readPattern(ByteReader reader,ModFormat.Type type,int tracks){
  if (reader.available() < 64 * tracks * 4)   return null;
  Pattern block=new Pattern(tracks,64);
  for (int row=0; row < 64; row++) {
    for (int track=0; track < tracks; track++) {
      int b0=reader.u1();
      int b1=reader.u1();
      int b2=reader.u1();
      int b3=reader.u1();
      int ins=(b0 & 0xF0 | (b2 & 0xF0) >> 4) - 1;
      int period=(b0 << 8 | b1) & 0xFFF;
      int key=Period.getKeyForPeriod(period * 100);
      int effect=type == ust ? ustEffect(b2 & 0xF,b3) : b2 & 0xF;
      int param=type == ust ? ustEffectParam(b2 & 0xF,b3) : b3;
      if (effect == 0x0E) {
        effect=effect << 4 | param >> 4 & 0xF;
        param&=0xF;
      }
      if (effect == 0x0D)       param=(param >> 4) * 10 + (param & 0xF);
      block.setNote(track,row,Note.create(key,ins,effect,param));
    }
  }
  return block;
}