mirror of https://github.com/apache/lucene.git
LUCENE-4942: Fix BytesRefIteratorTokenStream's attribute clone method.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1665949 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5a0e0e007a
commit
9cf30e5ed2
|
@ -87,7 +87,9 @@ class BytesRefIteratorTokenStream extends TokenStream {
|
|||
|
||||
@Override
|
||||
public BRTermToBytesRefAttributeImpl clone() {
|
||||
final BRTermToBytesRefAttributeImpl clone = (BRTermToBytesRefAttributeImpl) super.clone();
|
||||
// super.clone won't work since we need a new BytesRef reference and it's nice to have it final. The superclass
|
||||
// has no state to copy anyway.
|
||||
final BRTermToBytesRefAttributeImpl clone = new BRTermToBytesRefAttributeImpl();
|
||||
clone.setBytesRef(BytesRef.deepCopyOf(bytes));
|
||||
return clone;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ import org.junit.Before;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -423,6 +425,12 @@ public class FieldAnalysisRequestHandlerTest extends AnalysisRequestHandlerTestB
|
|||
((NamedList)result.get("field_types").get("location_rpt")).get("index");
|
||||
List<NamedList> tokenList = tokens.get("org.apache.lucene.spatial.prefix.BytesRefIteratorTokenStream");
|
||||
|
||||
assertTrue( tokenList.get(0).get("text").toString().startsWith("s") );
|
||||
|
||||
List<String> vals = new ArrayList<>(tokenList.size());
|
||||
for(NamedList v : tokenList) {
|
||||
vals.add( (String)v.get("text") );
|
||||
}
|
||||
Collections.sort(vals);
|
||||
assertEquals( "[s, s7, s7w, s7w1+, s9, s9v, s9v2+, sp, spp, spp5+, sv, svk, svk6+]", vals.toString() );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue