Buggy code:
public class BentleyOttmann { private static final boolean DEBUG = true ; public static ArrayList < Vertex > findIntersects ( PolyLine polyLine , LineSegmentList inputSegments ) { LineSegmentList segmentList ; if ( ( polyLine == null ) && ( inputSegments != null ) ) { segmentList = inputSegments ; } else { segmentList = new LineSegmentList ( polyLine ) ; } SweepLine SL = new SweepLine ( ) ; EventList eventList = new EventList ( segmentList ) ; ArrayList < Vertex > intersectionPointList = new ArrayList < Vertex > ( ) ; if ( BentleyOttmann . DEBUG ) System . out . println ( ( "EventList<seq2seq4repair_space>at<seq2seq4repair_space>Start:<seq2seq4repair_space>" + eventList ) ) ; EventPoint currentPoint = eventList . deQueue ( ) ; while ( ( eventList . size ( ) ) > 0 ) { if ( BentleyOttmann . DEBUG ) System . out . println ( ( "current<seq2seq4repair_space>Point<seq2seq4repair_space>checking:<seq2seq4repair_space>" + currentPoint ) ) ; if ( ( currentPoint . isLeftPoint ( ) ) == true ) { LineSegment currentSegment = currentPoint . getLineSegment1 ( ) ; LineSegment [ ] AB = SL . insertSorted ( currentSegment , currentPoint . getX ( ) ) ; LineSegment above = AB [ 0 ] ; LineSegment below = AB [ 1 ] ; if ( above != null ) { if ( MatrixVectorFunctions . doesIntersect ( above , currentSegment ) ) { if ( BentleyOttmann . DEBUG ) System . out . println ( ( "new<seq2seq4repair_space>intersect<seq2seq4repair_space>found.<seq2seq4repair_space>" + ( MatrixVectorFunctions . intersectionPoint ( above , currentSegment ) ) ) ) ; eventList . insertSorted ( new EventPoint ( MatrixVectorFunctions . intersectionPoint ( above , currentSegment ) , above , currentSegment , true , false ) ) ; } } if ( below != null ) { if ( MatrixVectorFunctions . doesIntersect ( below , currentSegment ) ) { if ( BentleyOttmann . DEBUG ) System . out . println ( ( "new<seq2seq4repair_space>intersect<seq2seq4repair_space>found:<seq2seq4repair_space>" + ( MatrixVectorFunctions . intersectionPoint ( below , currentSegment ) ) ) ) ; eventList . insertSorted ( new EventPoint ( MatrixVectorFunctions . intersectionPoint ( below , currentSegment ) , currentSegment , below , true , false ) ) ; } } } else if ( ( ( currentPoint . isLeftPoint ( ) ) == false ) && ( ( currentPoint . isIntersectionPoint ( ) ) == false ) ) { LineSegment currentSegment = currentPoint . getLineSegment1 ( ) ; <START_BUG> LineSegment [ ] AB = SL . delete ( currentSegment , currentPoint . getX ( ) ) ; <END_BUG> LineSegment above = AB [ 0 ] ; LineSegment below = AB [ 1 ] ; if ( ( above != null ) && ( below != null ) ) { if ( MatrixVectorFunctions . doesIntersect ( above , below ) ) { if ( BentleyOttmann . DEBUG ) System . out . println ( ( "new<seq2seq4repair_space>intersect<seq2seq4repair_space>found:<seq2seq4repair_space>" + ( MatrixVectorFunctions . intersectionPoint ( above , below ) ) ) ) ; eventList . insertSorted ( new EventPoint ( MatrixVectorFunctions . intersectionPoint ( above , below ) , above , below , true , false ) ) ; } } } else { if ( BentleyOttmann . DEBUG ) System . out . println ( ( ( ( ( "intersection<seq2seq4repair_space>Point<seq2seq4repair_space>reached:<seq2seq4repair_space>(" + ( currentPoint . getX ( ) ) ) + "," ) + ( currentPoint . getY ( ) ) ) + ")" ) ) ; intersectionPointList . add ( new Vertex ( currentPoint . getX ( ) , currentPoint . getY ( ) ) ) ; LineSegment intersectA = currentPoint . getLineSegment1 ( ) ; LineSegment intersectB = currentPoint . getLineSegment2 ( ) ; LineSegment [ ] AB = SL . swap ( intersectA , intersectB , currentPoint . getX ( ) ) ; LineSegment aboveA = AB [ 0 ] ; LineSegment belowB = AB [ 1 ] ; if ( ( aboveA == null ) && ( belowB == null ) ) { } else { if ( aboveA != null ) { if ( MatrixVectorFunctions . doesIntersect ( aboveA , intersectB ) ) { if ( BentleyOttmann . DEBUG ) System . out . println ( ( "new<seq2seq4repair_space>intersect<seq2seq4repair_space>found:<seq2seq4repair_space>" + ( MatrixVectorFunctions . intersectionPoint ( aboveA , intersectB ) ) ) ) ; eventList . insertSorted ( new EventPoint ( MatrixVectorFunctions . intersectionPoint ( aboveA , intersectB ) , aboveA , intersectB , true , false ) ) ; } } if ( belowB != null ) { if ( MatrixVectorFunctions . doesIntersect ( intersectA , belowB ) ) { if ( BentleyOttmann . DEBUG ) System . out . println ( ( "new<seq2seq4repair_space>intersect<seq2seq4repair_space>found:<seq2seq4repair_space>" + ( MatrixVectorFunctions . intersectionPoint ( intersectA , belowB ) ) ) ) ; eventList . insertSorted ( new EventPoint ( MatrixVectorFunctions . intersectionPoint ( intersectA , belowB ) , intersectA , belowB , true , false ) ) ; } } } } if ( BentleyOttmann . DEBUG ) System . out . println ( ( ( "End<seq2seq4repair_space>of<seq2seq4repair_space>current<seq2seq4repair_space>point.<seq2seq4repair_space>EventList:<seq2seq4repair_space>" + eventList ) + "\n" ) ) ; if ( BentleyOttmann . DEBUG ) System . out . println ( ( ( "Sweepline:<seq2seq4repair_space>" + SL ) + "\n" ) ) ; currentPoint = eventList . deQueue ( ) ; } System . out . println ( ( "number<seq2seq4repair_space>of<seq2seq4repair_space>intersection<seq2seq4repair_space>points:<seq2seq4repair_space>" + ( intersectionPointList . size ( ) ) ) ) ; System . out . println ( intersectionPointList ) ; return intersectionPointList ; } }

Fix:
LineSegment [ ] AB = SL . delete ( currentSegment ) ;