Program: 80082
Project: 80082
Buggy source:
private int outputPortals(File portalFile,HddObjectListReader<Portal> portalPositions,tectonicus.configuration.Map map){
  System.out.println("String_Node_Str");
  if (portalFile.exists())   portalFile.delete();
  int numPortals=0;
  JsArrayWriter jsWriter=null;
  try {
    jsWriter=new JsArrayWriter(portalFile,map.getId() + "String_Node_Str");
    ArrayList<Portal> portals=new ArrayList<Portal>();
    long prevX, prevY, prevZ, firstX, firstZ;
    Portal portal=new Portal();
    portalPositions.read(portal);
    firstX=portal.getX();
    firstZ=portal.getZ();
    prevX=portal.getX();
    prevY=portal.getY();
    prevZ=portal.getZ();
    while (portalPositions.hasNext()) {
      portalPositions.read(portal);
      if ((portal.getX() == prevX && portal.getZ() == prevZ + 1) || (portal.getX() == prevX + 1 && portal.getZ() == prevZ)) {
        prevX=portal.getX();
        prevY=portal.getY();
        prevZ=portal.getZ();
      }
 else {
        portals.add(new Portal(prevX + (firstX - prevX) / 2,prevY,prevZ + (firstZ - prevZ) / 2));
        numPortals++;
        prevX=portal.getX();
        prevY=portal.getY();
        prevZ=portal.getZ();
        firstX=portal.getX();
        firstZ=portal.getZ();
      }
    }
    portals.add(new Portal(portal.getX() + ((firstX - prevX) / 2),portal.getY(),portal.getZ() + (firstZ - prevZ) / 2));
    numPortals++;
    for (    Portal p : portals) {
      final float worldX=p.getX();
      final float worldY=p.getY();
      final float worldZ=p.getZ();
      HashMap<String,String> args=new HashMap<String,String>();
      String posStr="String_Node_Str" + worldX + "String_Node_Str"+ worldY+ "String_Node_Str"+ worldZ+ "String_Node_Str";
      args.put("String_Node_Str",posStr);
      jsWriter.write(args);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
 finally {
    if (jsWriter != null)     jsWriter.close();
  }
  return numPortals;
}

Fixed version (ground truth):
private int outputPortals(File portalFile,HddObjectListReader<Portal> portalPositions,tectonicus.configuration.Map map){
  System.out.println("String_Node_Str");
  if (portalFile.exists())   portalFile.delete();
  int numPortals=0;
  JsArrayWriter jsWriter=null;
  try {
    jsWriter=new JsArrayWriter(portalFile,map.getId() + "String_Node_Str");
    ArrayList<Portal> portals=new ArrayList<Portal>();
    if (portalPositions.hasNext()) {
      long prevX, prevY, prevZ, firstX, firstZ;
      Portal portal=new Portal();
      portalPositions.read(portal);
      firstX=portal.getX();
      firstZ=portal.getZ();
      prevX=portal.getX();
      prevY=portal.getY();
      prevZ=portal.getZ();
      while (portalPositions.hasNext()) {
        portalPositions.read(portal);
        if ((portal.getX() == prevX && portal.getZ() == prevZ + 1) || (portal.getX() == prevX + 1 && portal.getZ() == prevZ)) {
          prevX=portal.getX();
          prevY=portal.getY();
          prevZ=portal.getZ();
        }
 else {
          portals.add(new Portal(prevX + (firstX - prevX) / 2,prevY,prevZ + (firstZ - prevZ) / 2));
          numPortals++;
          prevX=portal.getX();
          prevY=portal.getY();
          prevZ=portal.getZ();
          firstX=portal.getX();
          firstZ=portal.getZ();
        }
      }
      portals.add(new Portal(portal.getX() + ((firstX - prevX) / 2),portal.getY(),portal.getZ() + (firstZ - prevZ) / 2));
      numPortals++;
      for (      Portal p : portals) {
        final float worldX=p.getX();
        final float worldY=p.getY();
        final float worldZ=p.getZ();
        HashMap<String,String> args=new HashMap<String,String>();
        String posStr="String_Node_Str" + worldX + "String_Node_Str"+ worldY+ "String_Node_Str"+ worldZ+ "String_Node_Str";
        args.put("String_Node_Str",posStr);
        jsWriter.write(args);
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
 finally {
    if (jsWriter != null)     jsWriter.close();
  }
  System.out.println("String_Node_Str" + numPortals + "String_Node_Str");
  return numPortals;
}