Program: 80077
Project: 80077
Buggy source:
private int outputPortals(File portalFile,HddObjectListReader<Portal> portalPositions,tectonicus.configuration.Map map,Vector3l spawn){
  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");
    long radius=0;
    long originX=spawn.x;
    long originZ=spawn.z;
    if (map.getWorldSubsetFactory().getClass() == CircularWorldSubsetFactory.class) {
      CircularWorldSubsetFactory subset=(CircularWorldSubsetFactory)map.getWorldSubsetFactory();
      radius=subset.getRadius();
      if (subset.getOrigin() != null) {
        originX=subset.getOrigin().x;
        originZ=subset.getOrigin().z;
      }
    }
    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);
        if (radius != 0 && Math.pow((p.getX() - originX),2) + Math.pow((p.getZ() - originZ),2) < Math.pow(radius,2)) {
          jsWriter.write(args);
        }
 else         if (radius == 0) {
          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;
}

Fixed version (ground truth):
private int outputPortals(File portalFile,HddObjectListReader<Portal> portalPositions,tectonicus.configuration.Map map,Vector3l spawn){
  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");
    long radius=0;
    long originX=spawn.x;
    long originZ=spawn.z;
    if (map.getWorldSubsetFactory().getClass() == CircularWorldSubsetFactory.class) {
      CircularWorldSubsetFactory subset=(CircularWorldSubsetFactory)map.getWorldSubsetFactory();
      radius=subset.getRadius();
      if (subset.getOrigin() != null) {
        originX=subset.getOrigin().x;
        originZ=subset.getOrigin().z;
      }
    }
    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);
        if (radius == 0 || radius != 0 && Math.pow((p.getX() - originX),2) + Math.pow((p.getZ() - originZ),2) < Math.pow(radius,2)) {
          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;
}