lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fabio Buscaroli (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENENET-8) Throwing an exception as a result of a normal situation is extremely bad in .net
Date Thu, 13 Jul 2006 12:19:30 GMT
    [ http://issues.apache.org/jira/browse/LUCENENET-8?page=comments#action_12420858 ] 

Fabio Buscaroli commented on LUCENENET-8:
-----------------------------------------

i agree, and i would address also the implementation of FieldInfos.FieldName(int fieldNumber).

this is the original method implementation
try 
{
return FieldInfo(fieldNumber).name;
 }
catch (System.NullReferenceException)
{
return "";
}

fieldNumber is -1 when the indexread does the first read. i have a web application and indexreader
are open and disponed frequently so, this kind of exception occurs at any search.

this simple code would solve the problem:

public System.String FieldName(int fieldNumber)
{
if (fieldNumber != -1)
{
try
{
    return FieldInfo(fieldNumber).name;
}
catch (System.NullReferenceException)
{
    return String.Empty;
}
}

return String.Empty;
}



> Throwing an exception as a result of a normal situation is extremely bad in .net
> --------------------------------------------------------------------------------
>
>          Key: LUCENENET-8
>          URL: http://issues.apache.org/jira/browse/LUCENENET-8
>      Project: Lucene.Net
>         Type: Task

>  Environment: Windows XP, Visual Studio 2003
>     Reporter: Jo Inge Arnes

>
> 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"

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message