nus-yam/ex-repair huggingface dataset:
Program: 51642
Project: 51642
Buggy source:
public void setInventoryWith(Inventory inventory,StockItem item,Player player){
  int i=0;
  for (  Integer amount : item.getAmounts()) {
    ItemStack chk=setLore(createCraftItem(item),getPriceLore(item,i,"String_Node_Str",pattern,player));
    chk.addEnchantments(item.getItemStack().getEnchantments());
    chk.setAmount(amount);
    if (item.getLimitSystem().checkLimit("String_Node_Str",i))     inventory.setItem(i++,chk);
  }
  inventory.setItem(stockSize - 1,itemsConfig.getItemManagement(7));
}

Fixed version (ground truth):
public void setInventoryWith(Inventory inventory,StockItem item,Player player){
  int i=0;
  for (  Integer amount : item.getAmounts()) {
    ItemStack chk=setLore(item.getItemStack(),getPriceLore(item,i,"String_Node_Str",pattern,player));
    chk.addEnchantments(item.getItemStack().getEnchantments());
    chk.setAmount(amount);
    if (item.getLimitSystem().checkLimit("String_Node_Str",i))     inventory.setItem(i++,chk);
  }
  inventory.setItem(stockSize - 1,itemsConfig.getItemManagement(7));
}
Program: 51643
Project: 51643
Buggy source:
@Override public Inventory getInventory(){
  Inventory inventory=Bukkit.createInventory(this,stockSize,name);
  for (  StockItem item : stock.get("String_Node_Str")) {
    ItemStack chk=setLore(createCraftItem(item),getPriceLore(item,0,"String_Node_Str",pattern,null));
    chk.addEnchantments(item.getItemStack().getEnchantments());
    if (item.getSlot() < 0)     item.setSlot(inventory.firstEmpty());
    inventory.setItem(item.getSlot(),chk);
  }
  if (!stock.get("String_Node_Str").isEmpty())   inventory.setItem(stockSize - 1,itemsConfig.getItemManagement("String_Node_Str"));
  return inventory;
}

Fixed version (ground truth):
@Override public Inventory getInventory(){
  Inventory inventory=Bukkit.createInventory(this,stockSize,name);
  for (  StockItem item : stock.get("String_Node_Str")) {
    ItemStack chk=setLore(item.getItemStack(),getPriceLore(item,0,"String_Node_Str",pattern,null));
    chk.addEnchantments(item.getItemStack().getEnchantments());
    if (item.getSlot() < 0)     item.setSlot(inventory.firstEmpty());
    inventory.setItem(item.getSlot(),chk);
  }
  if (!stock.get("String_Node_Str").isEmpty())   inventory.setItem(stockSize - 1,itemsConfig.getItemManagement("String_Node_Str"));
  return inventory;
}
Program: 51644
Project: 51644
Buggy source:
public static ItemStack setLore(ItemStack cis,List<String> lore){
  ItemMeta meta=Bukkit.getItemFactory().getItemMeta(cis.getType());
  List<String> list=new ArrayList<String>();
  for (  String s : lore)   list.add(s.replace('^','�'));
  meta.setLore(list);
  Map<String,Object> map=cis.serialize();
  map.put("String_Node_Str",meta);
  cis.setItemMeta(ItemStack.deserialize(map).getItemMeta());
  return ItemStack.deserialize(map);
}

Fixed version (ground truth):
public static ItemStack setLore(ItemStack cis,List<String> lore){
  ItemMeta meta=Bukkit.getItemFactory().getItemMeta(cis.getType());
  List<String> list=new ArrayList<String>();
  for (  String s : lore)   list.add(s.replace('^','�'));
  meta.setLore(list);
  meta.setDisplayName(NBTTagEditor.getName(cis));
  Map<String,Object> map=cis.serialize();
  map.put("String_Node_Str",meta);
  cis.setItemMeta(ItemStack.deserialize(map).getItemMeta());
  return ItemStack.deserialize(map);
}
Program: 51645
Project: 51645
Buggy source:
public Inventory inventoryView(Inventory inventory,TraderStatus s,Player player,String type){
  if (!s.isManaging()) {
    for (    StockItem item : stock.get(s.toString())) {
      ItemStack chk=setLore(createCraftItem(item),getPriceLore(item,0,s.toString(),pattern,player));
      chk.addEnchantments(item.getItemStack().getEnchantments());
      if (item.getSlot() < 0)       item.setSlot(inventory.firstEmpty());
      inventory.setItem(item.getSlot(),chk);
    }
    if (!stock.get(opositeStock(s.toString())).isEmpty())     inventory.setItem(stockSize - 1,itemsConfig.getItemManagement(opositeStock(s.toString())));
  }
 else {
    for (    StockItem item : stock.get(s.toString())) {
      ItemStack chk=setLore(createCraftItem(item),getLore(type,item,s.toString(),pattern,player));
      chk.addEnchantments(item.getItemStack().getEnchantments());
      if (item.getSlot() < 0)       item.setSlot(inventory.firstEmpty());
      inventory.setItem(item.getSlot(),chk);
    }
    inventory.setItem(stockSize - 3,itemsConfig.getItemManagement(4));
    inventory.setItem(stockSize - 2,itemsConfig.getItemManagement(2));
    inventory.setItem(stockSize - 1,itemsConfig.getItemManagement(opositeStock(s.toString())));
  }
  return inventory;
}

Fixed version (ground truth):
public Inventory inventoryView(Inventory inventory,TraderStatus s,Player player,String type){
  if (!s.isManaging()) {
    for (    StockItem item : stock.get(s.toString())) {
      ItemStack chk=setLore(item.getItemStack(),getPriceLore(item,0,s.toString(),pattern,player));
      chk.addEnchantments(item.getItemStack().getEnchantments());
      if (item.getSlot() < 0)       item.setSlot(inventory.firstEmpty());
      inventory.setItem(item.getSlot(),chk);
    }
    if (!stock.get(opositeStock(s.toString())).isEmpty())     inventory.setItem(stockSize - 1,itemsConfig.getItemManagement(opositeStock(s.toString())));
  }
 else {
    for (    StockItem item : stock.get(s.toString())) {
      ItemStack chk=setLore(item.getItemStack(),getLore(type,item,s.toString(),pattern,player));
      chk.addEnchantments(item.getItemStack().getEnchantments());
      if (item.getSlot() < 0)       item.setSlot(inventory.firstEmpty());
      inventory.setItem(item.getSlot(),chk);
    }
    inventory.setItem(stockSize - 3,itemsConfig.getItemManagement(4));
    inventory.setItem(stockSize - 2,itemsConfig.getItemManagement(2));
    inventory.setItem(stockSize - 1,itemsConfig.getItemManagement(opositeStock(s.toString())));
  }
  return inventory;
}
Program: 51646
Project: 51646
Buggy source:
public final boolean addAmountToInventory(int amount){
  PlayerInventory inventory=player.getInventory();
  int amountToAdd=amount;
  for (  ItemStack item : inventory.all(selectedItem.getItemStack().getType()).values()) {
    if (item.getDurability() == selectedItem.getItemStack().getDurability()) {
      if (item.getAmount() + amountToAdd <= selectedItem.getItemStack().getMaxStackSize()) {
        item.setAmount(item.getAmount() + amountToAdd);
        return true;
      }
      if (item.getAmount() < selectedItem.getItemStack().getMaxStackSize()) {
        amountToAdd=(item.getAmount() + amountToAdd) % selectedItem.getItemStack().getMaxStackSize();
        item.setAmount(selectedItem.getItemStack().getMaxStackSize());
      }
      if (amountToAdd <= 0)       return true;
    }
  }
  if (inventory.firstEmpty() < inventory.getSize() && inventory.firstEmpty() >= 0) {
    ItemStack is=selectedItem.getItemStack().clone();
    is.setAmount(amountToAdd);
    inventory.setItem(inventory.firstEmpty(),is);
    return true;
  }
  return false;
}

