mirror of https://github.com/apache/lucene.git
SOLR-13285: Updates with enum fields and javabin cause ClassCastException
This commit is contained in:
parent
876fcb7f7b
commit
7771d7bb84
|
@ -92,6 +92,8 @@ Bug Fixes
|
||||||
* SOLR-9882: 500 error code on breaching timeAllowed by core and distributed (fsv) search,
|
* SOLR-9882: 500 error code on breaching timeAllowed by core and distributed (fsv) search,
|
||||||
old and json facets (Mikhail Khludnev)
|
old and json facets (Mikhail Khludnev)
|
||||||
|
|
||||||
|
* SOLR-13285: Updates with enum fields and javabin cause ClassCastException (noble)
|
||||||
|
|
||||||
Improvements
|
Improvements
|
||||||
----------------------
|
----------------------
|
||||||
* SOLR-12999: Index replication could delete segments before downloading segments from master if there is not enough
|
* SOLR-12999: Index replication could delete segments before downloading segments from master if there is not enough
|
||||||
|
|
|
@ -53,6 +53,8 @@ import org.noggit.CharArr;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import static org.apache.solr.common.util.ByteArrayUtf8CharSequence.convertCharSeq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a space-efficient serialization/deserialization format for transferring data.
|
* Defines a space-efficient serialization/deserialization format for transferring data.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -818,7 +820,7 @@ public class JavaBinCodec implements PushWriter {
|
||||||
*/
|
*/
|
||||||
public EnumFieldValue readEnumFieldValue(DataInputInputStream dis) throws IOException {
|
public EnumFieldValue readEnumFieldValue(DataInputInputStream dis) throws IOException {
|
||||||
Integer intValue = (Integer) readVal(dis);
|
Integer intValue = (Integer) readVal(dis);
|
||||||
String stringValue = (String) readVal(dis);
|
String stringValue = (String) convertCharSeq (readVal(dis));
|
||||||
return new EnumFieldValue(intValue, stringValue);
|
return new EnumFieldValue(intValue, stringValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,20 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testReadAsCharSeq() throws Exception {
|
||||||
|
List<Object> types = new ArrayList<>();
|
||||||
|
SolrInputDocument idoc = new SolrInputDocument();
|
||||||
|
idoc.addField("foo", "bar");
|
||||||
|
idoc.addField("foos", Arrays.asList("bar1","bar2"));
|
||||||
|
idoc.addField("enumf", new EnumFieldValue(1, "foo"));
|
||||||
|
types.add(idoc);
|
||||||
|
compareObjects(
|
||||||
|
(List) getObject(getBytes(types, true)),
|
||||||
|
(List) types
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static SolrDocument generateSolrDocumentWithChildDocs() {
|
public static SolrDocument generateSolrDocumentWithChildDocs() {
|
||||||
SolrDocument parentDocument = new SolrDocument();
|
SolrDocument parentDocument = new SolrDocument();
|
||||||
parentDocument.addField("id", "1");
|
parentDocument.addField("id", "1");
|
||||||
|
@ -284,6 +298,14 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static byte[] getBytes(Object o, boolean readAsCharSeq) throws IOException {
|
||||||
|
try (JavaBinCodec javabin = new JavaBinCodec(); ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||||
|
javabin.readStringAsCharSeq = readAsCharSeq;
|
||||||
|
javabin.marshal(o, baos);
|
||||||
|
return baos.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Object getObject(byte[] bytes) throws IOException {
|
private static Object getObject(byte[] bytes) throws IOException {
|
||||||
try (JavaBinCodec jbc = new JavaBinCodec()) {
|
try (JavaBinCodec jbc = new JavaBinCodec()) {
|
||||||
return jbc.unmarshal(new ByteArrayInputStream(bytes));
|
return jbc.unmarshal(new ByteArrayInputStream(bytes));
|
||||||
|
|
Loading…
Reference in New Issue