nus-yam/ex-repair huggingface dataset:
Program: 2998
Project: 2998
Buggy source:
public synchronized void announce() throws InterruptedException {
  try {
    AgentStatus agentStatus=agent.getAgentStatus();
    AgentStatusRepresentation agentStatusRepresentation=AgentStatusRepresentation.from(agentStatus,httpServerInfo.getHttpUri());
    String json=codec.toJson(agentStatusRepresentation);
    client.preparePut(announcementUrl).setBody(json).execute().get();
  }
 catch (  InterruptedException e) {
    throw e;
  }
catch (  Exception e) {
    log.warn(e,"String_Node_Str" + announcementUrl);
  }
}

Fixed version (ground truth):
public synchronized void announce() throws InterruptedException {
  try {
    AgentStatus agentStatus=agent.getAgentStatus();
    AgentStatusRepresentation agentStatusRepresentation=AgentStatusRepresentation.from(agentStatus,httpServerInfo.getHttpUri());
    String json=codec.toJson(agentStatusRepresentation);
    Response response=client.preparePut(announcementUrl).setBody(json).setHeader(HttpHeaders.CONTENT_TYPE,MediaType.APPLICATION_JSON).execute().get();
    if (response.getStatusCode() != 200) {
      log.warn("String_Node_Str" + announcementUrl + "String_Node_Str"+ response.getStatusText());
    }
  }
 catch (  InterruptedException e) {
    throw e;
  }
catch (  Exception e) {
    log.warn(e,"String_Node_Str" + announcementUrl);
  }
}
Program: 2999
Project: 2999
Buggy source:
@BeforeClass public void startServer() throws Exception {
  tempDir=DeploymentUtils.createTempDir("String_Node_Str");
  Map<String,String> properties=ImmutableMap.<String,String>builder().put("String_Node_Str","String_Node_Str").put("String_Node_Str","String_Node_Str").put("String_Node_Str",tempDir.getAbsolutePath()).build();
  Injector injector=Guice.createInjector(new TestingHttpServerModule(),new JaxrsModule(),new AgentMainModule(),new ConfigurationModule(new ConfigurationFactory(properties)));
  server=injector.getInstance(TestingHttpServer.class);
  agent=injector.getInstance(Agent.class);
  server.start();
  client=new AsyncHttpClient();
  testRepository=RepositoryTestHelper.createTestRepository();
  appleAssignment=newAssignment("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@BeforeClass public void startServer() throws Exception {
  tempDir=DeploymentUtils.createTempDir("String_Node_Str");
  Map<String,String> properties=ImmutableMap.<String,String>builder().put("String_Node_Str","String_Node_Str").put("String_Node_Str",tempDir.getAbsolutePath()).build();
  Injector injector=Guice.createInjector(new TestingHttpServerModule(),new JaxrsModule(),new AgentMainModule(),new ConfigurationModule(new ConfigurationFactory(properties)));
  server=injector.getInstance(TestingHttpServer.class);
  agent=injector.getInstance(Agent.class);
  server.start();
  client=new AsyncHttpClient();
  testRepository=RepositoryTestHelper.createTestRepository();
  appleAssignment=newAssignment("String_Node_Str","String_Node_Str");
}
Program: 3000
Project: 3000
Buggy source:
@BeforeClass public void startServer() throws Exception {
  tempDir=DeploymentUtils.createTempDir("String_Node_Str");
  Map<String,String> properties=ImmutableMap.<String,String>builder().put("String_Node_Str","String_Node_Str").put("String_Node_Str","String_Node_Str").put("String_Node_Str",tempDir.getAbsolutePath()).build();
  Injector injector=Guice.createInjector(new TestingHttpServerModule(),new JaxrsModule(),new AgentMainModule(),new ConfigurationModule(new ConfigurationFactory(properties)));
  server=injector.getInstance(TestingHttpServer.class);
  agent=injector.getInstance(Agent.class);
  server.start();
  client=new AsyncHttpClient();
  testRepository=RepositoryTestHelper.createTestRepository();
  appleAssignment=newAssignment("String_Node_Str","String_Node_Str");
  bananaAssignment=newAssignment("String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@BeforeClass public void startServer() throws Exception {
  tempDir=DeploymentUtils.createTempDir("String_Node_Str");
  Map<String,String> properties=ImmutableMap.<String,String>builder().put("String_Node_Str","String_Node_Str").put("String_Node_Str",tempDir.getAbsolutePath()).build();
  Injector injector=Guice.createInjector(new TestingHttpServerModule(),new JaxrsModule(),new AgentMainModule(),new ConfigurationModule(new ConfigurationFactory(properties)));
  server=injector.getInstance(TestingHttpServer.class);
  agent=injector.getInstance(Agent.class);
  server.start();
  client=new AsyncHttpClient();
  testRepository=RepositoryTestHelper.createTestRepository();
  appleAssignment=newAssignment("String_Node_Str","String_Node_Str");
  bananaAssignment=newAssignment("String_Node_Str","String_Node_Str");
}
Program: 3001
Project: 3001
Buggy source:
/** 
 * Causes all old versions older than the specified parameter to be discarded.
 * @param preserveVersion The version to be preserved.
 */
public void flushOldVersions(long preserveVersion){
  VersionedObject<T> vo=currentVersion;
  for (; ; ) {
    if (vo == null)     return;
    if (vo.getVersion() <= preserveVersion) {
      vo.clearOldVersions();
      return;
    }
    vo=vo.getOlderVersion();
  }
}

Fixed version (ground truth):
/** 
 * Causes all old versions older than the specified parameter to be discarded.
 * @param preserveVersion The version to be preserved.
 */
public void flushOldVersions(long preserveVersion){
  VersionedObject<T> vo=currentVersion;
  for (; ; ) {
    if (vo == null)     return;
    if (vo.getVersion() < preserveVersion) {
      vo.clearOldVersions();
      return;
    }
    vo=vo.getOlderVersion();
  }
}
Program: 3002
Project: 3002
Buggy source:
public byte[] getPrefixData(){
  StringBuffer sb=new StringBuffer();
  Set<String> set=jibbleMap.keySet();
  for (  String s : set) {
    sb.append(s);
    int l=s.length();
    while (l < 4) {
      l++;
      sb.append(' ');
    }
  }
  String data=sb.toString();
  try {
    return data.getBytes("String_Node_Str");
  }
 catch (  UnsupportedEncodingException e) {
    throw new Error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public byte[] getPrefixData(){
  if (prefixData != null) {
    return prefixData;
  }
  StringBuffer sb=new StringBuffer();
  Set<String> set=jibbleMap.keySet();
  for (  String s : set) {
    sb.append(s);
    int l=s.length();
    while (l < 4) {
      l++;
      sb.append(' ');
    }
  }
  String data=sb.toString();
  try {
    prefixData=data.getBytes("String_Node_Str");
    return prefixData;
  }
 catch (  UnsupportedEncodingException e) {
    throw new Error("String_Node_Str",e);
  }
}
Program: 3003
Project: 3003
Buggy source:
@Override public Iterable<T> doInTransaction(TransactionStatus status){
  return repo.save(objects);
}

Fixed version (ground truth):
public Iterable<T> doInTransaction(TransactionStatus status){
  return repo.save(objects);
}
Program: 3004
Project: 3004
Buggy source:
private void save(final ArrayList<T> objects){
  new TransactionTemplate(transactionManager).execute(new TransactionCallback<Iterable<T>>(){
    @Override public Iterable<T> doInTransaction(    TransactionStatus status){
      return repo.save(objects);
    }
  }
);
}

Fixed version (ground truth):
private void save(final ArrayList<T> objects){
  new TransactionTemplate(transactionManager).execute(new TransactionCallback<Iterable<T>>(){
    public Iterable<T> doInTransaction(    TransactionStatus status){
      return repo.save(objects);
    }
  }
);
}
Program: 3005
Project: 3005
Buggy source:
private Object wrapValue(String key,Object value,Class<? extends IAttribute> dbClass){
  if (dbClass.equals(EnumExclusiveValue.class)) {
    return new EnumAttribute(key,null,(String)value);
  }
  if (dbClass.equals(EnumMultipleValue.class)) {
    return new MultiEnumAttribute(key,null,(String[])value);
  }
  return value;
}

Fixed version (ground truth):
private Object wrapValue(String key,Object value,Class<? extends IAttribute> dbClass){
  if (dbClass.equals(EnumExclusiveValue.class)) {
    return new EnumAttribute(key,"String_Node_Str",(String)value);
  }
  if (dbClass.equals(EnumMultipleValue.class)) {
    return new MultiEnumAttribute(key,"String_Node_Str",(String[])value);
  }
  return value;
}
Program: 3007
Project: 3007
Buggy source:
@SuppressWarnings("String_Node_Str") public JibbleConvertor(Logger log){
  log.info("String_Node_Str" + jibbleFile);
  try {
    jibbleMap=(TreeMap<String,PostcodeResult>)FileUtils.readObjectFromGZip(jibbleFile);
  }
 catch (  Error e) {
    log.error("String_Node_Str" + e.getCause().getMessage());
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public JibbleConvertor(Logger removeThis){
  log.info("String_Node_Str" + jibbleFile);
  try {
    jibbleMap=(TreeMap<String,PostcodeResult>)FileUtils.readObjectFromGZip(jibbleFile);
  }
 catch (  Error e) {
    log.error("String_Node_Str" + e.getCause().getMessage());
  }
}
Program: 3008
Project: 3008
Buggy source:
public PostcodeResult lookupShort(String prefix){
  if (prefix == null || jibbleMap == null)   return null;
  prefix=StringUtils.stripSpaces(prefix.toUpperCase());
  return jibbleMap.get(prefix);
}

Fixed version (ground truth):
public PostcodeResult lookupShort(String prefix){
  if (prefix == null || jibbleMap == null)   return null;
  prefix=StringUtils.stripSpaces(prefix.toUpperCase());
  log.debug("String_Node_Str",prefix);
  return jibbleMap.get(prefix);
}
Program: 3009
Project: 3009
Buggy source:
/** 
 * Look up a full postcode.<br><br>WARNING - EXECUTING THIS FUNCTION COSTS 1p!!<br><br>
 * @param postcode A full postcode to lookup, any caps, any spaces
 * @return A PostcodeResult if the postcode is valid, otherwise null
 * @throws LostDbConnection
 */
public synchronized PostcodeResult lookupFull(String postcode){
  if (service != null) {
    return service.lookupFull(postcode);
  }
  log.debug("String_Node_Str",postcode);
  postcode=StringUtils.stripSpaces(postcode);
  int trimmedLength=postcode.length() - 3;
  if (trimmedLength != 3 && trimmedLength != 4)   return null;
  postcode=postcode.substring(0,trimmedLength);
  return jibble.lookupShort(postcode);
}

Fixed version (ground truth):
/** 
 * Look up a full postcode.<br><br>WARNING - EXECUTING THIS FUNCTION COSTS 1p!!<br><br>
 * @param postcode A full postcode to lookup, any caps, any spaces
 * @return A PostcodeResult if the postcode is valid, otherwise null
 * @throws LostDbConnection
 */
public synchronized PostcodeResult lookupFull(String postcode){
  if (service != null) {
    return service.lookupFull(postcode);
  }
  log.debug("String_Node_Str",postcode);
  postcode=StringUtils.stripSpaces(postcode);
  int trimmedLength=postcode.length() - 3;
  if (trimmedLength < 2 || trimmedLength > 4)   return null;
  postcode=postcode.substring(0,trimmedLength);
  return jibble.lookupShort(postcode);
}
Program: 3010
Project: 3010
Buggy source:
/** 
 * On txLog playback, we want to apply transaction logs that include the transactions from the version of the currently loaded repository, forwards. Algo:  - keep track of highest version that is lower than current db version (as that might be the one) - if version == dbversion, return it, it's exact match (what we normally expect) - if version < dbversion but not greater than highestDbVer,  then remove it (as all it's transactions are in repos or have been applied) - if version < dbversion and > highestDbVer, update highestDbVer, and remember what file it is After have been through all, return the best found
 */
private File removeBestCandidate(ArrayList<File> candidates){
  File best=null;
  Iterator<File> i=candidates.iterator();
  while (i.hasNext()) {
    File file=i.next();
    long version=getDbVerFromFilename(file);
    if (version == -1) {
      continue;
    }
    if (version == startVersion) {
      i.remove();
      highestDbVer=version;
      return file;
    }
 else     if (version < startVersion) {
      if (version > highestDbVer && allowNonExact) {
        highestDbVer=version;
        best=file;
      }
 else {
        i.remove();
      }
    }
  }
  return best;
}

Fixed version (ground truth):
/** 
 * On txLog playback, we want to apply transaction logs that include the transactions from the version of the currently loaded repository, forwards. Algo:  - keep track of highest version that is lower than current db version (as that might be the one) - if version == dbversion, return it, it's exact match (what we normally expect) - if version < dbversion but not greater than highestDbVer,  then remove it (as all it's transactions are in repos or have been applied) - if version < dbversion and > highestDbVer, update highestDbVer, and remember what file it is After have been through all, return the best found
 */
private File removeBestCandidate(ArrayList<File> candidates){
  File best=null;
  Iterator<File> i=candidates.iterator();
  while (i.hasNext()) {
    File file=i.next();
    long version=getDbVerFromFilename(file);
    if (version == -1) {
      continue;
    }
    if (version == startVersion) {
      i.remove();
      highestDbVer=version;
      return file;
    }
 else     if (version < startVersion) {
      if (version > highestDbVer && allowNonExact) {
        highestDbVer=version;
        best=file;
      }
    }
 else {
      i.remove();
    }
  }
  return best;
}
Program: 3011
Project: 3011
Buggy source:
public IDimensions clone() throws CloneNotSupportedException ;

Fixed version (ground truth):
public Object clone() throws CloneNotSupportedException ;
Program: 3012
Project: 3012
Buggy source:
protected static void performDrop(Location target,OtherBlocksContainer dropData){
  if (!isCreature(dropData.dropped)) {
    if (dropData.dropped.equalsIgnoreCase("String_Node_Str")) {
      Inventory inven=null;
switch (Material.valueOf(dropData.original)) {
case FURNACE:
case BURNING_FURNACE:
        Furnace oven=(Furnace)target.getBlock().getState();
      inven=oven.getInventory();
    ItemStack cooking=inven.getItem(0);
  if (oven.getCookTime() > 0)   cooking.setAmount(cooking.getAmount() - 1);
if (cooking.getAmount() <= 0) inven.setItem(0,null);
break;
case DISPENSER:
Dispenser trap=(Dispenser)target.getBlock().getState();
inven=trap.getInventory();
break;
case CHEST:
Chest box=(Chest)target.getBlock().getState();
inven=box.getInventory();
break;
}
if (inven != null) {
for (ItemStack item : inven.getContents()) {
if (item.getType() != Material.AIR) {
target.getWorld().dropItemNaturally(target,item);
}
}
}
}
 else if (Material.valueOf(dropData.dropped) != Material.AIR) {
target.getWorld().dropItemNaturally(target,new ItemStack(Material.valueOf(dropData.dropped),dropData.quantity,dropData.color));
}
}
 else {
target.getWorld().spawnCreature(new Location(target.getWorld(),target.getX() + 0.5,target.getY() + 1,target.getZ() + 0.5),CreatureType.valueOf(OtherBlocks.creatureName(dropData.dropped)));
}
}

Fixed version (ground truth):
protected static void performDrop(Location target,OtherBlocksContainer dropData){
  if (!isCreature(dropData.dropped)) {
    if (dropData.dropped.equalsIgnoreCase("String_Node_Str")) {
      Inventory inven=null;
switch (Material.valueOf(dropData.original)) {
case FURNACE:
case BURNING_FURNACE:
        Furnace oven=(Furnace)target.getBlock().getState();
      inven=oven.getInventory();
    ItemStack cooking=inven.getItem(0);
  if (oven.getCookTime() > 0)   cooking.setAmount(cooking.getAmount() - 1);
if (cooking.getAmount() <= 0) inven.setItem(0,null);
break;
case DISPENSER:
Dispenser trap=(Dispenser)target.getBlock().getState();
inven=trap.getInventory();
break;
case CHEST:
Chest box=(Chest)target.getBlock().getState();
inven=box.getInventory();
break;
}
if (inven != null) {
for (ItemStack item : inven.getContents()) {
if (item.getType() != Material.AIR) {
target.getWorld().dropItemNaturally(target,item);
}
}
}
}
 else if (Material.valueOf(dropData.dropped) != Material.AIR) {
target.getWorld().dropItemNaturally(target,new ItemStack(Material.valueOf(dropData.dropped),dropData.quantity,dropData.color));
}
}
 else {
for (Integer i=0; i < dropData.quantity; i++) {
target.getWorld().spawnCreature(new Location(target.getWorld(),target.getX() + 0.5,target.getY() + 1,target.getZ() + 0.5),CreatureType.valueOf(OtherBlocks.creatureName(dropData.dropped)));
}
}
}
Program: 3013
Project: 3013
Buggy source:
@Override public void onEntityDeath(EntityDeathEvent event){
  if (!parent.damagerList.containsKey(event.getEntity())) {
    return;
  }
  Material weapon=parent.damagerList.get(event.getEntity()).tool;
  Entity victim=event.getEntity();
  CreatureType victimType=CommonEntity.getCreatureType(victim);
  parent.damagerList.remove(event.getEntity());
  for (  OtherBlocksContainer obc : parent.transformList) {
    if (!obc.worlds.contains(null) && !obc.worlds.contains(event.getEntity().getWorld().getName()))     continue;
    if (!OtherBlocks.containsValidToolString(weapon.toString(),obc.tool))     continue;
    if (!OtherBlocks.isCreature(obc.original) || CreatureType.valueOf(OtherBlocks.creatureName(obc.original)) != victimType) {
      continue;
    }
    if (parent.rng.nextDouble() > (obc.chance.doubleValue() / 100))     continue;
    event.getDrops().clear();
    Location location=victim.getLocation();
    OtherBlocks.performDrop(location,obc);
  }
}

Fixed version (ground truth):
@Override public void onEntityDeath(EntityDeathEvent event){
  if (!parent.damagerList.containsKey(event.getEntity())) {
    return;
  }
  Material weapon=parent.damagerList.get(event.getEntity()).tool;
  Entity victim=event.getEntity();
  CreatureType victimType=CommonEntity.getCreatureType(victim);
  parent.damagerList.remove(event.getEntity());
  for (  OtherBlocksContainer obc : parent.transformList) {
    if (!obc.worlds.contains(null) && !obc.worlds.contains(event.getEntity().getWorld().getName()))     continue;
    if (!OtherBlocks.containsValidToolString(weapon.toString(),obc.tool))     continue;
    if (!OtherBlocks.isCreature(obc.original) || CreatureType.valueOf(OtherBlocks.creatureName(obc.original)) != victimType) {
      continue;
    }
    if (parent.rng.nextDouble() > (obc.chance.doubleValue() / 100))     continue;
    setQuantity(obc);
    event.getDrops().clear();
    Location location=victim.getLocation();
    OtherBlocks.performDrop(location,obc);
  }
}
Program: 3015
Project: 3015
Buggy source:
@Override public void onLeavesDecay(LeavesDecayEvent event){
  boolean successfulConversion=false;
  Block target=event.getBlock();
  if (event.isCancelled())   return;
  for (  OtherBlocksContainer obc : parent.transformList) {
    if (!OtherBlocks.isLeafDecay(obc.original))     continue;
    if (!containsValidString(target.getWorld().getName(),obc.worlds))     continue;
    if (parent.rng.nextDouble() > (obc.chance.doubleValue() / 100))     continue;
    successfulConversion=true;
    OtherBlocks.performDrop(target.getLocation(),obc);
  }
  if (successfulConversion) {
    event.setCancelled(true);
    target.setType(Material.AIR);
  }
}

Fixed version (ground truth):
@Override public void onLeavesDecay(LeavesDecayEvent event){
  boolean successfulConversion=false;
  Block target=event.getBlock();
  if (event.isCancelled())   return;
  for (  OtherBlocksContainer obc : parent.transformList) {
    if (!OtherBlocks.isLeafDecay(obc.original))     continue;
    if (!containsValidString(target.getWorld().getName(),obc.worlds))     continue;
    if (parent.rng.nextDouble() > (obc.chance.doubleValue() / 100))     continue;
    setQuantity(obc);
    successfulConversion=true;
    OtherBlocks.performDrop(target.getLocation(),obc);
  }
  if (successfulConversion) {
    event.setCancelled(true);
    target.setType(Material.AIR);
  }
}
Program: 3016
Project: 3016
Buggy source:
@Override public void onBlockBreak(BlockBreakEvent event){
  if (event.isCancelled())   return;
  Block target=event.getBlock();
  ItemStack tool=event.getPlayer().getItemInHand();
  Integer maxDamage=0;
  boolean successfulConversion=false;
  for (  OtherBlocksContainer obc : parent.transformList) {
    if (!containsValidString(target.getWorld().getName(),obc.worlds))     continue;
    if (!containsValidMaterial(tool.getType(),obc.tool))     continue;
    if (OtherBlocks.isCreature(obc.original))     continue;
    if (OtherBlocks.isLeafDecay(obc.original))     continue;
    if (Material.valueOf(obc.original) != event.getBlock().getType())     continue;
    if (parent.rng.nextDouble() > (obc.chance.doubleValue() / 100))     continue;
    successfulConversion=true;
    OtherBlocks.performDrop(target.getLocation(),obc);
    maxDamage=(maxDamage < obc.damage) ? obc.damage : maxDamage;
  }
  if (successfulConversion) {
    event.setCancelled(true);
    target.setType(Material.AIR);
    if (tool.getType().getMaxDurability() < 0 || tool.getType().isBlock())     return;
    tool.setDurability((short)(tool.getDurability() + maxDamage));
    if (tool.getDurability() >= tool.getType().getMaxDurability()) {
      event.getPlayer().setItemInHand(null);
    }
  }
}

Fixed version (ground truth):
@Override public void onBlockBreak(BlockBreakEvent event){
  if (event.isCancelled())   return;
  Block target=event.getBlock();
  ItemStack tool=event.getPlayer().getItemInHand();
  Integer maxDamage=0;
  boolean successfulConversion=false;
  for (  OtherBlocksContainer obc : parent.transformList) {
    if (!containsValidString(target.getWorld().getName(),obc.worlds))     continue;
    if (!containsValidMaterial(tool.getType(),obc.tool))     continue;
    if (OtherBlocks.isCreature(obc.original))     continue;
    if (OtherBlocks.isLeafDecay(obc.original))     continue;
    if (Material.valueOf(obc.original) != event.getBlock().getType())     continue;
    if (parent.rng.nextDouble() > (obc.chance.doubleValue() / 100))     continue;
    setQuantity(obc);
    successfulConversion=true;
    OtherBlocks.performDrop(target.getLocation(),obc);
    maxDamage=(maxDamage < obc.damage) ? obc.damage : maxDamage;
  }
  if (successfulConversion) {
    event.setCancelled(true);
    target.setType(Material.AIR);
    if (tool.getType().getMaxDurability() < 0 || tool.getType().isBlock())     return;
    tool.setDurability((short)(tool.getDurability() + maxDamage));
    if (tool.getDurability() >= tool.getType().getMaxDurability()) {
      event.getPlayer().setItemInHand(null);
    }
  }
}
Program: 3020
Project: 3020
Buggy source:
public int getFixedMaxStackSize(Material m){
  return (int)((Material.DIAMOND_PICKAXE.getMaxStackSize() > 1) ? m.getMaxDurability() : m.getMaxStackSize());
}

Fixed version (ground truth):
public int getFixedMaxStackSize(Material m){
  return (int)((m.getMaxStackSize() < 1) ? m.getMaxDurability() : m.getMaxStackSize());
}
Program: 3021
Project: 3021
Buggy source:
public short getFixedMaxDurability(Material m){
  return (short)((Material.DIAMOND_PICKAXE.getMaxStackSize() > 1) ? m.getMaxStackSize() : m.getMaxDurability());
}

Fixed version (ground truth):
public short getFixedMaxDurability(Material m){
  return (short)((m.getMaxStackSize() < 1) ? m.getMaxStackSize() : m.getMaxDurability());
}
Program: 3022
Project: 3022
Buggy source:
public void onEnable(){
  PluginManager pm=getServer().getPluginManager();
  pm.registerEvent(Event.Type.BLOCK_DAMAGED,blockListener,Priority.Monitor,this);
  log.info(getDescription().getName() + "String_Node_Str" + getDescription().getVersion()+ "String_Node_Str");
}

Fixed version (ground truth):
public void onEnable(){
  PluginManager pm=getServer().getPluginManager();
  pm.registerEvent(Event.Type.BLOCK_DAMAGED,blockListener,Priority.Lowest,this);
  log.info(getDescription().getName() + "String_Node_Str" + getDescription().getVersion()+ "String_Node_Str");
}
Program: 3023
Project: 3023
Buggy source:
public int getFixedMaxStackSize(Material m){
  return (int)(Material.AIR.getMaxStackSize() == -1 ? m.getMaxDurability() : m.getMaxStackSize());
}

Fixed version (ground truth):
public int getFixedMaxStackSize(Material m){
  return (int)((Material.DIAMOND_PICKAXE.getMaxStackSize() > 1) ? m.getMaxDurability() : m.getMaxStackSize());
}
Program: 3024
Project: 3024
Buggy source:
public short getFixedMaxDurability(Material m){
  return (short)(Material.AIR.getMaxStackSize() == -1 ? m.getMaxStackSize() : m.getMaxDurability());
}

Fixed version (ground truth):
public short getFixedMaxDurability(Material m){
  return (short)((Material.DIAMOND_PICKAXE.getMaxStackSize() > 1) ? m.getMaxStackSize() : m.getMaxDurability());
}
Program: 3025
Project: 3025
Buggy source:
public List<EventItem> getEventItems(){
  return eventItems;
}

Fixed version (ground truth):
public List<EventItem> getEventItems(){
  if (eventItems == null)   eventItems=new ArrayList<EventItem>();
  return eventItems;
}
Program: 3026
Project: 3026
Buggy source:
public List<Emotion> getEmotionList(){
  return emotionList;
}

Fixed version (ground truth):
public List<Emotion> getEmotionList(){
  if (emotionList == null)   emotionList=new ArrayList<Emotion>();
  return emotionList;
}
Program: 3027
Project: 3027
Buggy source:
public static MoodEnum getType(double x,double y){
  if (x >= 0.5 && y >= 0.5) {
    MoodEnum m=MoodEnum.NERVOUS;
    m.x=x;
    m.y=y;
    return m;
  }
 else   if (x >= 0.5 && y <= 0.5) {
    MoodEnum m=MoodEnum.CALM;
    m.x=x;
    m.y=y;
    return m;
  }
 else   if (x <= 0.5 && y <= 0.5) {
    MoodEnum m=MoodEnum.SAD;
    m.x=x;
    m.y=y;
    return m;
  }
 else   if (x <= 0.5 && y >= 0.5) {
    MoodEnum m=MoodEnum.NERVOUS;
    m.x=x;
    m.y=y;
    return m;
  }
 else {
    MoodEnum m=MoodEnum.NERVOUS;
    m.x=x;
    m.y=y;
    return m;
  }
}

Fixed version (ground truth):
public static MoodEnum getType(double x,double y){
  if (x >= 0.5 && y >= 0.5) {
    MoodEnum m=MoodEnum.HAPPY;
    m.x=x;
    m.y=y;
    return m;
  }
 else   if (x >= 0.5 && y <= 0.5) {
    MoodEnum m=MoodEnum.CALM;
    m.x=x;
    m.y=y;
    return m;
  }
 else   if (x <= 0.5 && y <= 0.5) {
    MoodEnum m=MoodEnum.SAD;
    m.x=x;
    m.y=y;
    return m;
  }
 else   if (x <= 0.5 && y >= 0.5) {
    MoodEnum m=MoodEnum.NERVOUS;
    m.x=x;
    m.y=y;
    return m;
  }
 else {
    MoodEnum m=MoodEnum.CALM;
    m.x=x;
    m.y=y;
    return m;
  }
}
Program: 3028
Project: 3028
Buggy source:
@Override public int delete(Uri uri,String userName,String[] whereArgs){
  int count=0;
  String where=userName + "String_Node_Str" + UserColumns.USER_NAME;
  count=super.getUserDatabase().delete(SQLStatements.USER_DATABASE_TABLE_NAME,where,whereArgs);
  return count;
}

Fixed version (ground truth):
@Override public int delete(Uri uri,String where,String[] whereArgs){
  int count=0;
  count=super.getUserDatabase().delete(SQLStatements.USER_DATABASE_TABLE_NAME,where,whereArgs);
  return count;
}
Program: 3031
Project: 3031
Buggy source:
@SuppressWarnings("String_Node_Str") public void removeEvent(Event event){
  super.remove(event);
  Set<?> s=displayedEvents.entrySet();
  Iterator<?> it=s.iterator();
  int key=-1;
  while (it.hasNext()) {
    Map.Entry m=(Map.Entry)it.next();
    key=(Integer)m.getKey();
    System.out.println(event.getId());
    System.out.println(((Event)m.getValue()).getId());
    if (event.getId().equals(((Event)m.getValue()).getId())) {
      break;
    }
  }
  try {
    displayedEvents.remove(key);
  }
 catch (  Exception e) {
  }
  notifyDataSetChanged();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public void removeEvent(Event event){
  super.remove(event);
  Set<?> s=displayedEvents.entrySet();
  Iterator<?> it=s.iterator();
  int key=-1;
  while (it.hasNext()) {
    Map.Entry m=(Map.Entry)it.next();
    key=(Integer)m.getKey();
    System.out.println(event.getId());
    System.out.println(((BaseEvent)m.getValue()).getId());
    if (event.getId().equals(((BaseEvent)m.getValue()).getId())) {
      break;
    }
  }
  try {
    displayedEvents.remove(key);
  }
 catch (  Exception e) {
  }
  notifyDataSetChanged();
}
Program: 3032
Project: 3032
Buggy source:
protected void openExperience(Experience experience){
  String databaseName=experience.getTitle();
  boolean shared=experience.isShared();
  String id=experience.getId();
  receivedIntent.putExtra(Utilities.DATABASENAME_REQUEST,databaseName);
  receivedIntent.putExtra(Utilities.SHARED_REQUEST,shared);
  receivedIntent.putExtra(Utilities.EXPERIENCEID_REQUEST,id);
  receivedIntent.putExtra(Utilities.EXPERIENCECREATOR_REQUEST,experience.getUser().name);
  context.startActivity(receivedIntent);
  this.dismiss();
}

Fixed version (ground truth):
protected void openExperience(Experience experience){
  String databaseName=experience.getTitle() + "String_Node_Str";
  boolean shared=experience.isShared();
  String id=experience.getId();
  receivedIntent.putExtra(Utilities.DATABASENAME_REQUEST,databaseName);
  receivedIntent.putExtra(Utilities.SHARED_REQUEST,shared);
  receivedIntent.putExtra(Utilities.EXPERIENCEID_REQUEST,id);
  receivedIntent.putExtra(Utilities.EXPERIENCECREATOR_REQUEST,experience.getUser().name);
  context.startActivity(receivedIntent);
  this.dismiss();
}
Program: 3033
Project: 3033
Buggy source:
public Event(String id,String exID,Date dateTime,Location location,Account user){
  super(id,exID,dateTime,location,user);
  eventItems=new ArrayList<EventItem>();
  emotionList=new ArrayList<Emotion>();
}

Fixed version (ground truth):
public Event(String id,String exID,Date dateTime,Location location,Account user){
  super(id,exID,dateTime,location,user);
  eventItems=new ArrayList<EventItem>();
  emotionList=new ArrayList<Emotion>();
  className=this.getClass().getSimpleName();
}
Program: 3034
Project: 3034
Buggy source:
public MoodEvent(String id,String experienceID,Date dateTime,Location location,MoodEnum mood,Account user){
  super(id,experienceID,dateTime,location,user);
  this.mood=mood;
}

Fixed version (ground truth):
public MoodEvent(String id,String experienceID,Date dateTime,Location location,MoodEnum mood,Account user){
  super(id,experienceID,dateTime,location,user);
  this.mood=mood;
  className=this.getClass().getSimpleName();
}
Program: 3035
Project: 3035
Buggy source:
public JsonElement serialize(Event src,Type typeOfSrc,JsonSerializationContext context){
  if (src.getEmotionList().size() == 0)   src.setEmotionList(null);
  Gson gson=new Gson();
  return new JsonParser().parse(gson.toJson(src));
}

Fixed version (ground truth):
public JsonElement serialize(Experiences src,Type typeOfSrc,JsonSerializationContext context){
  if (src.getExperiences().size() == 0)   src.setExperiences(null);
 else {
    for (    Experience ex : src.getExperiences()) {
      if (ex.getEvents().size() == 0)       ex.setEvents(null);
 else {
        for (        BaseEvent baseEvent : ex.getEvents()) {
          if (baseEvent instanceof Event) {
            BaseEvent bEvent=new BaseEvent(baseEvent.getId(),baseEvent.getExperienceid(),baseEvent.getDatetime(),baseEvent.getLocation(),baseEvent.getUser());
            bEvent.setClassName(baseEvent.getClassName());
            if (((Event)baseEvent).getEmotionList().size() == 0)             bEvent.setEmotionList(null);
 else             bEvent.setEmotionList(baseEvent.getEmotionList());
            if (((Event)baseEvent).getEventItems().size() == 0)             bEvent.setEventItems(null);
 else             bEvent.setEventItems(((Event)baseEvent).getEventItems());
            ex.getEvents().add(bEvent);
            ex.getEvents().remove(baseEvent);
          }
 else           if (baseEvent instanceof MoodEvent) {
            baseEvent=(BaseEvent)baseEvent;
            baseEvent.setClassName(((MoodEvent)baseEvent).getClassName());
            baseEvent.setMood(((MoodEvent)baseEvent).getMood());
          }
        }
      }
    }
  }
  Gson gson=new Gson();
  return new JsonParser().parse(gson.toJson(src));
}
Program: 3038
Project: 3038
Buggy source:
public ArrayList<BaseEvent> LoadAllEventsFromDatabase(){
  ArrayList<BaseEvent> allEvents=new ArrayList<BaseEvent>();
  String[] eventTableColumns=new String[]{EventColumns._ID,EventColumns.EVENT_EXPERIENCEID,EventColumns.EVENT_TITLE,EventColumns.EVENT_LOCATION_LAT,EventColumns.EVENT_LOCATION_LNG,EventColumns.IS_SHARED};
  Cursor c=context.getContentResolver().query(EventColumns.CONTENT_URI,eventTableColumns,null,null,null);
  if (c.moveToFirst()) {
    do {
      Date createdDate=new Date(c.getLong(c.getColumnIndex(EventColumns.EVENT_TITLE)));
      Location location=new Location("String_Node_Str");
      location.setLatitude(Double.parseDouble(c.getString(c.getColumnIndex(EventColumns.EVENT_LOCATION_LAT))));
      location.setLongitude(Double.parseDouble(c.getString(c.getColumnIndex(EventColumns.EVENT_LOCATION_LNG))));
      System.out.println("String_Node_Str" + c.getString(c.getColumnIndex(EventColumns.CREATOR)));
      Event event=new Event(c.getString(c.getColumnIndex(EventColumns._ID)),c.getString(c.getColumnIndex(EventColumns.EVENT_EXPERIENCEID)),createdDate,location,new Account(c.getString(c.getColumnIndex(EventColumns.CREATOR)),"String_Node_Str"));
      event.setShared((c.getInt((c.getColumnIndex(EventColumns.IS_SHARED))) == 1) ? true : false);
      loadAllEmotions(event);
      loadAllConnectedEventItems(event);
      allEvents.add(event);
    }
 while (c.moveToNext());
  }
  c.close();
  Log.i("String_Node_Str",allEvents.size() + "String_Node_Str");
  return allEvents;
}

Fixed version (ground truth):
public ArrayList<BaseEvent> LoadAllEventsFromDatabase(){
  ArrayList<BaseEvent> allEvents=new ArrayList<BaseEvent>();
  String[] eventTableColumns=new String[]{EventColumns._ID,EventColumns.EVENT_EXPERIENCEID,EventColumns.EVENT_TITLE,EventColumns.EVENT_LOCATION_LAT,EventColumns.EVENT_LOCATION_LNG,EventColumns.IS_SHARED,EventColumns.CREATOR};
  Cursor c=context.getContentResolver().query(EventColumns.CONTENT_URI,eventTableColumns,null,null,null);
  if (c.moveToFirst()) {
    do {
      Date createdDate=new Date(c.getLong(c.getColumnIndex(EventColumns.EVENT_TITLE)));
      Location location=new Location("String_Node_Str");
      location.setLatitude(Double.parseDouble(c.getString(c.getColumnIndex(EventColumns.EVENT_LOCATION_LAT))));
      location.setLongitude(Double.parseDouble(c.getString(c.getColumnIndex(EventColumns.EVENT_LOCATION_LNG))));
      Event event=new Event(c.getString(c.getColumnIndex(EventColumns._ID)),c.getString(c.getColumnIndex(EventColumns.EVENT_EXPERIENCEID)),createdDate,location,new Account(c.getString(c.getColumnIndex(EventColumns.CREATOR)),"String_Node_Str"));
      event.setShared((c.getInt((c.getColumnIndex(EventColumns.IS_SHARED))) == 1) ? true : false);
      loadAllEmotions(event);
      loadAllConnectedEventItems(event);
      allEvents.add(event);
    }
 while (c.moveToNext());
  }
  c.close();
  Log.i("String_Node_Str",allEvents.size() + "String_Node_Str");
  return allEvents;
}
Program: 3039
Project: 3039
Buggy source:
/** 
 * Synchronize shared timelines with database.
 */
private void syncTimelines(){
  UserAndGroupServiceHandler ugHandler=new UserAndGroupServiceHandler(this,this);
  ugHandler.downloadUsersAndGroups();
  ArrayList<Experience> sharedExperiences=contentLoader.LoadAllSharedExperiencesFromDatabase();
  for (  Experience experience : sharedExperiences) {
    new DatabaseHelper(this,experience.getTitle() + "String_Node_Str");
    experience.setEvents(contentLoader.LoadAllEventsFromDatabase());
    DatabaseHelper.getCurrentTimelineDatabase().close();
  }
  Experiences experiences=new Experiences(sharedExperiences);
  GAEHandler.send(experiences,this);
  Experiences exps=Downloader.getAllSharedExperiencesFromServer(user);
  if (exps != null) {
    for (    Experience e : exps.getExperiences()) {
      e.setSharingGroupObject(uGManager.getGroupFromDatabase(e.getSharingGroup()));
      contentAdder.addExperienceToTimelineContentProvider(e);
      addNewTimelineToTimelineDatabase(e);
    }
  }
  runOnUiThread(confirmSync);
}

Fixed version (ground truth):
/** 
 * Synchronize shared timelines with database.
 */
private void syncTimelines(){
  UserAndGroupServiceHandler ugHandler=new UserAndGroupServiceHandler(this,this);
  ugHandler.downloadUsersAndGroups();
  ArrayList<Experience> sharedExperiences=contentLoader.LoadAllSharedExperiencesFromDatabase();
  for (  Experience experience : sharedExperiences) {
    new DatabaseHelper(this,experience.getTitle() + "String_Node_Str");
    experience.setEvents(contentLoader.LoadAllEventsFromDatabase());
    DatabaseHelper.getCurrentTimelineDatabase().close();
  }
  Experiences experiences=new Experiences(sharedExperiences);
  GAEHandler.persistTimelineObject(experiences);
  Experiences exps=Downloader.getAllSharedExperiencesFromServer(user);
  if (exps != null) {
    for (    Experience e : exps.getExperiences()) {
      e.setSharingGroupObject(uGManager.getGroupFromDatabase(e.getSharingGroup()));
      contentAdder.addExperienceToTimelineContentProvider(e);
      addNewTimelineToTimelineDatabase(e);
    }
  }
  runOnUiThread(confirmSync);
}
Program: 3040
Project: 3040
Buggy source:
public void run(){
  GAEHandler.send(moodEvent,TimelineActivity.this);
}

Fixed version (ground truth):
public void run(){
  GAEHandler.persistTimelineObject(moodEvent);
}
Program: 3041
Project: 3041
Buggy source:
private void addMoodEventToTimeline(final MoodEvent moodEvent){
  Runnable SendMoodEventRunnable=new Runnable(){
    public void run(){
      GAEHandler.send(moodEvent,TimelineActivity.this);
    }
  }
;
  timeline.addEvent(moodEvent);
  EventAdapter.updateAdapter();
  contentAdder.addEventToEventContentProvider(moodEvent);
  Thread sendMoodThread=new Thread(SendMoodEventRunnable,"String_Node_Str");
  sendMoodThread.start();
}

Fixed version (ground truth):
private void addMoodEventToTimeline(final MoodEvent moodEvent){
  Runnable SendMoodEventRunnable=new Runnable(){
    public void run(){
      GAEHandler.persistTimelineObject(moodEvent);
    }
  }
;
  timeline.addEvent(moodEvent);
  EventAdapter.updateAdapter();
  contentAdder.addEventToEventContentProvider(moodEvent);
  Thread sendMoodThread=new Thread(SendMoodEventRunnable,"String_Node_Str");
  sendMoodThread.start();
}
Program: 3042
Project: 3042
Buggy source:
public void run(){
  GAEHandler.send(mEvent,mActivity);
  ContentUpdater updater=new ContentUpdater(mContext);
  updater.setEventShared(mEvent);
}

Fixed version (ground truth):
public void run(){
  GAEHandler.persistTimelineObject(mEvent);
  ContentUpdater updater=new ContentUpdater(mContext);
  updater.setEventShared(mEvent);
}
Program: 3045
Project: 3045
Buggy source:
public JsonElement serialize(BaseEvent baseEvent,Type typeOfSrc,JsonSerializationContext context){
  BaseEvent bEvent=new BaseEvent(baseEvent.getId(),baseEvent.getExperienceid(),baseEvent.getDatetime(),baseEvent.getLocation(),baseEvent.getUser());
  if (baseEvent instanceof Event) {
    bEvent.setClassName(baseEvent.getClassName());
    if (((Event)baseEvent).getEmotionList().size() == 0)     bEvent.setEmotionList(null);
 else     bEvent.setEmotionList(baseEvent.getEmotionList());
    if (((Event)baseEvent).getEventItems().size() == 0)     bEvent.setEventItems(null);
 else     bEvent.setEventItems(((Event)baseEvent).getEventItems());
    bEvent.setShared(((Event)baseEvent).isShared());
  }
 else   if (baseEvent instanceof MoodEvent) {
    bEvent.setClassName(((MoodEvent)baseEvent).getClassName());
    bEvent.setMoodInt(((MoodEvent)baseEvent).getMood().getMoodInt());
    bEvent.setShared(((MoodEvent)baseEvent).isShared());
  }
  Gson gson=new Gson();
  return new JsonParser().parse(gson.toJson(bEvent));
}

Fixed version (ground truth):
public JsonElement serialize(BaseEvent baseEvent,Type typeOfSrc,JsonSerializationContext context){
  BaseEvent bEvent=null;
  if (baseEvent instanceof Event) {
    bEvent=convertEventToBaseEvent(baseEvent);
  }
 else   if (baseEvent instanceof MoodEvent) {
    bEvent=convertMoodEventToBaseEvent(baseEvent);
  }
  Gson gson=new Gson();
  return new JsonParser().parse(gson.toJson(bEvent));
}
Program: 3046
Project: 3046
Buggy source:
private void loadAllEmotions(Event event){
  String[] columns=new String[]{EmotionColumns._ID,EmotionColumns.EVENT_ID,EmotionColumns.EMOTION_TYPE};
  String where=EmotionColumns.EVENT_ID + "String_Node_Str" + event.getId()+ "String_Node_Str";
  Cursor listOfEmotions=context.getContentResolver().query(EmotionColumns.CONTENT_URI,columns,where,null,null);
  if (listOfEmotions.moveToFirst()) {
    String id=listOfEmotions.getString(listOfEmotions.getColumnIndex(NoteColumns._ID));
    do {
switch (listOfEmotions.getInt(listOfEmotions.getColumnIndex(EmotionColumns.EMOTION_TYPE))) {
case 1:
        event.addEmotion(new Emotion(id,EmotionEnum.LIKE));
      break;
case 2:
    event.addEmotion(new Emotion(id,EmotionEnum.COOL));
  break;
case 3:
event.addEmotion(new Emotion(id,EmotionEnum.DISLIKE));
break;
case 4:
event.addEmotion(new Emotion(id,EmotionEnum.SAD));
break;
}
}
 while (listOfEmotions.moveToNext());
}
listOfEmotions.close();
}

Fixed version (ground truth):
private void loadAllEmotions(Event event){
  String[] columns=new String[]{EmotionColumns._ID,EmotionColumns.EVENT_ID,EmotionColumns.EMOTION_TYPE};
  String where=EmotionColumns.EVENT_ID + "String_Node_Str" + event.getId()+ "String_Node_Str";
  Cursor listOfEmotions=context.getContentResolver().query(EmotionColumns.CONTENT_URI,columns,where,null,null);
  if (listOfEmotions.moveToFirst()) {
    do {
      String id=listOfEmotions.getString(listOfEmotions.getColumnIndex(EmotionColumns._ID));
switch (listOfEmotions.getInt(listOfEmotions.getColumnIndex(EmotionColumns.EMOTION_TYPE))) {
case 1:
        event.addEmotion(new Emotion(id,EmotionEnum.LIKE));
      break;
case 2:
    event.addEmotion(new Emotion(id,EmotionEnum.COOL));
  break;
case 3:
event.addEmotion(new Emotion(id,EmotionEnum.DISLIKE));
break;
case 4:
event.addEmotion(new Emotion(id,EmotionEnum.SAD));
break;
}
}
 while (listOfEmotions.moveToNext());
}
listOfEmotions.close();
}
Program: 3047
Project: 3047
Buggy source:
/** 
 * @param object The object to send
 * @param a Needs {@link Activity} to get the path of the content?
 */
public static void send(Object object,Activity a){
  Gson gson=new Gson();
  String jsonString="String_Node_Str";
  try {
    jsonString=gson.toJson(object,object.getClass());
  }
 catch (  Exception e) {
    Log.e("String_Node_Str",e.getMessage());
  }
  System.out.println("String_Node_Str" + jsonString);
  Uploader.putToGAE(object,jsonString);
  System.out.println("String_Node_Str");
  if (object instanceof Experiences) {
    for (    Experience ex : ((Experiences)object).getExperiences()) {
      for (      Event event : ex.getEvents()) {
        for (        EventItem eventI : event.getEventItems()) {
          if (eventI instanceof SimplePicture) {
            Uploader.uploadFile(Utilities.IMAGE_STORAGE_FILEPATH + ((SimplePicture)eventI).getPictureFilename(),((SimplePicture)eventI).getPictureFilename());
          }
        }
      }
    }
  }
 else   if (object instanceof Event) {
    for (    EventItem eventI : ((Event)object).getEventItems()) {
      if (eventI instanceof SimplePicture) {
        Uploader.uploadFile(Utilities.getRealPathFromURI(((SimplePicture)eventI).getPictureUri(),a),((SimplePicture)eventI).getPictureFilename());
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * @param object The object to send
 * @param a Needs {@link Activity} to get the path of the content?
 */
public static void send(Object object,Activity a){
  GsonBuilder gsonB=new GsonBuilder();
  gsonB.registerTypeAdapter(Experience.class,new ExperienceSerializer());
  Gson gson=gsonB.create();
  String jsonString="String_Node_Str";
  try {
    jsonString=gson.toJson(object,object.getClass());
  }
 catch (  Exception e) {
    Log.e("String_Node_Str",e.getMessage());
  }
  System.out.println("String_Node_Str" + jsonString);
  Uploader.putToGAE(object,jsonString);
  System.out.println("String_Node_Str");
  if (object instanceof Experiences) {
    for (    Experience ex : ((Experiences)object).getExperiences()) {
      for (      Event event : ex.getEvents()) {
        for (        EventItem eventI : event.getEventItems()) {
          if (eventI instanceof SimplePicture) {
            Uploader.uploadFile(Utilities.IMAGE_STORAGE_FILEPATH + ((SimplePicture)eventI).getPictureFilename(),((SimplePicture)eventI).getPictureFilename());
          }
        }
      }
    }
  }
 else   if (object instanceof Event) {
    for (    EventItem eventI : ((Event)object).getEventItems()) {
      if (eventI instanceof SimplePicture) {
        Uploader.uploadFile(Utilities.getRealPathFromURI(((SimplePicture)eventI).getPictureUri(),a),((SimplePicture)eventI).getPictureFilename());
      }
    }
  }
}
Program: 3049
Project: 3049
Buggy source:
private void calcDistances(MetricsBag bag){
  inDegreesDist=inDegrees.emdDistance(bag.inDegrees);
  outDegreesDist=outDegrees.emdDistance(bag.outDegrees);
  inPageRanksDist=inPageRanks.emdDistance(bag.inPageRanks);
  outPageRanksDist=outPageRanks.emdDistance(bag.outPageRanks);
  triadicProfileDist=triadicProfile.emdDistance(bag.triadicProfile);
  double verySmall=0.999;
  if (inDegreesDist == 0)   inDegreesDist=verySmall;
  if (outDegreesDist == 0)   outDegreesDist=verySmall;
  if (inPageRanksDist == 0)   inPageRanksDist=verySmall;
  if (outPageRanksDist == 0)   outPageRanksDist=verySmall;
  if (triadicProfileDist == 0)   triadicProfileDist=verySmall;
  distance=inDegreesDist * outDegreesDist * inPageRanksDist* outPageRanksDist* triadicProfileDist;
  distance=Math.pow(distance,1.0 / 4.0);
}

Fixed version (ground truth):
private void calcDistances(MetricsBag bag){
  inDegreesDist=inDegrees.emdDistance(bag.inDegrees);
  outDegreesDist=outDegrees.emdDistance(bag.outDegrees);
  inPageRanksDist=inPageRanks.emdDistance(bag.inPageRanks);
  outPageRanksDist=outPageRanks.emdDistance(bag.outPageRanks);
  triadicProfileDist=triadicProfile.emdDistance(bag.triadicProfile);
  double verySmall=0.999;
  if (inDegreesDist == 0)   inDegreesDist=verySmall;
  if (outDegreesDist == 0)   outDegreesDist=verySmall;
  if (inPageRanksDist == 0)   inPageRanksDist=verySmall;
  if (outPageRanksDist == 0)   outPageRanksDist=verySmall;
  if (triadicProfileDist == 0)   triadicProfileDist=verySmall;
  distance=inDegreesDist * outDegreesDist * inPageRanksDist* outPageRanksDist* triadicProfileDist;
  distance=Math.pow(distance,1.0 / 5.0);
}