nus-yam/ex-repair huggingface dataset:
Program: 34099
Project: 34099
Buggy source:
/** 
 * Prevents usage of an Ender Chest
 * @param event
 */
@EventHandler(priority=EventPriority.LOWEST) void PlayerInteractEvent(PlayerInteractEvent event){
  if (debug) {
    plugin.getLogger().info(event.getEventName());
  }
  Player player=(Player)event.getPlayer();
  if (player.getWorld().getName().equalsIgnoreCase(Settings.worldName) || player.getWorld().getName().equalsIgnoreCase(Settings.worldName + "String_Node_Str")) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
      if (event.getClickedBlock().getType() == Material.ENDER_CHEST) {
        if (!(event.getPlayer().hasPermission(Settings.PERMPREFIX + "String_Node_Str"))) {
          event.setCancelled(true);
        }
 else {
          player.sendMessage(ChatColor.RED + Locale.errorNoPermission);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Prevents usage of an Ender Chest
 * @param event
 */
@EventHandler(priority=EventPriority.LOWEST) void PlayerInteractEvent(PlayerInteractEvent event){
  if (debug) {
    plugin.getLogger().info(event.getEventName());
  }
  Player player=(Player)event.getPlayer();
  if (player.getWorld().getName().equalsIgnoreCase(Settings.worldName) || player.getWorld().getName().equalsIgnoreCase(Settings.worldName + "String_Node_Str")) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
      if (event.getClickedBlock().getType() == Material.ENDER_CHEST) {
        if (!(event.getPlayer().hasPermission(Settings.PERMPREFIX + "String_Node_Str"))) {
          player.sendMessage(ChatColor.RED + Locale.errorNoPermission);
          event.setCancelled(true);
        }
      }
    }
  }
}
Program: 34100
Project: 34100
Buggy source:
/** 
 * Prevents crafting of EnderChest unless the player has permission
 * @param event
 */
@EventHandler(priority=EventPriority.LOW) public void onCraft(CraftItemEvent event){
  if (debug) {
    plugin.getLogger().info(event.getEventName());
  }
  Player player=(Player)event.getWhoClicked();
  if (player.getWorld().getName().equalsIgnoreCase(Settings.worldName) || player.getWorld().getName().equalsIgnoreCase(Settings.worldName + "String_Node_Str")) {
    if (event.getRecipe().getResult().getType() == Material.ENDER_CHEST) {
      if (!(player.hasPermission(Settings.PERMPREFIX + "String_Node_Str"))) {
        event.setCancelled(true);
      }
 else {
        player.sendMessage(ChatColor.RED + Locale.errorNoPermission);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Prevents crafting of EnderChest unless the player has permission
 * @param event
 */
@EventHandler(priority=EventPriority.LOW) public void onCraft(CraftItemEvent event){
  if (debug) {
    plugin.getLogger().info(event.getEventName());
  }
  Player player=(Player)event.getWhoClicked();
  if (player.getWorld().getName().equalsIgnoreCase(Settings.worldName) || player.getWorld().getName().equalsIgnoreCase(Settings.worldName + "String_Node_Str")) {
    if (event.getRecipe().getResult().getType() == Material.ENDER_CHEST) {
      if (!(player.hasPermission(Settings.PERMPREFIX + "String_Node_Str"))) {
        player.sendMessage(ChatColor.RED + Locale.errorNoPermission);
        event.setCancelled(true);
      }
    }
  }
}
Program: 34101
Project: 34101
Buggy source:
/** 
 * Returns true if this location is within the spawn area Spawn are is square and goes out to range in + and - x and z directions
 * @param loc
 * @return
 */
protected boolean isAtSpawn(Location loc){
  if (spawnLoc == null) {
    return false;
  }
  if (loc.getWorld().equals(bedrock.getWorld())) {
    if ((Math.abs(loc.getBlockX() - bedrock.getBlockX()) <= range) || (Math.abs(loc.getBlockZ() - bedrock.getBlockZ()) <= range)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Returns true if this location is within the spawn area Spawn are is square and goes out to range in + and - x and z directions
 * @param loc
 * @return
 */
protected boolean isAtSpawn(Location loc){
  if (spawnLoc == null) {
    return false;
  }
  if (loc.getWorld().equals(bedrock.getWorld())) {
    if ((Math.abs(loc.getBlockX() - bedrock.getBlockX()) <= range) && (Math.abs(loc.getBlockZ() - bedrock.getBlockZ()) <= range)) {
      return true;
    }
  }
  return false;
}
Program: 34102
Project: 34102
Buggy source:
/** 
 * Checks if this location is safe for a player to teleport to. Used by warps and boat exits Unsafe is any liquid or air and also if there's no space
 * @param l - Location to be checked
 * @return true if safe, otherwise false
 */
protected static boolean isSafeLocation(final Location l){
  if (l == null) {
    return false;
  }
  final Block ground=l.getBlock().getRelative(BlockFace.DOWN);
  final Block space1=l.getBlock();
  final Block space2=l.getBlock().getRelative(BlockFace.UP);
  if (ground.getType().equals(Material.AIR)) {
    return false;
  }
  if (ground.isLiquid() || space1.isLiquid() || space2.isLiquid()) {
    if (Settings.acidDamage > 0D) {
      return false;
    }
 else     if (ground.getType().equals(Material.STATIONARY_LAVA) || ground.getType().equals(Material.LAVA) || space1.getType().equals(Material.STATIONARY_LAVA)|| space1.getType().equals(Material.LAVA)|| space2.getType().equals(Material.STATIONARY_LAVA)|| space2.getType().equals(Material.LAVA)) {
      return false;
    }
  }
  if (ground.getType().equals(Material.CACTUS)) {
    return false;
  }
  if (ground.getType().equals(Material.BOAT)) {
    return false;
  }
  if (space1.getType().isSolid()) {
    if (!(space1.getType().equals(Material.SIGN_POST)) && !(space1.getType().equals(Material.WALL_SIGN))) {
      return false;
    }
  }
  if (space2.getType().isSolid()) {
    if (!(space2.getType().equals(Material.SIGN_POST)) && !(space2.getType().equals(Material.WALL_SIGN))) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Checks if this location is safe for a player to teleport to. Used by warps and boat exits Unsafe is any liquid or air and also if there's no space
 * @param l - Location to be checked
 * @return true if safe, otherwise false
 */
protected static boolean isSafeLocation(final Location l){
  if (l == null) {
    return false;
  }
  final Block ground=l.getBlock().getRelative(BlockFace.DOWN);
  final Block space1=l.getBlock();
  final Block space2=l.getBlock().getRelative(BlockFace.UP);
  if (ground.getType() == Material.AIR) {
    return false;
  }
  if (ground.isLiquid() || space1.isLiquid() || space2.isLiquid()) {
    if (Settings.acidDamage > 0D) {
      return false;
    }
 else     if (ground.getType().equals(Material.STATIONARY_LAVA) || ground.getType().equals(Material.LAVA) || space1.getType().equals(Material.STATIONARY_LAVA)|| space1.getType().equals(Material.LAVA)|| space2.getType().equals(Material.STATIONARY_LAVA)|| space2.getType().equals(Material.LAVA)) {
      return false;
    }
  }
  if (ground.getType().equals(Material.CACTUS)) {
    return false;
  }
  if (ground.getType().equals(Material.BOAT)) {
    return false;
  }
  if (space1.getType().isSolid()) {
    if (!(space1.getType().equals(Material.SIGN_POST)) && !(space1.getType().equals(Material.WALL_SIGN))) {
      return false;
    }
  }
  if (space2.getType().isSolid()) {
    if (!(space2.getType().equals(Material.SIGN_POST)) && !(space2.getType().equals(Material.WALL_SIGN))) {
      return false;
    }
  }
  return true;
}
Program: 34104
Project: 34104
Buggy source:
/** 
 * This teleports player to their island. If not safe place can be found then the player is sent to spawn via /spawn command
 * @param player
 * @return
 */
@SuppressWarnings("String_Node_Str") protected boolean homeTeleport(final Player player){
  Location home=null;
  home=getSafeHomeLocation(player.getUniqueId());
  if (player.isInsideVehicle()) {
    Entity boat=player.getVehicle();
    if (boat instanceof Boat) {
      player.leaveVehicle();
      boat.remove();
      player.getInventory().addItem(new ItemStack(Material.BOAT,1));
      player.updateInventory();
    }
  }
  if (home == null) {
    if (!player.performCommand(Settings.SPAWNCOMMAND)) {
      player.sendBlockChange(player.getWorld().getSpawnLocation(),player.getWorld().getSpawnLocation().getBlock().getType(),player.getWorld().getSpawnLocation().getBlock().getData());
      player.teleport(player.getWorld().getSpawnLocation());
    }
    player.sendMessage(ChatColor.RED + Locale.warpserrorNotSafe);
    return true;
  }
  home.getWorld().loadChunk(home.getChunk());
  player.sendBlockChange(home,home.getBlock().getType(),home.getBlock().getData());
  player.teleport(home);
  player.sendMessage(ChatColor.GREEN + Locale.islandteleport);
  return true;
}

Fixed version (ground truth):
/** 
 * This teleports player to their island. If not safe place can be found then the player is sent to spawn via /spawn command
 * @param player
 * @return
 */
@SuppressWarnings("String_Node_Str") protected boolean homeTeleport(final Player player){
  Location home=null;
  home=getSafeHomeLocation(player.getUniqueId());
  if (player.isInsideVehicle()) {
    Entity boat=player.getVehicle();
    if (boat instanceof Boat) {
      player.leaveVehicle();
      boat.remove();
      player.getInventory().addItem(new ItemStack(Material.BOAT,1));
      player.updateInventory();
    }
  }
  if (home == null) {
    if (!player.performCommand(Settings.SPAWNCOMMAND)) {
      player.sendBlockChange(player.getWorld().getSpawnLocation(),player.getWorld().getSpawnLocation().getBlock().getType(),player.getWorld().getSpawnLocation().getBlock().getData());
      player.teleport(player.getWorld().getSpawnLocation());
    }
    player.sendMessage(ChatColor.RED + Locale.warpserrorNotSafe);
    return true;
  }
  home.getWorld().loadChunk(home.getChunk());
  player.sendBlockChange(home,home.getBlock().getType(),home.getBlock().getData());
  player.sendBlockChange(home.getBlock().getRelative(BlockFace.DOWN).getLocation(),home.getBlock().getRelative(BlockFace.DOWN).getType(),home.getBlock().getRelative(BlockFace.DOWN).getData());
  player.teleport(home);
  player.sendMessage(ChatColor.GREEN + Locale.islandteleport);
  return true;
}
Program: 34107
Project: 34107
Buggy source:
@EventHandler(priority=EventPriority.LOW) public void ArmorStandDestroy(EntityDamageByEntityEvent e){
  if (debug) {
    plugin.getLogger().info(e.getEventName());
  }
  if (!(e.getEntity() instanceof LivingEntity)) {
    return;
  }
  if (!e.getEntity().getWorld().getName().equalsIgnoreCase(Settings.worldName)) {
    return;
  }
  final LivingEntity livingEntity=(LivingEntity)e.getEntity();
  if (!livingEntity.getType().equals(EntityType.ARMOR_STAND)) {
    return;
  }
  if (e.getDamager() instanceof Player) {
    Player p=(Player)e.getDamager();
    if (p.isOp()) {
      return;
    }
    if (VaultHelper.checkPerm(p,Settings.PERMPREFIX + "String_Node_Str")) {
      return;
    }
    p.sendMessage(ChatColor.RED + Locale.islandProtected);
    e.setCancelled(true);
  }
}

Fixed version (ground truth):
@EventHandler(priority=EventPriority.LOW) public void ArmorStandDestroy(EntityDamageByEntityEvent e){
  if (debug) {
    plugin.getLogger().info(e.getEventName());
  }
  if (!(e.getEntity() instanceof LivingEntity)) {
    return;
  }
  if (!e.getEntity().getWorld().getName().equalsIgnoreCase(Settings.worldName)) {
    return;
  }
  final LivingEntity livingEntity=(LivingEntity)e.getEntity();
  if (!livingEntity.getType().equals(EntityType.ARMOR_STAND)) {
    return;
  }
  if (e.getDamager() instanceof Player) {
    Player p=(Player)e.getDamager();
    if (p.isOp()) {
      return;
    }
    if (plugin.playerIsOnIsland(p)) {
      return;
    }
    if (VaultHelper.checkPerm(p,Settings.PERMPREFIX + "String_Node_Str")) {
      return;
    }
    p.sendMessage(ChatColor.RED + Locale.islandProtected);
    e.setCancelled(true);
  }
}
Program: 34110
Project: 34110
Buggy source:
@Override public void populate(World world,Random random,Chunk source){
  for (int x=0; x < 16; x++) {
    for (int y=0; y < world.getMaxHeight(); y++) {
      for (int z=0; z < 16; z++) {
        Block b=source.getBlock(x,y,z);
        if (b.getType().equals(Material.MOB_SPAWNER)) {
          CreatureSpawner cs=(CreatureSpawner)b.getState();
switch (random.nextInt(3)) {
case 0:
            cs.setSpawnedType(EntityType.BLAZE);
          break;
case 1:
        cs.setSpawnedType(EntityType.SKELETON);
      break;
case 2:
    cs.setSpawnedType(EntityType.MAGMA_CUBE);
  break;
default :
cs.setSpawnedType(EntityType.BLAZE);
}
}
}
}
}
}

Fixed version (ground truth):
@Override public void populate(World world,Random random,Chunk source){
  for (int x=0; x < 16; x++) {
    for (int y=0; y < world.getMaxHeight(); y++) {
      for (int z=0; z < 16; z++) {
        Block b=source.getBlock(x,y,z);
        if (b.getType().equals(Material.MOB_SPAWNER)) {
          CreatureSpawner cs=(CreatureSpawner)b.getState();
switch (random.nextInt(3)) {
case 0:
            cs.setSpawnedType(EntityType.BLAZE);
          break;
case 1:
        cs.setSpawnedType(EntityType.SKELETON);
      break;
case 2:
    cs.setSpawnedType(EntityType.MAGMA_CUBE);
  break;
default :
cs.setSpawnedType(EntityType.BLAZE);
}
}
 else if (b.getType().equals(Material.OBSIDIAN)) {
b.setType(Material.CHEST);
Chest cs=(Chest)b.getState();
Inventory chestInv=cs.getInventory();
int numOfStacks=2 + random.nextInt(3);
for (int i=0; i < numOfStacks; i++) {
int slot=random.nextInt(chestInv.getSize());
for (int j=0; j < chestInv.getSize(); j++) {
if (chestInv.getItem(slot) == null) {
  break;
}
slot=random.nextInt(chestInv.getSize());
}
int choice=random.nextInt(73);
if (choice < 5) {
chestInv.setItem(slot,new ItemStack(Material.DIAMOND,random.nextInt(2) + 1));
}
 else if (choice < 10) {
chestInv.setItem(slot,new ItemStack(Material.IRON_INGOT,random.nextInt(4) + 1));
}
 else if (choice < 25) {
chestInv.setItem(slot,new ItemStack(Material.GOLD_INGOT,random.nextInt(2) + 1));
}
 else if (choice < 30) {
chestInv.setItem(slot,new ItemStack(Material.GOLD_SWORD,1));
}
 else if (choice < 35) {
chestInv.setItem(slot,new ItemStack(Material.GOLD_CHESTPLATE,1));
}
 else if (choice < 40) {
chestInv.setItem(slot,new ItemStack(Material.FLINT_AND_STEEL,1));
}
 else if (choice < 45) {
chestInv.setItem(slot,new ItemStack(Material.NETHER_WARTS,random.nextInt(4) + 3));
}
 else if (choice < 55) {
chestInv.setItem(slot,new ItemStack(Material.SADDLE,1));
}
 else if (choice < 63) {
chestInv.setItem(slot,new ItemStack(Material.GOLD_BARDING,1));
}
 else if (choice < 68) {
chestInv.setItem(slot,new ItemStack(Material.IRON_BARDING,1));
}
 else if (choice < 71) {
chestInv.setItem(slot,new ItemStack(Material.DIAMOND_BARDING,1));
}
 else {
chestInv.setItem(slot,new ItemStack(Material.OBSIDIAN,random.nextInt(3) + 1));
}
}
}
 else if (b.getType().equals(Material.STONE)) {
b.setType(Material.QUARTZ_ORE);
}
}
}
}
}
Program: 34111
Project: 34111
Buggy source:
/** 
 * Prevents blocks from being broken
 * @param e
 */
@EventHandler(priority=EventPriority.LOW) public void onBlockBreak(final BlockBreakEvent e){
  if (e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "String_Node_Str") || e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "String_Node_Str")) {
    if (!awayFromSpawn(e.getPlayer()) && !e.getPlayer().isOp()) {
      e.setCancelled(true);
    }
  }
}

Fixed version (ground truth):
/** 
 * Prevents blocks from being broken
 * @param e
 */
@EventHandler(priority=EventPriority.LOW) public void onBlockBreak(final BlockBreakEvent e){
  if ((e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "String_Node_Str") && !Settings.newNether) || e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "String_Node_Str")) {
    if (!awayFromSpawn(e.getPlayer()) && !e.getPlayer().isOp()) {
      e.getPlayer().sendMessage(Locale.netherSpawnIsProtected);
      e.setCancelled(true);
    }
  }
}
Program: 34112
Project: 34112
Buggy source:
private boolean awayFromSpawn(Player player){
  Vector p=player.getLocation().toVector().multiply(new Vector(1,0,1));
  Vector spawn=player.getWorld().getSpawnLocation().toVector().multiply(new Vector(1,0,1));
  if (spawn.distanceSquared(p) < (Settings.netherSpawnRadius * Settings.netherSpawnRadius)) {
    player.sendMessage(Locale.netherSpawnIsProtected);
    return false;
  }
 else {
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Function to check proximity to nether spawn location
 * @param player
 * @return
 */
private boolean awayFromSpawn(Player player){
  Vector p=player.getLocation().toVector().multiply(new Vector(1,0,1));
  Vector spawn=player.getWorld().getSpawnLocation().toVector().multiply(new Vector(1,0,1));
  if (spawn.distanceSquared(p) < (Settings.netherSpawnRadius * Settings.netherSpawnRadius)) {
    return false;
  }
 else {
    return true;
  }
}
Program: 34118
Project: 34118
Buggy source:
/** 
 * This event makes sure that any acid bottles become potions without the warning
 * @param e
 */
@EventHandler(priority=EventPriority.NORMAL,ignoreCancelled=false) public void onBrewComplete(final BrewEvent e){
  if (e.getBlock().getWorld().getName().equalsIgnoreCase(Settings.worldName)) {
    BrewerInventory inv=e.getContents();
    int i=0;
    for (    ItemStack item : inv.getContents()) {
      ItemMeta meta=item.getItemMeta();
      meta.setDisplayName(null);
      meta.setLore(null);
      item.setItemMeta(null);
      inv.setItem(i,item);
      i++;
    }
  }
}

Fixed version (ground truth):
/** 
 * This event makes sure that any acid bottles become potions without the warning
 * @param e
 */
@EventHandler(priority=EventPriority.NORMAL,ignoreCancelled=false) public void onBrewComplete(final BrewEvent e){
  if (e.getBlock().getWorld().getName().equalsIgnoreCase(Settings.worldName)) {
    BrewerInventory inv=e.getContents();
    int i=0;
    for (    ItemStack item : inv.getContents()) {
      if (item != null) {
        ItemMeta meta=item.getItemMeta();
        meta.setDisplayName(null);
        meta.setLore(null);
        item.setItemMeta(null);
        inv.setItem(i,item);
      }
      i++;
    }
  }
}
Program: 34121
Project: 34121
Buggy source:
public Uri save(ContentResolver contentResolver,String title,String description){
  return CaptureSketchUtils.insertImage(contentResolver,bitmap,title,description);
}

Fixed version (ground truth):
public Uri save(ContentResolver contentResolver,String title,String description){
  return CaptureSketchUtils.insertImage(contentResolver,getBitmap(),title,description);
}
Program: 34122
Project: 34122
Buggy source:
private void splitIntoMultipleEventsAndPost(@NonNull MotionEvent event,RainbowInputController rainbowInputController){
  float px=rainbowInputController.getX();
  float py=rainbowInputController.getY();
  float diffX=event.getX() - px;
  float diffY=event.getY() - py;
  int divisions=getDivisionsFor(event);
  for (int i=0; i < divisions; i++) {
    float newEventX=px + diffX * (i + 1) / 2;
    float newEventY=py + diffY * (i + 1) / 2;
    MotionEvent subEvent=obtainEventWithNewPosition(event,newEventX,newEventY);
    rainbowInputController.postEvent(subEvent,rainbow.getRainbowDrawer());
  }
}

Fixed version (ground truth):
private void splitIntoMultipleEventsAndPost(@NonNull MotionEvent event,RainbowInputController rainbowInputController){
  float px=rainbowInputController.getX();
  float py=rainbowInputController.getY();
  float diffX=event.getX() - px;
  float diffY=event.getY() - py;
  int divisions=getDivisionsFor(event);
  for (int i=1; i <= divisions; i++) {
    float newEventX=px + diffX * i / divisions;
    float newEventY=py + diffY * i / divisions;
    MotionEvent subEvent=obtainEventWithNewPosition(event,newEventX,newEventY);
    rainbowInputController.postEvent(subEvent,rainbow.getRainbowDrawer());
  }
}
Program: 34123
Project: 34123
Buggy source:
private void performMove(MotionEvent event,RainbowDrawer rainbowDrawer){
  notifyFingerDraggedFor(px,py,x,y,event,rainbowDrawer);
}

Fixed version (ground truth):
private void performMove(MotionEvent event,RainbowDrawer rainbowDrawer){
  fingerPositionPredictor.moveTo(x,y);
  if (hasInteractionListener()) {
    event.setLocation(x,y);
    rainbowInteractionListener.onFingerDragged(event,rainbowDrawer);
  }
}
Program: 34124
Project: 34124
Buggy source:
private void handleSketchEvent(final MotionEvent event,final RainbowDrawer rainbowDrawer){
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
    screenTouched=true;
  fingerPositionPredictor.resetTo(x,y);
if (hasInteractionListener()) {
  rainbowInteractionListener.onSketchTouched(event,rainbowDrawer);
}
break;
case MotionEvent.ACTION_UP:
screenTouched=false;
if (hasInteractionListener()) {
rainbowInteractionListener.onSketchReleased(event,rainbowDrawer);
}
break;
case MotionEvent.ACTION_MOVE:
screenTouched=true;
performMove(event,rainbowDrawer);
break;
}
if (hasInteractionListener()) {
rainbowInteractionListener.onMotionEvent(event,rainbowDrawer);
}
}

Fixed version (ground truth):
private void handleSketchEvent(final MotionEvent event,final RainbowDrawer rainbowDrawer){
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
    performTouch(event,rainbowDrawer);
  break;
case MotionEvent.ACTION_UP:
screenTouched=false;
performRelease(event,rainbowDrawer);
break;
case MotionEvent.ACTION_MOVE:
screenTouched=true;
performMove(event,rainbowDrawer);
break;
}
performMotion(event,rainbowDrawer);
}
Program: 34125
Project: 34125
Buggy source:
private void splitIntoMultipleEventsAndPost(@NonNull MotionEvent event,RainbowInputController rainbowInputController){
  float px=rainbowInputController.getX();
  float py=rainbowInputController.getY();
  float diffX=event.getX() - px;
  float diffY=event.getY() - py;
  int divisions=getContext().getResources().getInteger(R.integer.dragging_divisions);
  for (int i=0; i < divisions; i++) {
    float newEventX=px + diffX * (i + 1) / 2;
    float newEventY=py + diffY * (i + 1) / 2;
    MotionEvent subEvent=obtainEventWithNewPosition(event,newEventX,newEventY);
    rainbowInputController.postEvent(subEvent,rainbow.getRainbowDrawer());
  }
}

Fixed version (ground truth):
private void splitIntoMultipleEventsAndPost(@NonNull MotionEvent event,RainbowInputController rainbowInputController){
  float px=rainbowInputController.getX();
  float py=rainbowInputController.getY();
  float diffX=event.getX() - px;
  float diffY=event.getY() - py;
  int divisions=getDivisionsFor(event);
  for (int i=0; i < divisions; i++) {
    float newEventX=px + diffX * (i + 1) / 2;
    float newEventY=py + diffY * (i + 1) / 2;
    MotionEvent subEvent=obtainEventWithNewPosition(event,newEventX,newEventY);
    rainbowInputController.postEvent(subEvent,rainbow.getRainbowDrawer());
  }
}
Program: 34126
Project: 34126
Buggy source:
public String format(String caller){
  Locale locale=LocaleContextHolder.getLocale();
  return messageSource.getMessage(messageKey,new Object[]{caller},locale);
}

Fixed version (ground truth):
public String format(Object... args){
  Locale locale=LocaleContextHolder.getLocale();
  return messageSource.getMessage(messageKey,args,locale);
}
Program: 34131
Project: 34131
Buggy source:
@Before public void initTest(){
  PoreTests.mockPlugin();
  world=PoreWorld.of(mock(World.class));
  when(world.getHandle().getEntities()).thenReturn(ImmutableList.of(mock(org.spongepowered.api.entity.player.Player.class),mock(org.spongepowered.api.entity.Entity.class),mock(org.spongepowered.api.entity.living.Human.class),mock(org.spongepowered.api.entity.player.Player.class),mock(org.spongepowered.api.entity.living.Living.class),mock(org.spongepowered.api.entity.player.Player.class),mock(org.spongepowered.api.entity.player.Player.class),mock(org.spongepowered.api.entity.living.Living.class),mock(org.spongepowered.api.entity.living.Living.class),mock(org.spongepowered.api.entity.Entity.class),mock(org.spongepowered.api.entity.living.Human.class),mock(org.spongepowered.api.entity.player.Player.class),mock(org.spongepowered.api.entity.living.animal.Cow.class),mock(org.spongepowered.api.entity.living.animal.Pig.class)));
}

Fixed version (ground truth):
@Before public void initTest(){
  PoreTests.mockPlugin();
  world=PoreWorld.of(mock(World.class));
  when(world.getHandle().getEntities()).thenReturn(ImmutableList.of(mock(org.spongepowered.api.entity.living.player.Player.class),mock(org.spongepowered.api.entity.Entity.class),mock(org.spongepowered.api.entity.living.Human.class),mock(org.spongepowered.api.entity.living.player.Player.class),mock(org.spongepowered.api.entity.living.Living.class),mock(org.spongepowered.api.entity.living.player.Player.class),mock(org.spongepowered.api.entity.living.player.Player.class),mock(org.spongepowered.api.entity.living.Living.class),mock(org.spongepowered.api.entity.living.Living.class),mock(org.spongepowered.api.entity.Entity.class),mock(org.spongepowered.api.entity.living.Human.class),mock(org.spongepowered.api.entity.living.player.Player.class),mock(org.spongepowered.api.entity.living.animal.Cow.class),mock(org.spongepowered.api.entity.living.animal.Pig.class)));
}
Program: 34132
Project: 34132
Buggy source:
@Override public Arrow spawnArrow(Location location,Vector direction,float speed,float spread){
  checkNotNull(location,"String_Node_Str");
  checkNotNull(direction,"String_Node_Str");
  Entity spawned=spawnEntity(location,EntityType.ARROW);
  assert(spawned instanceof Arrow);
  Arrow arrow=(Arrow)spawned;
  arrow.setVelocity(VectorConverter.getUnitVector(direction).multiply(speed));
  return arrow;
}

Fixed version (ground truth):
@Override public Arrow spawnArrow(Location location,Vector direction,float speed,float spread){
}
Program: 34133
Project: 34133
Buggy source:
@Override public Item dropItem(Location location,ItemStack item){
  Optional<org.spongepowered.api.entity.Entity> created=getHandle().createEntity(EntityTypes.DROPPED_ITEM,VectorConverter.create3d(location));
  if (!created.isPresent()) {
    return null;
  }
  assert(created instanceof Item);
  org.spongepowered.api.entity.Item drop=(org.spongepowered.api.entity.Item)created;
  drop.setPickupDelay(10);
  throw new NotImplementedException();
}

Fixed version (ground truth):
@Override public Item dropItem(Location location,ItemStack item){
}
Program: 34134
Project: 34134
Buggy source:
public static EntityInteractionType of(Action action){
  if (action == Action.LEFT_CLICK_AIR) {
    return EntityInteractionType.LEFT_CLICK;
  }
 else   if (action == Action.LEFT_CLICK_BLOCK) {
    return EntityInteractionType.LEFT_CLICK;
  }
 else   if (action == Action.RIGHT_CLICK_AIR) {
    return EntityInteractionType.RIGHT_CLICK;
  }
 else   if (action == Action.RIGHT_CLICK_BLOCK) {
    return EntityInteractionType.RIGHT_CLICK;
  }
  return null;
}

Fixed version (ground truth):
public static EntityInteractionType of(Action action){
  if (action == Action.LEFT_CLICK_AIR) {
    return EntityInteractionTypes.ATTACK;
  }
 else   if (action == Action.LEFT_CLICK_BLOCK) {
    return EntityInteractionTypes.ATTACK;
  }
 else   if (action == Action.RIGHT_CLICK_AIR) {
    return EntityInteractionTypes.USE;
  }
 else   if (action == Action.RIGHT_CLICK_BLOCK) {
    return EntityInteractionTypes.USE;
  }
  return null;
}
Program: 34135
Project: 34135
Buggy source:
@Override public Block getBlock(int x,int y,int z){
  return PoreBlock.of(getHandle().getBlock(x,y,z));
}

Fixed version (ground truth):
@Override public Block getBlock(int x,int y,int z){
  return PoreBlock.of(getHandle().getFullBlock(x,y,z));
}
Program: 34136
Project: 34136
Buggy source:
@Override public float getSaturation(){
  return getHandle().getSaturation();
}

Fixed version (ground truth):
@Override public float getSaturation(){
  return (float)getHandle().getSaturation();
}
Program: 34137
Project: 34137
Buggy source:
@Override public boolean getAllowFlight(){
  return getHandle().getAllowFlight();
}

Fixed version (ground truth):
@Override public boolean getAllowFlight(){
  throw new NotImplementedException();
}
Program: 34138
Project: 34138
Buggy source:
@Override public float getExhaustion(){
  return getHandle().getHunger();
}

Fixed version (ground truth):
@Override public float getExhaustion(){
  return (float)getHandle().getExhaustion();
}
Program: 34139
Project: 34139
Buggy source:
@Override public void setAllowFlight(boolean flight){
  getHandle().setAllowFlight(flight);
}

Fixed version (ground truth):
@Override public void setAllowFlight(boolean flight){
  throw new NotImplementedException();
}
Program: 34140
Project: 34140
Buggy source:
@Override public void setExhaustion(float value){
  getHandle().setHunger(value);
}

Fixed version (ground truth):
@Override public void setExhaustion(float value){
  getHandle().setExhaustion(value);
}
Program: 34141
Project: 34141
Buggy source:
@Override public int getExperience(){
  return (int)getHandle().getExperience();
}

Fixed version (ground truth):
@Override public int getExperience(){
  return getHandle().getExperience();
}
Program: 34142
Project: 34142
Buggy source:
@Override public int getDroppedExp(){
  return (int)this.getHandle().getDroppedExperience();
}

Fixed version (ground truth):
@Override public int getDroppedExp(){
  return this.getHandle().getExp();
}
Program: 34143
Project: 34143
Buggy source:
@Override public void setDroppedExp(int exp){
  this.getHandle().setDroppedExperience(exp);
}

Fixed version (ground truth):
@Override public void setDroppedExp(int exp){
  this.getHandle().setExp(exp);
}
Program: 34144
Project: 34144
Buggy source:
@Override public void setFire(boolean fire){
  getHandle().setFlamable(fire);
}

Fixed version (ground truth):
@Override public void setFire(boolean fire){
  getHandle().setFlammable(fire);
}
Program: 34145
Project: 34145
Buggy source:
@Override public boolean getFire(){
  return this.getHandle().isFlamable();
}

Fixed version (ground truth):
@Override public boolean getFire(){
  return this.getHandle().isFlammable();
}
Program: 34146
Project: 34146
Buggy source:
@Override public InventoryHolder getHolder(){
  if (this instanceof CarriedInventory) {
    Optional<?> carrier=((CarriedInventory)this.getHandle()).getCarrier();
    if (carrier.isPresent()) {
      return PoreInventoryHolder.of((Carrier)carrier.get());
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public InventoryHolder getHolder(){
  if (this.getHandle() instanceof CarriedInventory) {
    Optional<?> carrier=((CarriedInventory)this.getHandle()).getCarrier();
    if (carrier.isPresent()) {
      return PoreInventoryHolder.of((Carrier)carrier.get());
    }
  }
  return null;
}
Program: 34147
Project: 34147
Buggy source:
@Subscribe public void onPlayerChat(final PlayerChatEvent event){
  Set<Player> players=new HashSet<Player>(PoreWorld.of(event.getPlayer().getWorld()).getPlayers());
  Bukkit.getPluginManager().callEvent(new org.bukkit.event.player.AsyncPlayerChatEvent(false,PorePlayer.of(event.getPlayer()),event.getMessage(),players){
    @Override public void setCancelled(    boolean cancelled){
      super.setCancelled(cancelled);
    }
  }
);
}

Fixed version (ground truth):
@Subscribe public void onPlayerChat(final PlayerChatEvent event){
  Set<Player> players=new HashSet<Player>(PoreWorld.of(event.getPlayer().getWorld()).getPlayers());
  Bukkit.getPluginManager().callEvent(new org.bukkit.event.player.AsyncPlayerChatEvent(false,PorePlayer.of(event.getPlayer()),event.getMessage().toLegacy(),players){
    @Override public void setCancelled(    boolean cancelled){
      super.setCancelled(cancelled);
    }
  }
);
}
Program: 34148
Project: 34148
Buggy source:
@Override public String getMessage(){
  return handle.getMessage();
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public String getMessage(){
  return handle.getMessage().toLegacy();
}
Program: 34149
Project: 34149
Buggy source:
@Subscribe public void onInitialization(PreInitializationEvent event){
  instance=this;
  logger.info("String_Node_Str");
  initializeEventHandlers();
  server=new PoreServer(event.getGame(),logger);
}

Fixed version (ground truth):
@Subscribe public void onInitialization(PreInitializationEvent event){
  instance=this;
  logger.info("String_Node_Str");
  initializeEventHandlers();
  server=new PoreServer(game,logger);
}
Program: 34150
Project: 34150
Buggy source:
private static void initializeEventHandlers(){
  getGame().getEventManager().register(getInstance(),getInstance());
  getGame().getEventManager().register(getInstance(),new BlockEventRelay());
  getGame().getEventManager().register(getInstance(),new EntityEventRelay());
  getGame().getEventManager().register(getInstance(),new PlayerEventRelay());
  getGame().getEventManager().register(getInstance(),new WorldEventRelay());
}

Fixed version (ground truth):
private static void initializeEventHandlers(){
  getGame().getEventManager().register(getInstance(),new BlockEventRelay());
  getGame().getEventManager().register(getInstance(),new EntityEventRelay());
  getGame().getEventManager().register(getInstance(),new PlayerEventRelay());
  getGame().getEventManager().register(getInstance(),new WorldEventRelay());
}
Program: 34151
Project: 34151
Buggy source:
protected PoreAmbient(Living handle){
  super(handle);
}

Fixed version (ground truth):
protected PoreAmbient(Ambient handle){
  super(handle);
}
Program: 34152
Project: 34152
Buggy source:
protected PoreWaterMob(Agent handle){
  super(handle);
}

Fixed version (ground truth):
protected PoreWaterMob(Aquatic handle){
  super(handle);
}
Program: 34153
Project: 34153
Buggy source:
@Override public Location getLocation(Location loc){
  loc.setWorld(null);
  loc.setX(getHandle().getPosition().getX());
  loc.setY(getHandle().getPosition().getX());
  loc.setZ(getHandle().getPosition().getX());
  loc.setPitch(getHandle().getVectorRotation().getX());
  loc.setYaw(getHandle().getVectorRotation().getY());
  return loc;
}

Fixed version (ground truth):
@Override public Location getLocation(Location loc){
  loc.setWorld(null);
  loc.setX(getHandle().getLocation().getPosition().getX());
  loc.setY(getHandle().getLocation().getPosition().getX());
  loc.setZ(getHandle().getLocation().getPosition().getX());
  loc.setPitch(getHandle().getRotation().getX());
  loc.setYaw(getHandle().getRotation().getY());
  return loc;
}
Program: 34154
Project: 34154
Buggy source:
@Override public boolean leaveVehicle(){
  if (getHandle().getRiding().isPresent()) {
    getHandle().dismount();
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean leaveVehicle(){
  if (getHandle().getVehicle().isPresent()) {
    getHandle().setVehicle(null);
    return true;
  }
  return false;
}
Program: 34155
Project: 34155
Buggy source:
@Override public boolean isDead(){
  return getHandle().isDead();
}

Fixed version (ground truth):
@Override public boolean isDead(){
  return getHandle().isRemoved();
}
Program: 34156
Project: 34156
Buggy source:
@Override public boolean eject(){
  if (getHandle().getRider().isPresent()) {
    final org.spongepowered.api.entity.Entity rider=getHandle().getRider().get();
    getHandle().eject();
    final PoreEntity dismounted=this;
    Pore.getGame().getEventManager().post(new EntityDismountEvent(){
      private boolean cancelled=false;
      @Override public org.spongepowered.api.entity.Entity getDismounted(){
        return dismounted.getHandle();
      }
      @Override public boolean isCancelled(){
        return cancelled;
      }
      @Override public void setCancelled(      boolean cancel){
        this.cancelled=cancel;
        if (cancel)         rider.mount(dismounted.getHandle());
 else         rider.dismount();
      }
      @Override public org.spongepowered.api.entity.Entity getEntity(){
        return rider;
      }
      @Override public Game getGame(){
        return Pore.getGame();
      }
      @Override public CallbackList getCallbacks(){
        return null;
      }
    }
);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean eject(){
  if (getHandle().getPassenger().isPresent()) {
    final org.spongepowered.api.entity.Entity rider=getHandle().getPassenger().get();
    getHandle().setPassenger(null);
    final PoreEntity dismounted=this;
    Pore.getGame().getEventManager().post(new EntityDismountEvent(){
      private boolean cancelled=false;
      @Override public org.spongepowered.api.entity.Entity getDismounted(){
        return dismounted.getHandle();
      }
      @Override public boolean isCancelled(){
        return cancelled;
      }
      @Override public void setCancelled(      boolean cancel){
        this.cancelled=cancel;
        if (cancel)         dismounted.getHandle().setPassenger(rider);
 else         dismounted.setPassenger(null);
      }
      @Override public org.spongepowered.api.entity.Entity getEntity(){
        return rider;
      }
      @Override public Game getGame(){
        return Pore.getGame();
      }
      @Override public CallbackList getCallbacks(){
        return null;
      }
    }
);
    return true;
  }
  return false;
}
Program: 34157
Project: 34157
Buggy source:
@Override public void setCancelled(boolean cancel){
  this.cancelled=cancel;
  if (cancel)   rider.mount(dismounted.getHandle());
 else   rider.dismount();
}

Fixed version (ground truth):
@Override public void setCancelled(boolean cancel){
  this.cancelled=cancel;
  if (cancel)   dismounted.getHandle().setPassenger(rider);
 else   dismounted.setPassenger(null);
}
Program: 34158
Project: 34158
Buggy source:
@Override public boolean setPassenger(final Entity passenger){
  if (!getHandle().getRider().isPresent()) {
    ((PoreEntity)passenger).getHandle().mount(getHandle());
    final PoreEntity mounted=this;
    Pore.getGame().getEventManager().post(new EntityMountEvent(){
      private boolean cancelled=false;
      @Override public org.spongepowered.api.entity.Entity getMounted(){
        return mounted.getHandle();
      }
      @Override public boolean isCancelled(){
        return cancelled;
      }
      @Override public void setCancelled(      boolean cancel){
        this.cancelled=cancel;
        if (cancel)         mounted.getHandle().eject();
 else         ((PoreEntity)passenger).getHandle().mount(getHandle());
      }
      @Override public org.spongepowered.api.entity.Entity getEntity(){
        return ((PoreEntity)passenger).getHandle();
      }
      @Override public Game getGame(){
        return Pore.getGame();
      }
      @Override public CallbackList getCallbacks(){
        return null;
      }
    }
);
    return true;
  }
 else   if (passenger == null) {
    getHandle().eject();
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean setPassenger(final Entity passenger){
  if (!getHandle().getPassenger().isPresent()) {
    getHandle().setPassenger(((PoreEntity)passenger).getHandle());
    final PoreEntity mounted=this;
    Pore.getGame().getEventManager().post(new EntityMountEvent(){
      private boolean cancelled=false;
      @Override public org.spongepowered.api.entity.Entity getVehicle(){
        return mounted.getHandle();
      }
      @Override public boolean isCancelled(){
        return cancelled;
      }
      @Override public void setCancelled(      boolean cancel){
        this.cancelled=cancel;
        if (cancel)         mounted.getHandle().setPassenger(null);
 else         mounted.getHandle().setPassenger(((PoreEntity)passenger).getHandle());
      }
      @Override public org.spongepowered.api.entity.Entity getEntity(){
        return ((PoreEntity)passenger).getHandle();
      }
      @Override public Game getGame(){
        return Pore.getGame();
      }
      @Override public CallbackList getCallbacks(){
        return null;
      }
    }
);
    return true;
  }
 else   if (passenger == null) {
    getHandle().setPassenger(null);
    return true;
  }
  return false;
}
Program: 34159
Project: 34159
Buggy source:
@Override public Entity getVehicle(){
  return getHandle().getRiding().isPresent() ? PoreEntity.of(getHandle().getRiding().get()) : null;
}

Fixed version (ground truth):
@Override public Entity getVehicle(){
  return getHandle().getVehicle().isPresent() ? PoreEntity.of(getHandle().getVehicle().get()) : null;
}
Program: 34160
Project: 34160
Buggy source:
@Override public boolean isInsideVehicle(){
  return getHandle().getRiding().isPresent();
}

Fixed version (ground truth):
@Override public boolean isInsideVehicle(){
  return getHandle().getVehicle().isPresent();
}
Program: 34161
Project: 34161
Buggy source:
@Override public boolean isValid(){
  return getHandle().isValid();
}

Fixed version (ground truth):
@Override public boolean isValid(){
  return getHandle().isLoaded();
}
Program: 34162
Project: 34162
Buggy source:
@Override public boolean isEmpty(){
  return !getHandle().getRider().isPresent();
}

Fixed version (ground truth):
@Override public boolean isEmpty(){
  return !getHandle().getPassenger().isPresent();
}
Program: 34163
Project: 34163
Buggy source:
@Override public Entity getPassenger(){
  return getHandle().getRider().isPresent() ? PoreEntity.of(getHandle().getRider().get()) : null;
}

Fixed version (ground truth):
@Override public Entity getPassenger(){
  return getHandle().getPassenger().isPresent() ? PoreEntity.of(getHandle().getPassenger().get()) : null;
}
Program: 34164
Project: 34164
Buggy source:
public static EulerDirection of(EulerAngle angle){
  throw new NotImplementedException();
}

Fixed version (ground truth):
public static Vector3f of(EulerAngle angle){
  return new Vector3f(angle.getX(),angle.getY(),angle.getZ());
}
Program: 34165
Project: 34165
Buggy source:
public PoreBeacon(BlockLoc spongeBlock){
  super(spongeBlock);
}

Fixed version (ground truth):
protected PoreBeacon(org.spongepowered.api.block.BlockState handle){
  super(handle);
}
Program: 34166
Project: 34166
Buggy source:
/** 
 * Returns a Pore wrapper for the given handle. If one exists, it will be retrieved; otherwise, a new wrapper instance will be created.
 * @param handle The Sponge object to wrap.
 * @return A Pore wrapper for the given Sponge object.
 */
public static PoreBlock of(BlockLoc handle){
  return getConverter().apply(handle);
}

Fixed version (ground truth):
/** 
 * Returns a Pore wrapper for the given handle. If one exists, it will be retrieved; otherwise, a new wrapper instance will be created.
 * @param handle The Sponge object to wrap.
 * @return A Pore wrapper for the given Sponge object.
 */
public static PoreBlock of(BlockLoc handle){
  return converter.apply(handle);
}
Program: 34167
Project: 34167
Buggy source:
/** 
 * Returns a Pore wrapper for the given handle. If one exists, it will be retrieved; otherwise, a new wrapper instance will be created.
 * @param handle The Sponge object to wrap.
 * @return A Pore wrapper for the given Sponge object.
 */
public static PoreBlockState of(org.spongepowered.api.block.BlockState handle){
  return getConverter().apply(handle);
}

Fixed version (ground truth):
/** 
 * Returns a Pore wrapper for the given handle. If one exists, it will be retrieved; otherwise, a new wrapper instance will be created.
 * @param handle The Sponge object to wrap.
 * @return A Pore wrapper for the given Sponge object.
 */
public static PoreBlockState of(org.spongepowered.api.block.BlockState handle){
  return converter.apply(handle);
}
Program: 34168
Project: 34168
Buggy source:
private PoreBlockState(org.spongepowered.api.block.BlockState handle){
  super(handle);
}

Fixed version (ground truth):
protected PoreBlockState(org.spongepowered.api.block.BlockState handle){
  super(handle);
}
Program: 34169
Project: 34169
Buggy source:
public PoreBrewingStand(BlockLoc spongeBlock){
  super(spongeBlock);
}

Fixed version (ground truth):
protected PoreBrewingStand(org.spongepowered.api.block.BlockState handle){
  super(handle);
}
Program: 34170
Project: 34170
Buggy source:
public PoreChest(BlockLoc spongeBlock){
  super(spongeBlock);
}

Fixed version (ground truth):
protected PoreChest(org.spongepowered.api.block.BlockState handle){
  super(handle);
}
Program: 34171
Project: 34171
Buggy source:
public PoreCommandBlock(BlockLoc spongeBlock){
  super(spongeBlock);
}

Fixed version (ground truth):
protected PoreCommandBlock(org.spongepowered.api.block.BlockState handle){
  super(handle);
}
Program: 34172
Project: 34172
Buggy source:
public PoreCreatureSpawner(BlockLoc spongeBlock){
  super(spongeBlock);
}

Fixed version (ground truth):
protected PoreCreatureSpawner(org.spongepowered.api.block.BlockState handle){
  super(handle);
}
Program: 34173
Project: 34173
Buggy source:
public PoreDispenser(BlockLoc spongeBlock){
  super(spongeBlock);
}

Fixed version (ground truth):
protected PoreDispenser(org.spongepowered.api.block.BlockState handle){
  super(handle);
}
Program: 34174
Project: 34174
Buggy source:
public PoreDropper(BlockLoc spongeBlock){
  super(spongeBlock);
}

Fixed version (ground truth):
protected PoreDropper(org.spongepowered.api.block.BlockState handle){
  super(handle);
}
Program: 34175
Project: 34175
Buggy source:
public PoreServerCommandSender(){
}

Fixed version (ground truth):
protected PoreServerCommandSender(Subject handle){
  super(handle);
}
Program: 34176
Project: 34176
Buggy source:
private PorePermissible(Subject handle){
  super(handle);
}

Fixed version (ground truth):
protected PorePermissible(Subject handle){
  super(handle);
}
Program: 34177
Project: 34177
Buggy source:
public boolean showPopupHook(){
  return true;
}

Fixed version (ground truth):
/** 
 * This method should be implemented appropriately by subclasses
 * @param event
 * @return boolean
 */
public boolean showPopupHook(MouseEvent event){
  return true;
}
Program: 34178
Project: 34178
Buggy source:
private void showMenuIfPopupTrigger(MouseEvent e){
  if (e.isPopupTrigger() && showPopupHook()) {
    popup.show(component,e.getX() + 3,e.getY() + 3);
  }
}

Fixed version (ground truth):
private void showMenuIfPopupTrigger(MouseEvent e){
  if (e.isPopupTrigger() && showPopupHook(e)) {
    popup.show(component,e.getX() + 3,e.getY() + 3);
  }
}
Program: 34179
Project: 34179
Buggy source:
@Override public boolean showPopupHook(){
  TreeSelectionModel selectionModel=((PdfTree)component).getSelectionModel();
  TreePath[] paths=selectionModel.getSelectionPaths();
  if (paths.length < 1) {
    return false;
  }
  PdfObjectTreeNode lastPath=((PdfObjectTreeNode)paths[0].getLastPathComponent());
  if (!lastPath.isStream()) {
    return false;
  }
  PRStream stream=(PRStream)lastPath.getPdfObject();
  return stream.get(PdfName.SUBTYPE) != PdfName.IMAGE;
}

Fixed version (ground truth):
@Override public boolean showPopupHook(MouseEvent event){
  PdfTree tree=(PdfTree)component;
  int row=tree.getClosestRowForLocation(event.getX(),event.getY());
  tree.setSelectionRow(row);
  TreeSelectionModel selectionModel=((PdfTree)component).getSelectionModel();
  TreePath[] paths=selectionModel.getSelectionPaths();
  if (paths == null || paths.length < 1) {
    return false;
  }
  PdfObjectTreeNode lastPath=((PdfObjectTreeNode)paths[0].getLastPathComponent());
  if (!lastPath.isStream()) {
    return false;
  }
  PRStream stream=(PRStream)lastPath.getPdfObject();
  return stream.get(PdfName.SUBTYPE) != PdfName.IMAGE;
}
Program: 34180
Project: 34180
Buggy source:
/** 
 * @see javax.swing.JTable#valueChanged(javax.swing.event.ListSelectionEvent)
 */
@Override public void valueChanged(ListSelectionEvent evt){
  if (evt != null)   super.valueChanged(evt);
  if (controller == null)   return;
  if (getRowCount() > 0) {
    controller.selectNode(list.get(getSelectedRow()));
    if (listener != null)     listener.gotoPage(getSelectedRow() + 1);
  }
}

Fixed version (ground truth):
/** 
 * @see javax.swing.JTable#valueChanged(javax.swing.event.ListSelectionEvent)
 */
@Override public void valueChanged(ListSelectionEvent evt){
  if (evt != null)   super.valueChanged(evt);
  if (controller == null)   return;
  if (getRowCount() > 0) {
    int selectedRow=getSelectedRow();
    if (selectedRow >= 0) {
      controller.selectNode(list.get(selectedRow));
      if (listener != null)       listener.gotoPage(getSelectedRow() + 1);
    }
  }
}