You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "Marco Dissel (JIRA)" <ji...@apache.org> on 2006/11/02 22:59:17 UTC
[jira] Commented: (LUCENENET-26) ArgumentOutOfRangeException in
FieldInfo(int fieldNumber) constructor
[ http://issues.apache.org/jira/browse/LUCENENET-26?page=comments#action_12446736 ]
Marco Dissel commented on LUCENENET-26:
---------------------------------------
And another related NullReferenceException in the code above FieldInfo(int fieldNumber)
Changed code:
/// <summary> Return the fieldName identified by its number.
///
/// </summary>
/// <param name="fieldNumber">
/// </param>
/// <returns> the fieldName or an empty string when the field
/// with the given number doesn't exist.
/// </returns>
public System.String FieldName(int fieldNumber)
{
FieldInfo fieldInfo = FieldInfo(fieldNumber);
if (fieldInfo != null){
return fieldInfo.name;
}
return String.Empty;
}
> 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