ArgumentOutOfRangeException in FieldInfo(int fieldNumber) constructor
---------------------------------------------------------------------

                 Key: LUCENENET-26
                 URL: http://issues.apache.org/jira/browse/LUCENENET-26
             Project: Lucene.Net
          Issue Type: Improvement
            Reporter: Marco Dissel
            Priority: Trivial


Another exception is raised that can be avoided.. In this case the fieldNumber 
= -1 resulting in the ArgumentOutOfRangeException

This can be easily solved by checking (fieldNumber > -1 && fieldNumber < 
byNumber.Count)

ps. the java version has the same problem..

                /// <summary> Return the fieldinfo object referenced by the 
fieldNumber.</summary>
                /// <param name="fieldNumber">
                /// </param>
                /// <returns> the FieldInfo object or null when the given 
fieldNumber
                /// doesn't exist.
                /// </returns>
                public FieldInfo FieldInfo(int fieldNumber)
                {
                        try
                        {
                                return (FieldInfo) byNumber[fieldNumber];
                        }
                        catch (System.ArgumentOutOfRangeException) // 
(System.IndexOutOfRangeException)
                        {
                                return null;
                        }
                }

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

        

Reply via email to