[ 
https://issues.apache.org/jira/browse/LUCENE-10052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17400598#comment-17400598
 ] 

ASF subversion and git services commented on LUCENE-10052:
----------------------------------------------------------

Commit 65a53450dcf0219923e1f727f14cf507fb48db60 in lucene's branch 
refs/heads/main from Michael McCandless
[ https://gitbox.apache.org/repos/asf?p=lucene.git;h=65a5345 ]

LUCENE-10052: first cut at LTC.newBytesRef methods, and switching a few test 
cases over (#245)

* LUCENE-10052: first cut at LTC.newBytesRef methods, to randomize the 
offset/length of a BytesRef, and switching a few test cases over

> Add LuceneTestCase.newBytesRef methods
> --------------------------------------
>
>                 Key: LUCENE-10052
>                 URL: https://issues.apache.org/jira/browse/LUCENE-10052
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>            Priority: Major
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {{BytesRef}} is a super useful Lucene utility class, referencing a slice 
> (offset + length) of an underlying possibly larger {{byte[]}}.  We use it all 
> over the place in our APIs.
> But the {{offset}} is trappy – we programmers sometimes forget to add the 
> {{offset}} when accessing the underlying bytes.  Or sometimes we accidentally 
> add it twice, as just happened in our (Amazon Product Search) Lucene usage.  
> Such errors are devious because they often do not matter since typically 
> {{offset}} will be zero, but then suddenly when the rare {{BytesRef}} arrives 
> with non-zero {{offset}}, BOOM.
> I think we should improve our testing here by making it simple to randomize a 
> {{BytesRef}} creation to sometimes use non-zero offset and also to sometimes 
> leave extra padding on the end of the underlying {{byte[]}} to catch another 
> trappy case where we use {{bytesRef.bytes.length}} when we were supposed to 
> use {{bytesRef.length}}.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to