lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From laimis <...@git.apache.org>
Subject [GitHub] lucenenet pull request: return -1 if reader returns 0 or less
Date Sat, 27 Dec 2014 18:57:59 GMT
GitHub user laimis opened a pull request:

    https://github.com/apache/lucenenet/pull/30

    return -1 if reader returns 0 or less

    This fixes failures that can be observed in Lucene.Net.Analysis tests and possible other
locations with test failure messages like these:
    
    Expected string length 9 but was 13. Strings differ at index 1.
      Expected: "npffoeijg"
      But was:  "n\0pf\0\0\0foeijg"
    
    Expected string length 2 but was 1. Strings differ at index 1.
      Expected: "[\0"
      But was:  "["
    
    Expected string length 6 but was 8. Strings differ at index 6.
      Expected: "432794"
      But was:  "432794\0\0"
    
    MockTokenizer implementation uses equals comparison to 0 to check for an end of stream
and rewrites it to -1 as Java would return and the calling classes expect. However some of
the implementations (e.g. MockCharFilter) return -1 already and MockTokenizer should handle
that. Without that check it ends up using values in the byte array which in "end of stream"
cases contains \0 chars.
    
    I tried checking other locations for cases of the same bug and could not find any. Although
it does not mean it does not exist. It is so subtle and hard to find, took me forever just
to figure out what was going on. Hopefully we don't have this situation anywhere else, and
if we do, tests will lead us to such locations.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/laimis/lucenenet MockTokenizer_fixes

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/lucenenet/pull/30.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 #30
    
----
commit ff4ef2840d4d5f0cfa7d27db2973d84e64bd666a
Author: Laimonas Simutis <laimis@gmail.com>
Date:   2014-12-27T18:38:29Z

    return -1 if reader returns 0 or less

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message