Fixed version (ground truth):
public final boolean addAmountToInventory(int amount){
  PlayerInventory inventory=player.getInventory();
  int amountToAdd=amount;
  for (  ItemStack item : inventory.all(selectedItem.getItemStack().getType()).values()) {
    if (item.getDurability() == selectedItem.getItemStack().getDurability()) {
      if (NBTTagEditor.getName(item).equals(selectedItem.getName())) {
        if (item.getAmount() + amountToAdd <= selectedItem.getItemStack().getMaxStackSize()) {
          item.setAmount(item.getAmount() + amountToAdd);
          return true;
        }
        if (item.getAmount() < selectedItem.getItemStack().getMaxStackSize()) {
          amountToAdd=(item.getAmount() + amountToAdd) % selectedItem.getItemStack().getMaxStackSize();
          item.setAmount(selectedItem.getItemStack().getMaxStackSize());
        }
        if (amountToAdd <= 0)         return true;
      }
    }
  }
  if (inventory.firstEmpty() < inventory.getSize() && inventory.firstEmpty() >= 0) {
    ItemStack is=selectedItem.getItemStack().clone();
    is.setAmount(amountToAdd);
    NBTTagEditor.removeDescription(is);
    StockItem it=this.getStock().getItem(is,TraderStatus.BUY,true,false);
    if (it != null) {
      int scale=is.getAmount() / it.getAmount();
      DecimalFormat f=new DecimalFormat("String_Node_Str");
      List<String> lore=new ArrayList<String>();
      ;
      for (      String l : itemsConfig.getPriceLore("String_Node_Str"))       lore.add(l.replace("String_Node_Str",f.format(it.getPrice()) + "String_Node_Str").replace("String_Node_Str",f.format(it.getPrice() * scale) + "String_Node_Str"));
      if (scale > 0)       NBTTagEditor.addDescription(is,lore);
    }
    inventory.setItem(inventory.firstEmpty(),is);
    return true;
  }
  return false;
}
Program: 51647
Project: 51647
Buggy source:
public final boolean inventoryHasPlaceAmount(int amount){
  PlayerInventory inventory=player.getInventory();
  int amountToAdd=amount;
  for (  ItemStack item : inventory.all(selectedItem.getItemStack().getType()).values()) {
    if (item.getDurability() == selectedItem.getItemStack().getDurability()) {
      if (item.getAmount() + amountToAdd <= selectedItem.getItemStack().getMaxStackSize())       return true;
      if (item.getAmount() < 64) {
        amountToAdd=(item.getAmount() + amountToAdd) % 64;
      }
      if (amountToAdd <= 0)       return true;
    }
  }
  if (inventory.firstEmpty() < inventory.getSize() && inventory.firstEmpty() >= 0) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
public final boolean inventoryHasPlaceAmount(int amount){
  PlayerInventory inventory=player.getInventory();
  int amountToAdd=amount;
  for (  ItemStack item : inventory.all(selectedItem.getItemStack().getType()).values()) {
    if (item.getDurability() == selectedItem.getItemStack().getDurability()) {
      if (NBTTagEditor.getName(item).equals(selectedItem.getName())) {
        if (item.getAmount() + amountToAdd <= selectedItem.getItemStack().getMaxStackSize())         return true;
        if (item.getAmount() < 64) {
          amountToAdd=(item.getAmount() + amountToAdd) % 64;
        }
        if (amountToAdd <= 0)         return true;
      }
    }
  }
  if (inventory.firstEmpty() < inventory.getSize() && inventory.firstEmpty() >= 0) {
    return true;
  }
  return false;
}
Program: 51650
Project: 51650
Buggy source:
@Override public boolean buyTransaction(Player p,double price){
  return getTraderConfig().transaction(getSelectedMarketItem().getItemOwner(),p.getName(),price);
}

Fixed version (ground truth):
@Override public boolean buyTransaction(Player p,double price){
  return getTraderConfig().transaction(getSelectedMarketItem().getItemOwner(),p.getName(),false,price);
}
Program: 51652
Project: 51652
Buggy source:
@Override public boolean sellTransaction(Player p,double price,ItemStack item){
  return getTraderConfig().transaction(p.getName(),getSelectedMarketItem().getItemOwner(),price * ((int)item.getAmount() / getSelectedItem().getAmount()));
}

Fixed version (ground truth):
@Override public boolean sellTransaction(Player p,double price,ItemStack item){
  return getTraderConfig().transaction(p.getName(),getSelectedMarketItem().getItemOwner(),true,price * ((int)item.getAmount() / getSelectedItem().getAmount()));
}
Program: 51653
Project: 51653
Buggy source:
public StockItem getItem(ItemStack itemStack,TraderStatus status,boolean dura,boolean amount){
  boolean equal=false;
  if (status.equals(TraderStatus.MANAGE_BUY) || status.equals(TraderStatus.BUY)) {
    for (    StockItem item : buyStock) {
      equal=false;
      if (itemStack.getType().equals(item.getItemStack().getType()) && itemStack.getData().equals(item.getItemStack().getData())) {
        equal=true;
        if (dura)         equal=itemStack.getDurability() >= item.getItemStack().getDurability();
        if (amount && equal)         equal=itemStack.getAmount() >= item.getItemStack().getAmount();
        if (equal)         return item;
      }
    }
  }
  if (status.equals(TraderStatus.MANAGE_SELL) || status.equals(TraderStatus.SELL)) {
    for (    StockItem item : sellStock) {
      equal=false;
      if (itemStack.getType().equals(item.getItemStack().getType()) && itemStack.getData().equals(item.getItemStack().getData())) {
        equal=true;
        if (dura)         equal=itemStack.getDurability() >= item.getItemStack().getDurability();
        if (amount && equal)         equal=itemStack.getAmount() >= item.getItemStack().getAmount();
        if (equal)         return item;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public StockItem getItem(ItemStack itemStack,TraderStatus status,boolean dura,boolean amount){
  boolean equal=false;
  if (status.equals(TraderStatus.MANAGE_BUY) || status.equals(TraderStatus.BUY)) {
    for (    StockItem item : buyStock) {
      equal=false;
      if (itemStack.getType().equals(item.getItemStack().getType())) {
        equal=true;
        if (dura)         equal=itemStack.getDurability() <= item.getItemStack().getDurability();
 else         equal=itemStack.getData().equals(item.getItemStack().getData());
        if (amount && equal)         equal=itemStack.getAmount() >= item.getItemStack().getAmount();
        if (equal)         return item;
      }
    }
  }
  if (status.equals(TraderStatus.MANAGE_SELL) || status.equals(TraderStatus.SELL)) {
    for (    StockItem item : sellStock) {
      equal=false;
      if (itemStack.getType().equals(item.getItemStack().getType()) && itemStack.getData().equals(item.getItemStack().getData())) {
        equal=true;
        if (dura)         equal=itemStack.getDurability() >= item.getItemStack().getDurability();
        if (amount && equal)         equal=itemStack.getAmount() >= item.getItemStack().getAmount();
        if (equal)         return item;
      }
    }
  }
  return null;
}
Program: 51654
Project: 51654
Buggy source:
public boolean buyTransaction(Player pBuying,double price){
  return transaction(owner,pBuying.getName(),price);
}

Fixed version (ground truth):
public boolean buyTransaction(Player pBuying,double price){
  return transaction(owner,pBuying.getName(),false,price);
}
Program: 51655
Project: 51655
Buggy source:
public boolean sellTransaction(Player pSelling,double price){
  return transaction(pSelling.getName(),owner,price);
}

Fixed version (ground truth):
public boolean sellTransaction(Player pSelling,double price){
  return transaction(pSelling.getName(),owner,true,price);
}
Program: 51656
Project: 51656
Buggy source:
public boolean transaction(String pSelling,String pBuying,final double price){
  if (w.withdraw(pBuying,price,false)) {
    w.deposit(pSelling,price,true);
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean transaction(String pSelling,String pBuying,boolean isOwner,final double price){
  if (w.withdraw(pBuying,price,isOwner)) {
    w.deposit(pSelling,price,!isOwner);
    return true;
  }
  return false;
}
Program: 51657
Project: 51657
Buggy source:
public Inventory inventoryView(int size,String name){
  Inventory view=Bukkit.createInventory(this,size,name);
  for (  StockItem item : sellStock) {
    ItemStack chk=new ItemStack(item.getItemStack().getType(),item.getItemStack().getAmount(),item.getItemStack().getDurability());
    chk.addEnchantments(item.getItemStack().getEnchantments());
    if (item.getSlot() < 0)     item.setSlot(view.firstEmpty());
    view.setItem(item.getSlot(),chk);
  }
  if (!buyStock.isEmpty())   view.setItem(view.getSize() - 1,config.getItemManagement(1));
  return view;
}

Fixed version (ground truth):
public Inventory inventoryView(int size,String name){
  Inventory view=Bukkit.createInventory(this,size,name);
  for (  StockItem item : sellStock) {
    ItemStack chk=new ItemStack(item.getItemStack().getType(),item.getItemStack().getAmount(),item.getItemStack().getDurability());
    chk.addEnchantments(item.getItemStack().getEnchantments());
    if (item.getSlot() < 0 || getItem(item.getSlot(),TraderStatus.SELL) != null)     item.setSlot(view.firstEmpty());
    view.setItem(item.getSlot(),chk);
  }
  if (!buyStock.isEmpty())   view.setItem(view.getSize() - 1,config.getItemManagement(1));
  return view;
}
Program: 51658
Project: 51658
Buggy source:
@Override public Inventory getInventory(){
  Inventory inv=Bukkit.createInventory(this,size,"String_Node_Str");
  for (  StockItem item : sellStock)   inv.addItem(item.getItemStack());
  return inv;
}

Fixed version (ground truth):
@Override public Inventory getInventory(){
  Inventory inv=Bukkit.createInventory(this,size,"String_Node_Str");
  for (  StockItem item : sellStock) {
    if (item.getSlot() < 0 || getItem(item.getSlot(),TraderStatus.SELL) != null)     item.setSlot(inv.firstEmpty());
    inv.setItem(item.getSlot(),item.getItemStack());
  }
  return inv;
}
Program: 51663
Project: 51663
Buggy source:
public final void switchInventory(StockItem item){
  inventory.clear();
  InventoryTrait.setInventoryWith(inventory,item);
  selectedItem=item;
}

Fixed version (ground truth):
public final void switchInventory(StockItem item){
  inventory.clear();
  if (TraderStatus.hasManageMode(traderStatus))   InventoryTrait.setManagerInventoryWith(inventory,item);
 else   InventoryTrait.setInventoryWith(inventory,item);
  selectedItem=item;
}
Program: 51664
Project: 51664
Buggy source:
@Override public void onLoad(){
  info("String_Node_Str" + getDescription().getVersion());
  saveDefaultConfig();
  stdConfig=getConfig();
  itemConfig=new ItemsConfig(stdConfig);
  instance=this;
  info("String_Node_Str" + getDescription().getVersion());
}

Fixed version (ground truth):
@Override public void onLoad(){
  saveDefaultConfig();
  stdConfig=getConfig();
  itemConfig=new ItemsConfig(stdConfig);
  instance=this;
}
Program: 51666
Project: 51666
Buggy source:
@Override public void load(DataKey data) throws NPCLoadException {
  if (data.keyExists("String_Node_Str")) {
    type=TraderType.getTypeByName(data.getString("String_Node_Str"));
  }
  if (type.equals(TraderType.PLAYER_BANK)) {
    this.bankTrait.load(data);
  }
 else {
    this.traderTrait.load(data);
    this.inventoryTrait.load(data);
  }
}

Fixed version (ground truth):
@Override public void load(DataKey data) throws NPCLoadException {
  if (data.keyExists("String_Node_Str")) {
    type=TraderType.getTypeByName(data.getString("String_Node_Str"));
    traderTrait.setTraderType(type);
  }
  if (type.equals(TraderType.PLAYER_BANK)) {
    this.bankTrait.load(data);
  }
 else {
    this.traderTrait.load(data);
    this.inventoryTrait.load(data);
  }
}
Program: 51667
Project: 51667
Buggy source:
public boolean setType(Player player,Trader trader,String typeString){
  if (!permsManager.has(player,"String_Node_Str" + typeString)) {
    player.sendMessage(locale.getLocaleString("String_Node_Str"));
    return true;
  }
  TraderType type=TraderType.getTypeByName(typeString);
  if (type == null) {
    player.sendMessage(locale.getLocaleString("String_Node_Str").replace("String_Node_Str",trader.getTraderConfig().getTraderType().toString()));
  }
 else {
    trader.getTraderConfig().setTraderType(type);
    player.sendMessage(locale.getLocaleString("String_Node_Str").replace("String_Node_Str",typeString));
  }
  return true;
}

Fixed version (ground truth):
public boolean setType(Player player,Trader trader,String typeString){
  if (!permsManager.has(player,"String_Node_Str" + typeString)) {
    player.sendMessage(locale.getLocaleString("String_Node_Str"));
    return true;
  }
  TraderType type=TraderType.getTypeByName(typeString);
  if (type == null) {
    player.sendMessage(locale.getLocaleString("String_Node_Str").replace("String_Node_Str",trader.getTraderConfig().getTraderType().toString()));
  }
 else {
    trader.getTraderConfig().setTraderType(type);
    trader.getNpc().getTrait(TraderCharacterTrait.class).setTraderType(type);
    player.sendMessage(locale.getLocaleString("String_Node_Str").replace("String_Node_Str",typeString));
  }
  return true;
}
Program: 51674
Project: 51674
Buggy source:
public boolean reachedLimitWith(int a){
  return amount + a >= limit;
}

Fixed version (ground truth):
public boolean reachedLimitWith(int a){
  if (limit <= 0)   return false;
  return amount + a >= limit;
}
Program: 51676
Project: 51676
Buggy source:
public final boolean addSelectedToInventory(Player player,int slot){
  PlayerInventory inventory=player.getInventory();
  int amountToAdd=selectedItem.getAmount(slot);
  for (  ItemStack item : inventory.all(selectedItem.getItemStack().getType()).values()) {
    if (item.getAmount() + amountToAdd <= selectedItem.getItemStack().getMaxStackSize()) {
      item.setAmount(item.getAmount() + amountToAdd);
      return true;
    }
    if (item.getAmount() < 64) {
      amountToAdd=(item.getAmount() + amountToAdd) % 64;
      item.setAmount(64);
    }
    if (amountToAdd <= 0)     return true;
  }
  if (inventory.firstEmpty() < inventory.getSize() && inventory.firstEmpty() >= 0) {
    ItemStack is=selectedItem.getItemStack(slot).clone();
    is.setAmount(amountToAdd);
    inventory.setItem(inventory.firstEmpty(),is);
    return true;
  }
  return false;
}

Fixed version (ground truth):
public final boolean addSelectedToInventory(Player player,int slot){
  PlayerInventory inventory=player.getInventory();
  int amountToAdd=selectedItem.getAmount(slot);
  for (  ItemStack item : inventory.all(selectedItem.getItemStack().getType()).values()) {
    if (item.getDurability() == selectedItem.getItemStack().getDurability()) {
      if (item.getAmount() + amountToAdd <= selectedItem.getItemStack().getMaxStackSize()) {
        item.setAmount(item.getAmount() + amountToAdd);
        return true;
      }
      if (item.getAmount() < 64) {
        amountToAdd=(item.getAmount() + amountToAdd) % 64;
        item.setAmount(64);
      }
      if (amountToAdd <= 0)       return true;
    }
  }
  if (inventory.firstEmpty() < inventory.getSize() && inventory.firstEmpty() >= 0) {
    ItemStack is=selectedItem.getItemStack(slot).clone();
    is.setAmount(amountToAdd);
    inventory.setItem(inventory.firstEmpty(),is);
    return true;
  }
  return false;
}
Program: 51677
Project: 51677
Buggy source:
@Override public void onSpawn(){
}

Fixed version (ground truth):
@Override public void onSpawn(){
  if (npc.hasTrait(TraderCharacterTrait.class))   CitizensTrader.getTraderManager().addTraderNpc(npc);
}
Program: 51678
Project: 51678
Buggy source:
private void setTraderType(Player p,String type){
  if (type != null && (type.equals("String_Node_Str") || type.equals("String_Node_Str"))) {
    Trader trader=this.traderManager.getOngoingTrades(p.getName());
    if (trader.getTraderConfig().getTraderType().toString().equals(type))     return;
    trader.getTraderConfig().setTraderType(TraderType.getTypeByName(type));
    p.sendMessage(ChatColor.RED + "String_Node_Str" + type);
  }
 else {
    p.sendMessage(ChatColor.RED + "String_Node_Str");
  }
}

Fixed version (ground truth):
private void setTraderType(Player p,String type){
  if (type != null && (type.equals("String_Node_Str") || type.equals("String_Node_Str"))) {
    Trader trader=this.traderManager.getOngoingTrades(p.getName());
    if (trader == null)     return;
    if (trader.getTraderConfig().getTraderType().toString().equals(type))     return;
    trader.getTraderConfig().setTraderType(TraderType.getTypeByName(type));
    p.sendMessage(ChatColor.RED + "String_Node_Str" + type);
  }
 else {
    p.sendMessage(ChatColor.RED + "String_Node_Str");
  }
}
Program: 51679
Project: 51679
Buggy source:
@EventHandler public void onInventoryClick(InventoryClickEvent event){
  if (!(event.getWhoClicked() instanceof Player))   return;
  Player p=(Player)event.getWhoClicked();
  if (ongoingTrades.containsKey(p.getName())) {
    if (event.getRawSlot() < 0) {
      event.setCancelled(true);
      return;
    }
    if (TraderStatus.hasManageMode(ongoingTrades.get(p.getName()).getTraderStatus())) {
      if (ongoingTrades.get(p.getName()).equalsTraderStatus(TraderStatus.PLAYER_MANAGE))       ongoingTrades.get(p.getName()).setTraderStatus(TraderStatus.PLAYER_MANAGE_SELL);
      ongoingTrades.get(p.getName()).managerMode(event);
      System.out.print(event.isCancelled());
    }
 else {
      if (config.getMode().equals("String_Node_Str"))       ongoingTrades.get(p.getName()).secureMode(event);
      if (config.getMode().equals("String_Node_Str"))       ongoingTrades.get(p.getName()).simpleMode(event);
    }
  }
}

Fixed version (ground truth):
@EventHandler public void onInventoryClick(InventoryClickEvent event){
  if (!(event.getWhoClicked() instanceof Player))   return;
  Player p=(Player)event.getWhoClicked();
  if (ongoingTrades.containsKey(p.getName())) {
    if (event.getRawSlot() < 0) {
      event.setCancelled(true);
      return;
    }
    if (TraderStatus.hasManageMode(ongoingTrades.get(p.getName()).getTraderStatus())) {
      if (ongoingTrades.get(p.getName()).equalsTraderStatus(TraderStatus.PLAYER_MANAGE))       ongoingTrades.get(p.getName()).setTraderStatus(TraderStatus.PLAYER_MANAGE_SELL);
      ongoingTrades.get(p.getName()).managerMode(event);
    }
 else {
      if (config.getMode().equals("String_Node_Str"))       ongoingTrades.get(p.getName()).secureMode(event);
      if (config.getMode().equals("String_Node_Str"))       ongoingTrades.get(p.getName()).simpleMode(event);
    }
  }
}
Program: 51686
Project: 51686
Buggy source:
@Override public String toString(){
  return limit + "String_Node_Str" + amount+ "String_Node_Str"+ timeout;
}

Fixed version (ground truth):
@Override public String toString(){
  return limit + "String_Node_Str" + amount+ "String_Node_Str"+ (timeout / 1000);
}
Program: 51690
Project: 51690
Buggy source:
public final Trader selectItem(int slot,TraderStatus status){
  selectedItem=traderStock.getItem(slot,status);
  return this;
}

Fixed version (ground truth):
public final Trader selectItem(ItemStack item,TraderStatus status,boolean dura,boolean amount){
  selectedItem=traderStock.getItem(item,status,dura,amount);
  return this;
}
Program: 51691
Project: 51691
Buggy source:
public StockItem getItem(int slot,TraderStatus status){
  if (status.equals(TraderStatus.PLAYER_MANAGE_BUY) || status.equals(TraderStatus.PLAYER_BUY)) {
    for (    StockItem item : buyStock)     if (item.getSlot() == slot)     return item;
  }
  if (status.equals(TraderStatus.PLAYER_MANAGE_SELL) || status.equals(TraderStatus.PLAYER_SELL)) {
    for (    StockItem item : sellStock)     if (item.getSlot() == slot)     return item;
  }
  return null;
}

Fixed version (ground truth):
public StockItem getItem(ItemStack itemStack,TraderStatus status,boolean dura,boolean amount){
  boolean equal=false;
  if (status.equals(TraderStatus.PLAYER_MANAGE_BUY) || status.equals(TraderStatus.PLAYER_BUY)) {
    for (    StockItem item : buyStock) {
      equal=false;
      if (itemStack.getType().equals(item.getItemStack().getType()) && itemStack.getData().equals(item.getItemStack().getData())) {
        equal=true;
        if (dura)         equal=itemStack.getDurability() >= item.getItemStack().getDurability();
        if (amount && equal)         equal=itemStack.getAmount() == item.getItemStack().getAmount();
        if (equal)         return item;
      }
    }
  }
  if (status.equals(TraderStatus.PLAYER_MANAGE_SELL) || status.equals(TraderStatus.PLAYER_SELL)) {
    for (    StockItem item : sellStock) {
      equal=false;
      if (itemStack.getType().equals(item.getItemStack().getType()) && itemStack.getData().equals(item.getItemStack().getData())) {
        equal=true;
        if (dura)         equal=itemStack.getDurability() >= item.getItemStack().getDurability();
        if (amount && equal)         equal=itemStack.getAmount() == item.getItemStack().getAmount();
        if (equal)         return item;
      }
    }
  }
  return null;
}
Program: 51694
Project: 51694
Buggy source:
@Override public void onSet(NPC npc){
  if (!npc.hasTrait(InventoryTrait.class)) {
    npc.addTrait(new InventoryTrait());
    npc.getTrait(InventoryTrait.class).loadInventory(npc.getId());
  }
}

Fixed version (ground truth):
@Override public void onSet(NPC npc){
  if (!npc.hasTrait(InventoryTrait.class)) {
    npc.addTrait(InventoryTrait.class);
  }
}
Program: 51695
Project: 51695
Buggy source:
@Override public void save(DataKey data){
}

Fixed version (ground truth):
@Override public void save(DataKey data){
  System.out.print(data);
  List<String> sellList=new ArrayList<String>();
  if (!sellStock.isEmpty())   for (  StockItem item : sellStock)   sellList.add(item.toString());
  List<String> buyList=new ArrayList<String>();
  if (!buyStock.isEmpty())   for (  StockItem item : buyStock)   buyList.add(item.toString());
  data.setRaw("String_Node_Str",sellList);
  data.setRaw("String_Node_Str",buyList);
}
Program: 51696
Project: 51696
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void load(DataKey data) throws NPCLoadException {
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void load(DataKey data) throws NPCLoadException {
  if (data.keyExists("String_Node_Str")) {
    for (    String item : (List<String>)data.getRaw("String_Node_Str")) {
      sellStock.add(new StockItem(item));
    }
  }
  if (data.keyExists("String_Node_Str")) {
    for (    String item : (List<String>)data.getRaw("String_Node_Str"))     buyStock.add(new StockItem(item));
  }
}
Program: 51698
Project: 51698
Buggy source:
/** 
 * Command created to add new nodes to a container.
 */
@SuppressWarnings("String_Node_Str") @Override protected Command getCreateCommand(CreateRequest request){
  Assert.isLegal(getHost().getModel() instanceof OPMContainer,this.getClass().toString() + "String_Node_Str");
  OPMContainer model=(OPMContainer)getHost().getModel();
  Command retVal=null;
  EClass newObjectType=(EClass)request.getNewObjectType();
  if (OPMPackage.eINSTANCE.getOPMNode().isSuperTypeOf(newObjectType)) {
    if (!OpmValidator.eINSTANCE.validateContaiment(model,newObjectType)) {
      return null;
    }
    OPMNodeCreateCommand command=new OPMNodeCreateCommand();
    Rectangle constraints=(Rectangle)getConstraintFor(request);
    if (constraints.getSize().isEmpty()) {
      constraints.setSize(DEFAULT_THING_DIMENSION);
    }
    command.setConstraints(constraints);
    OPMContainer container=(OPMContainer)getHost().getModel();
    if (container instanceof OPMDecorated<?>)     container=((OPMDecorated<OPMContainer>)container).getDecorated();
    command.setContainer(container);
    command.setNode((OPMNode)(request.getNewObject()));
    retVal=command;
  }
  return retVal;
}

Fixed version (ground truth):
/** 
 * Command created to add new nodes to a container.
 */
@SuppressWarnings("String_Node_Str") @Override protected Command getCreateCommand(CreateRequest request){
  Assert.isLegal(getHost().getModel() instanceof OPMContainer,this.getClass().toString() + "String_Node_Str");
  OPMContainer model=(OPMContainer)getHost().getModel();
  Command retVal=null;
  EClass newObjectType=(EClass)request.getNewObjectType();
  if (OPMPackage.eINSTANCE.getOPMNode().isSuperTypeOf(newObjectType)) {
    if (!OpmValidator.eINSTANCE.validateContainment(model,newObjectType)) {
      return null;
    }
    OPMNodeCreateCommand command=new OPMNodeCreateCommand();
    Rectangle constraints=(Rectangle)getConstraintFor(request);
    if (constraints.getSize().isEmpty()) {
      constraints.setSize(DEFAULT_THING_DIMENSION);
    }
    command.setConstraints(constraints);
    OPMContainer container=(OPMContainer)getHost().getModel();
    if (container instanceof OPMDecorated<?>)     container=((OPMDecorated<OPMContainer>)container).getDecorated();
    command.setContainer(container);
    command.setNode((OPMNode)(request.getNewObject()));
    retVal=command;
  }
  return retVal;
}
Program: 51699
Project: 51699
Buggy source:
public static OpmValidatorImpl init(){
  if (instance == null) {
    OpmValidatorImpl validator=new OpmValidatorImpl();
    validator.initContaimentRules();
    validator.initLinkRules();
    instance=validator;
  }
  return instance;
}

Fixed version (ground truth):
public static OpmValidatorImpl init(){
  if (instance == null) {
    OpmValidatorImpl validator=new OpmValidatorImpl();
    validator.initContainmentRules();
    validator.initLinkRules();
    instance=validator;
  }
  return instance;
}
Program: 51700
Project: 51700
Buggy source:
/** 
 * Command created to add new nodes to a container.
 */
@Override protected Command getCreateCommand(CreateRequest request){
  if (!canGetChildCommand())   return null;
  ContainerInstance model=(ContainerInstance)getHost().getModel();
  Command retVal=null;
  NodeInstance newNode=(NodeInstance)request.getNewObject();
  if (opmodelValidator.validateContaiment(model,newNode)) {
    OPModelNodeCreateCommand command=new OPModelNodeCreateCommand();
    Rectangle constraints=(Rectangle)getConstraintFor(request);
    if (constraints.getSize().isEmpty()) {
      constraints.setSize(DEFAULT_NODE_DIMENSION);
    }
    command.setConstraints(constraints);
    command.setContainer(model);
    command.setNode(newNode);
    retVal=command;
  }
  return retVal;
}

Fixed version (ground truth):
/** 
 * Command created to add new nodes to a container.
 */
@Override protected Command getCreateCommand(CreateRequest request){
  if (!canGetChildCommand())   return null;
  ContainerInstance model=(ContainerInstance)getHost().getModel();
  Command retVal=null;
  NodeInstance newNode=(NodeInstance)request.getNewObject();
  if (opmodelValidator.validateContainment(model,newNode)) {
    OPModelNodeCreateCommand command=new OPModelNodeCreateCommand();
    Rectangle constraints=(Rectangle)getConstraintFor(request);
    if (constraints.getSize().isEmpty()) {
      constraints.setSize(DEFAULT_NODE_DIMENSION);
    }
    command.setConstraints(constraints);
    command.setContainer(model);
    command.setNode(newNode);
    retVal=command;
  }
  return retVal;
}
Program: 51701
Project: 51701
Buggy source:
public OpmodelValidator(OPmetaDefinition interpretation){
  this.interpretation=interpretation;
  linkValidator=new LinkValidator();
  contaimentValidator=new ContainmentValidator();
  initValidationRules();
}

Fixed version (ground truth):
public OpmodelValidator(OPmetaDefinition interpretation){
  this.interpretation=interpretation;
  linkValidator=new LinkValidator();
  containmentValidator=new ContainmentValidator();
  initValidationRules();
}
Program: 51702
Project: 51702
Buggy source:
private void initValidationRules(){
  List<OPmodelLinkValidationRule> rawLinkRules=interpretation.getLinkValidationRules();
  List<OPmodelContainmentValidationRule> rawContaimentRules=interpretation.getContainmentValidationRules();
  for (  OPmodelLinkValidationRule rule : rawLinkRules) {
    ElementTypeDecriptor from=new ElementTypeDecriptor(rule.getSourceType());
    ElementTypeDecriptor to=new ElementTypeDecriptor(rule.getTargetType());
    ElementTypeDecriptor link=new ElementTypeDecriptor(rule.getLinkType());
    linkValidator.addRule(from,link,to,rule.isValid());
  }
  for (  OPmodelContainmentValidationRule rule : rawContaimentRules) {
    ElementTypeDecriptor container=new ElementTypeDecriptor(rule.getContainerType());
    ElementTypeDecriptor containedItem=new ElementTypeDecriptor(rule.getNodeType());
    contaimentValidator.addRule(container,containedItem,rule.isValid());
  }
  try {
    linkValidator.finalizeInit();
    contaimentValidator.finalizeInit();
  }
 catch (  Exception ex) {
    throw new RuntimeException("String_Node_Str",ex);
  }
}

Fixed version (ground truth):
private void initValidationRules(){
  List<OPmodelLinkValidationRule> rawLinkRules=interpretation.getLinkValidationRules();
  List<OPmodelContainmentValidationRule> rawContainmentRules=interpretation.getContainmentValidationRules();
  for (  OPmodelLinkValidationRule rule : rawLinkRules) {
    ElementTypeDecriptor from=new ElementTypeDecriptor(rule.getSourceType());
    ElementTypeDecriptor to=new ElementTypeDecriptor(rule.getTargetType());
    ElementTypeDecriptor link=new ElementTypeDecriptor(rule.getLinkType());
    linkValidator.addRule(from,link,to,rule.isValid());
  }
  for (  OPmodelContainmentValidationRule rule : rawContainmentRules) {
    ElementTypeDecriptor container=new ElementTypeDecriptor(rule.getContainerType());
    ElementTypeDecriptor containedItem=new ElementTypeDecriptor(rule.getNodeType());
    containmentValidator.addRule(container,containedItem,rule.isValid());
  }
  try {
    linkValidator.finalizeInit();
    containmentValidator.finalizeInit();
  }
 catch (  Exception ex) {
    throw new RuntimeException("String_Node_Str",ex);
  }
}
Program: 51703
Project: 51703
Buggy source:
private void fillOpmContainmentRules(List<OPMetaModelContainmentValidationRule> contaimentRules){
  OPMetaModelContainmentValidationRule rule=opmetaFactory.eINSTANCE.createOPMetaModelContainmentValidationRule();
  rule.setContainerTypeName("String_Node_Str");
  rule.setNodeTypeName("String_Node_Str");
  rule.setValid(true);
  contaimentRules.add(rule);
  rule=opmetaFactory.eINSTANCE.createOPMetaModelContainmentValidationRule();
  rule.setContainerTypeName("String_Node_Str");
  rule.setNodeTypeName("String_Node_Str");
  rule.setValid(false);
  contaimentRules.add(rule);
  rule=opmetaFactory.eINSTANCE.createOPMetaModelContainmentValidationRule();
  rule.setContainerTypeName("String_Node_Str");
  rule.setNodeTypeName("String_Node_Str");
  rule.setValid(true);
  contaimentRules.add(rule);
  rule=opmetaFactory.eINSTANCE.createOPMetaModelContainmentValidationRule();
  rule.setContainerTypeName("String_Node_Str");
  rule.setNodeTypeName("String_Node_Str");
  rule.setValid(true);
  contaimentRules.add(rule);
}

Fixed version (ground truth):
private void fillOpmContainmentRules(List<OPMetaModelContainmentValidationRule> containmentRules){
  OPMetaModelContainmentValidationRule rule=opmetaFactory.eINSTANCE.createOPMetaModelContainmentValidationRule();
  rule.setContainerTypeName("String_Node_Str");
  rule.setNodeTypeName("String_Node_Str");
  rule.setValid(true);
  containmentRules.add(rule);
  rule=opmetaFactory.eINSTANCE.createOPMetaModelContainmentValidationRule();
  rule.setContainerTypeName("String_Node_Str");
  rule.setNodeTypeName("String_Node_Str");
  rule.setValid(false);
  containmentRules.add(rule);
  rule=opmetaFactory.eINSTANCE.createOPMetaModelContainmentValidationRule();
  rule.setContainerTypeName("String_Node_Str");
  rule.setNodeTypeName("String_Node_Str");
  rule.setValid(true);
  containmentRules.add(rule);
  rule=opmetaFactory.eINSTANCE.createOPMetaModelContainmentValidationRule();
  rule.setContainerTypeName("String_Node_Str");
  rule.setNodeTypeName("String_Node_Str");
  rule.setValid(true);
  containmentRules.add(rule);
}
Program: 51704
Project: 51704
Buggy source:
@Override protected void outlineShape(Graphics g){
  g.drawPolyline(getPoints());
  PointList points=getPoints();
  Point source=points.getFirstPoint();
  Point pointAfterSource=points.getPoint(1);
  Point target=points.getLastPoint();
  Point pointBeforeTarget=points.getPoint(points.size() - 2);
switch (kind) {
case EFFECT:
    arrow.setLocation(source);
  arrow.setReferencePoint(pointAfterSource);
g.drawPolyline(arrow.getPoints());
case CONSUMPTION:
case RESULT:
case INVOCATION:
arrow.setLocation(target);
arrow.setReferencePoint(pointBeforeTarget);
g.drawPolyline(arrow.getPoints());
break;
case INSTRUMENT:
int radius=OPMFigureConstants.agentCircleRadius;
g.pushState();
g.setBackgroundColor(ColorConstants.black);
g.fillOval(target.x() - radius,target.y() - radius,radius * 2,radius * 2);
g.setBackgroundColor(ColorConstants.white);
g.fillOval(target.x() - (radius - 2),target.y() - (radius - 2),(radius - 2) * 2,(radius - 2) * 2);
g.popState();
break;
}
switch (activationKind) {
case CONDITION:
if (pointBeforeTarget.x() < target.x()) g.drawText("String_Node_Str",target.x() - 20,target.y() - 20);
 else g.drawText("String_Node_Str",target.x() + 20,target.y() - 20);
break;
case EVENT:
if (pointBeforeTarget.x() < target.x()) g.drawText("String_Node_Str",target.x() - 20,target.y() - 20);
 else g.drawText("String_Node_Str",target.x() + 20,target.y() - 20);
}
}

Fixed version (ground truth):
@Override protected void outlineShape(Graphics g){
  g.drawPolyline(getPoints());
  PointList points=getPoints();
  Point source=points.getFirstPoint();
  Point pointAfterSource=points.getPoint(1);
  Point target=points.getLastPoint();
  Point pointBeforeTarget=points.getPoint(points.size() - 2);
  int radius=OPMFigureConstants.agentCircleRadius;
switch (kind) {
case EFFECT:
    arrow.setLocation(source);
  arrow.setReferencePoint(pointAfterSource);
g.drawPolyline(arrow.getPoints());
case CONSUMPTION:
case RESULT:
case INVOCATION:
arrow.setLocation(target);
arrow.setReferencePoint(pointBeforeTarget);
g.drawPolyline(arrow.getPoints());
break;
case INSTRUMENT:
g.pushState();
g.setBackgroundColor(ColorConstants.black);
g.fillOval(target.x() - radius,target.y() - radius,radius * 2,radius * 2);
g.setBackgroundColor(ColorConstants.white);
g.fillOval(target.x() - (radius - 2),target.y() - (radius - 2),(radius - 2) * 2,(radius - 2) * 2);
g.popState();
break;
case AGENT:
g.pushState();
g.setBackgroundColor(ColorConstants.black);
g.fillOval(target.x() - radius,target.y() - radius,radius * 2,radius * 2);
g.popState();
break;
}
switch (activationKind) {
case CONDITION:
if (pointBeforeTarget.x() < target.x()) g.drawText("String_Node_Str",target.x() - 20,target.y() - 20);
 else g.drawText("String_Node_Str",target.x() + 20,target.y() - 20);
break;
case EVENT:
if (pointBeforeTarget.x() < target.x()) g.drawText("String_Node_Str",target.x() - 20,target.y() - 20);
 else g.drawText("String_Node_Str",target.x() + 20,target.y() - 20);
}
}
Program: 51705
Project: 51705
Buggy source:
@Override protected List getModelChildren(){
  OPMNode model=(OPMNode)getModel();
  if (model instanceof OPMContainer) {
    OPMContainer container=(OPMContainer)model;
    return Collections.unmodifiableList(container.getNodes());
  }
 else {
    return Collections.EMPTY_LIST;
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override protected List getModelChildren(){
  OPMNode model=(OPMNode)getModel();
  if (model instanceof OPMContainer) {
    OPMContainer container=(OPMContainer)model;
    return Collections.unmodifiableList(container.getNodes());
  }
 else {
    return Collections.EMPTY_LIST;
  }
}
Program: 51706
Project: 51706
Buggy source:
@Override public ConnectionAnchor getTargetConnectionAnchor(Request request){
  if (getFigure() instanceof LabelFigure) {
    return null;
  }
 else {
    return ((OPMNodeFigure)getFigure()).getTargetConnectionAnchor();
  }
}

Fixed version (ground truth):
@Override public ConnectionAnchor getTargetConnectionAnchor(Request request){
  if (getFigure() instanceof OPMNodeFigure) {
    return ((OPMNodeFigure)getFigure()).getTargetConnectionAnchor();
  }
 else {
    return null;
  }
}
Program: 51707
Project: 51707
Buggy source:
@Override public ConnectionAnchor getSourceConnectionAnchor(Request request){
  if (getFigure() instanceof LabelFigure) {
    return null;
  }
 else {
    return ((OPMNodeFigure)getFigure()).getSourceConnectionAnchor();
  }
}

Fixed version (ground truth):
@Override public ConnectionAnchor getSourceConnectionAnchor(Request request){
  if (getFigure() instanceof OPMNodeFigure) {
    return ((OPMNodeFigure)getFigure()).getTargetConnectionAnchor();
  }
 else {
    return null;
  }
}
Program: 51708
Project: 51708
Buggy source:
@Override public List<OPMLink> getLinks(){
  recreateNodesAndLinks();
  return new ArrayList(links);
}

Fixed version (ground truth):
@Override public List<OPMLink> getLinks(){
  recreateNodesAndLinks();
  return new ArrayList<>(links);
}
Program: 51709
Project: 51709
Buggy source:
public OPMNamedElementDirectEditManager(GraphicalEditPart source,Class editorType,CellEditorLocator locator,Label label){
  super(source,editorType,locator);
  this.label=label;
}

Fixed version (ground truth):
public OPMNamedElementDirectEditManager(GraphicalEditPart source,Class<?> editorType,CellEditorLocator locator,Label label){
  super(source,editorType,locator);
  this.label=label;
}
Program: 51710
Project: 51710
Buggy source:
/** 
 * Currently the class only adapts to create a   {@link SnapToHelper} when the editor is in snapping mode (either togrid or to shapes).
 */
@Override public Object getAdapter(Class key){
  if (key == SnapToHelper.class) {
    List<SnapToHelper> helpers=new ArrayList<SnapToHelper>();
    if (Boolean.TRUE.equals(getViewer().getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED))) {
      helpers.add(new SnapToGeometry(this));
    }
    if (Boolean.TRUE.equals(getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED))) {
      helpers.add(new SnapToGrid(this));
    }
    if (helpers.size() == 0) {
      return null;
    }
 else {
      return new CompoundSnapToHelper(helpers.toArray(new SnapToHelper[0]));
    }
  }
  return super.getAdapter(key);
}

Fixed version (ground truth):
/** 
 * Currently the class only adapts to create a   {@link SnapToHelper} when the editor is in snapping mode (either togrid or to shapes).
 */
@SuppressWarnings("String_Node_Str") @Override public Object getAdapter(Class key){
  if (key == SnapToHelper.class) {
    List<SnapToHelper> helpers=new ArrayList<SnapToHelper>();
    if (Boolean.TRUE.equals(getViewer().getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED))) {
      helpers.add(new SnapToGeometry(this));
    }
    if (Boolean.TRUE.equals(getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED))) {
      helpers.add(new SnapToGrid(this));
    }
    if (helpers.size() == 0) {
      return null;
    }
 else {
      return new CompoundSnapToHelper(helpers.toArray(new SnapToHelper[0]));
    }
  }
  return super.getAdapter(key);
}
Program: 51711
Project: 51711
Buggy source:
private void setStructuralLinkAggregatorPosition(CreateConnectionRequest request){
  OPMStructuralLink structuralLink=(OPMStructuralLink)request.getNewObject();
  OPMNode source=(OPMNode)request.getSourceEditPart().getModel();
  if (source instanceof OPMDecorated<?>)   source=(OPMNode)((OPMDecorated<OPMNode>)source).getDecorated();
  OPMNode target=(OPMNode)request.getTargetEditPart().getModel();
  if (target instanceof OPMDecorated<?>)   target=(OPMNode)((OPMDecorated<OPMNode>)target).getDecorated();
  structuralLink.setAggregatorPosition(getAggregatorPosition(source,target));
}

Fixed version (ground truth):
private void setStructuralLinkAggregatorPosition(CreateConnectionRequest request){
  OPMStructuralLink structuralLink=(OPMStructuralLink)request.getNewObject();
  OPMNode source=(OPMNode)request.getSourceEditPart().getModel();
  if (source instanceof OPMDecorated<?>)   source=(OPMNode)((OPMDecorated<?>)source).getDecorated();
  OPMNode target=(OPMNode)request.getTargetEditPart().getModel();
  if (target instanceof OPMDecorated<?>)   target=(OPMNode)((OPMDecorated<?>)target).getDecorated();
  structuralLink.setAggregatorPosition(getAggregatorPosition(source,target));
}