GitHub user laimis opened a pull request:
https://github.com/apache/lucenenet/pull/136
use GetSafe instead of Get to match java behavior
Discovered this issue while diagnosing why
TestFilteredQuery.TestFilteredQuery_Mem was failing randomly. It came down to a
specific filter that needs to be selected with random at this point:
https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.TestFramework/Util/TestUtil.cs#L1303
that gets selected together with "MatchAllDocs" query, called from here:
https://github.com/apache/lucenenet/blob/master/src/Lucene.Net.Tests/core/Search/TestFilteredQuery.cs#L170
The test fails with:
Test(s) failed. System.ArgumentOutOfRangeException : Index was out of
range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.BitArray.Get(Int32 index)
at Lucene.Net.Util.DocIdBitSet.Get(Int32 index) in
z:\Builds\work\bcdbe6b8cc677a49\src\Lucene.Net.Core\Util\DocIdBitSet.cs:line 71
Lucene.Net data / logic flow matches what Lucene is doing and in this case
Lucene returns False as bitset returns false in case the index is greater than
the bitset length. While BitArray returns exception in that case.
There are more places in the code base that use BitArray.Get, not sure if
it is worth adjusting all of those to use SafeGet or instead fix those as they
are discovered to lead into issues. Open to the suggestions.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/laimis/lucenenet docidbitsetfix
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/lucenenet/pull/136.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #136
----
commit 3d6fb126fcda2dfc1e5a16908f6fb131e1b2b0b1
Author: Laimonas Simutis <[email protected]>
Date: 2015-05-02T14:39:01Z
use GetSafe instead of Get to simulate java behavior
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---