diff --git a/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java b/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java index 15a5da0cd2f..d27f89b6415 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java +++ b/lucene/core/src/java/org/apache/lucene/index/SortedDocValues.java @@ -110,20 +110,10 @@ public abstract class SortedDocValues extends BinaryDocValues { } else if (cmp > 0) { high = mid - 1; } else { - // nocommit: we shouldnt have to set spare at all if its actually a spare, but its not! - // ant test -Dtestcase=TestFieldCacheRewriteMethod -Dtests.method=testRegexps -Dtests.seed=AFC4A08B212CE143 -Dtests.slow=true -Dtests.locale=th -Dtests.timezone=Canada/Mountain -Dtests.file.encoding=ISO-8859-1 - spare.bytes = BytesRef.EMPTY_BYTES; - spare.offset = 0; - spare.length = 0; return mid; // key found } } - // nocommit: we shouldnt have to set spare at all if its actually a spare, but its not! - // ant test -Dtestcase=TestFieldCacheRewriteMethod -Dtests.method=testRegexps -Dtests.seed=AFC4A08B212CE143 -Dtests.slow=true -Dtests.locale=th -Dtests.timezone=Canada/Mountain -Dtests.file.encoding=ISO-8859-1 - spare.bytes = BytesRef.EMPTY_BYTES; - spare.offset = 0; - spare.length = 0; return -(low + 1); // key not found. } } diff --git a/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesTermsEnum.java b/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesTermsEnum.java index 4151a47563b..6dd1bec15ed 100644 --- a/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesTermsEnum.java +++ b/lucene/core/src/java/org/apache/lucene/index/SortedDocValuesTermsEnum.java @@ -42,6 +42,10 @@ public class SortedDocValuesTermsEnum extends TermsEnum { if (ord >= 0) { currentOrd = ord; term.offset = 0; + // nocommit is there cleaner way ... + // term.bytes may be pointing to codec-private byte[] + // storage, so we must force new byte[] allocation: + term.bytes = new byte[text.length]; term.copyBytes(text); return SeekStatus.FOUND; } else { @@ -60,7 +64,6 @@ public class SortedDocValuesTermsEnum extends TermsEnum { public boolean seekExact(BytesRef text, boolean useCache) throws IOException { int ord = values.lookupTerm(text, term); if (ord >= 0) { - term.copyBytes(text); currentOrd = ord; return true; } else {