[
https://issues.apache.org/jira/browse/LUCENE-6321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14345045#comment-14345045
]
Adrien Grand commented on LUCENE-6321:
--------------------------------------
OK to not make Term cloneable.
The test that showed the issue is ThreadedIndexingAndSearchingTestCase which
has the following code:
{noformat}
while (System.currentTimeMillis() < stopTimeMS) {
BytesRef term = termsEnum.next();
if (term == null) {
totTermCount.set(seenTermCount);
break;
}
seenTermCount++;
// search 30 terms
if ((seenTermCount + shift) % trigger == 0) {
//if (VERBOSE) {
//System.out.println(Thread.currentThread().getName() +
" now search body:" + term.utf8ToString());
//}
totHits.addAndGet(runQuery(s, new TermQuery(new
Term("body", term))));
}
}
{noformat}
> Make oal.index.Term more defensive
> ----------------------------------
>
> Key: LUCENE-6321
> URL: https://issues.apache.org/jira/browse/LUCENE-6321
> Project: Lucene - Core
> Issue Type: Bug
> Reporter: Adrien Grand
> Assignee: Adrien Grand
> Priority: Minor
> Attachments: LUCENE-6321.patch
>
>
> oal.index.Term has a Term(String field, BytesRef termBytes) constructor. Even
> though it warns that the term bytes should not be reused, I'm wondering that
> we should make it more defensive.
> {noformat}
> * <p>WARNING: the provided BytesRef is not copied, but used directly.
> * Therefore the bytes should not be modified after construction, for
> * example, you should clone a copy by {@link BytesRef#deepCopyOf}
> * rather than pass reused bytes from a TermsEnum.
> {noformat}
> For example if you have term queries in your query cache and they are
> modified in-place, it would have very bad consequences and would be hard to
> diagnose.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]