Uploaded image for project: 'Lucene.Net'
  1. Lucene.Net
  2. LUCENENET-8

Throwing an exception as a result of a normal situation is extremely bad in .net

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Major
    • Resolution: Invalid
    • None
    • None
    • None
    • None
    • Windows XP, Visual Studio 2003

    Description

      At the end of the FastCharStream.Refill() method, it says:

      int charsRead = input.Read(buffer, newPosition, buffer.Length - newPosition);
      if (charsRead <= 0)
      throw new System.IO.IOException("read past eof");
      else
      bufferLength += charsRead;

      When I run Lucene in the debugger, this causes an exception to be thrown all the time.
      To me it looks like it is thrown as a result of a normal situation, not because of some critical error.

      Is this correct?

      If this is the case, then the code is horrible. Throwing an exception in .NET is extremely slow, and should never be thrown as a result of a normal situation. I repeat: "extremely slow"

      Attachments

        1. test.patch
          4 kB
          Asgeir Halldorsson

        Activity

          People

            digydigy Digy
            joinge Jo Inge Arnes
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: