Program: 86548
Project: 86548
Buggy source:
/** 
 * When inserting a point in the already processed mesh, we must determine  if we are in a triangle or on an edge. Here, we are on an edge.<br/> <code>contEdge</code> will be split in two edges using <code>pt</code>. The new point, new edges and new triangles will be added to the mesh. The edges that could be  eligible for a flip-flap are stored in <code>badEdges</code> The method return a DEdge, which is the first edge of the triangles linked (left or right) to the original edge that becomes encroached because of the insertion, if any.
 * @param pt
 * @param contEdge
 * @param badEdges
 * @return
 * @throws DelaunayError 
 */
final DEdge initPointOnEdge(final DPoint pt,DEdge contEdge,Deque<DEdge> badEdges) throws DelaunayError {
  DTriangle left=contEdge.getLeft();
  DTriangle right=contEdge.getRight();
  DEdge r1=null;
  DEdge r2=null;
  DEdge l1=null;
  DEdge l2=null;
  DEdge otherPart=new DEdge(pt,contEdge.getEndPoint());
  if (left != null) {
    l1=left.getOppositeEdge(contEdge.getEndPoint());
    l2=left.getOppositeEdge(contEdge.getStartPoint());
    badEdges.add(l1);
    badEdges.add(l2);
    DPoint opLeft=left.getOppositePoint(contEdge);
    DEdge lastLeft=new DEdge(pt,opLeft);
    DTriangle otl=new DTriangle(l2,otherPart,lastLeft);
    left.setEdge(left.getEdgeIndex(l2),lastLeft);
    edgeGID++;
    lastLeft.setGID(edgeGID);
    edges.add(lastLeft);
    addTriangle(otl);
  }
  if (right != null) {
    r1=right.getOppositeEdge(contEdge.getEndPoint());
    r2=right.getOppositeEdge(contEdge.getStartPoint());
    badEdges.add(r1);
    badEdges.add(r2);
    DPoint opRight=right.getOppositePoint(contEdge);
    DEdge lastRight=new DEdge(pt,opRight);
    DTriangle otr=new DTriangle(r2,otherPart,lastRight);
    right.setEdge(right.getEdgeIndex(r2),lastRight);
    edgeGID++;
    lastRight.setGID(edgeGID);
    edges.add(lastRight);
    addTriangle(otr);
  }
  contEdge.setEndPoint(pt);
  pointGID++;
  pt.setGID(pointGID);
  points.add(pt);
  edgeGID++;
  otherPart.setGID(edgeGID);
  edges.add(otherPart);
  contEdge.setEndPoint(pt);
  if (left != null) {
    left.recomputeCenter();
    if (l1.isEncroached()) {
      return l1;
    }
 else     if (l2.isEncroached()) {
      return l2;
    }
  }
  if (right != null) {
    right.recomputeCenter();
    if (r1.isEncroached()) {
      return r1;
    }
 else     if (r2.isEncroached()) {
      return r2;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * When inserting a point in the already processed mesh, we must determine  if we are in a triangle or on an edge. Here, we are on an edge.<br/> <code>contEdge</code> will be split in two edges using <code>pt</code>. The new point, new edges and new triangles will be added to the mesh. The edges that could be  eligible for a flip-flap are stored in <code>badEdges</code> The method return a DEdge, which is the first edge of the triangles linked (left or right) to the original edge that becomes encroached because of the insertion, if any.
 * @param pt
 * @param contEdge
 * @param badEdges
 * @return
 * @throws DelaunayError 
 */
final DEdge initPointOnEdge(final DPoint pt,DEdge contEdge,Deque<DEdge> badEdges) throws DelaunayError {
  DTriangle left=contEdge.getLeft();
  DTriangle right=contEdge.getRight();
  DEdge r1=null;
  DEdge r2=null;
  DEdge l1=null;
  DEdge l2=null;
  DEdge otherPart=new DEdge(pt,contEdge.getEndPoint());
  if (left != null) {
    l1=left.getOppositeEdge(contEdge.getEndPoint());
    l2=left.getOppositeEdge(contEdge.getStartPoint());
    badEdges.add(l1);
    badEdges.add(l2);
    DPoint opLeft=left.getOppositePoint(contEdge);
    DEdge lastLeft=new DEdge(pt,opLeft);
    DTriangle otl=new DTriangle(l2,otherPart,lastLeft);
    left.setEdge(left.getEdgeIndex(l2),lastLeft);
    lastLeft.setLeft(left);
    edgeGID++;
    lastLeft.setGID(edgeGID);
    edges.add(lastLeft);
    addTriangle(otl);
  }
  if (right != null) {
    r1=right.getOppositeEdge(contEdge.getEndPoint());
    r2=right.getOppositeEdge(contEdge.getStartPoint());
    badEdges.add(r1);
    badEdges.add(r2);
    DPoint opRight=right.getOppositePoint(contEdge);
    DEdge lastRight=new DEdge(pt,opRight);
    DTriangle otr=new DTriangle(r2,otherPart,lastRight);
    right.setEdge(right.getEdgeIndex(r2),lastRight);
    lastRight.setRight(right);
    edgeGID++;
    lastRight.setGID(edgeGID);
    edges.add(lastRight);
    addTriangle(otr);
  }
  contEdge.setEndPoint(pt);
  pointGID++;
  pt.setGID(pointGID);
  points.add(pt);
  edgeGID++;
  otherPart.setGID(edgeGID);
  edges.add(otherPart);
  contEdge.setEndPoint(pt);
  if (left != null) {
    left.recomputeCenter();
    if (l1.isEncroached()) {
      return l1;
    }
 else     if (l2.isEncroached()) {
      return l2;
    }
  }
  if (right != null) {
    right.recomputeCenter();
    if (r1.isEncroached()) {
      return r1;
    }
 else     if (r2.isEncroached()) {
      return r2;
    }
  }
  return null;
}