You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by an...@apache.org on 2019/03/08 09:33:23 UTC
[lucene-solr] branch branch_8_0 updated: SOLR-13285: Updates with
enum fields and javabin cause ClassCastException
This is an automated email from the ASF dual-hosted git repository.
anshum pushed a commit to branch branch_8_0
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8_0 by this push:
new 2ae4746 SOLR-13285: Updates with enum fields and javabin cause ClassCastException
2ae4746 is described below
commit 2ae4746365c1ee72a0047ced7610b2096e438979
Author: Noble Paul <no...@apache.org>
AuthorDate: Mon Mar 4 10:24:57 2019 +1100
SOLR-13285: Updates with enum fields and javabin cause ClassCastException
---
solr/CHANGES.txt | 3 ++-
.../org/apache/solr/common/util/JavaBinCodec.java | 4 +++-
.../apache/solr/common/util/TestJavaBinCodec.java | 22 ++++++++++++++++++++++
3 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 5c8164a..7031f69 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -193,8 +193,9 @@ Bug Fixes
* SOLR-13255 : ClasscastException when URPs try to read a String field which returns a ByteArrayUTF8CHarSequence . This is a regression
in release 7.7 (noble)
-*SOLR-13299: Fix Windows startup script to disable HTTP/2 if TLS is enabled on Java 8. (Uwe Schindler)
+* SOLR-13299: Fix Windows startup script to disable HTTP/2 if TLS is enabled on Java 8. (Uwe Schindler)
+* SOLR-13285: Updates with enum fields and javabin cause ClassCastException (noble)
Improvements
----------------------
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java b/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
index 905f6b9..634ecb4 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/JavaBinCodec.java
@@ -53,6 +53,8 @@ import org.noggit.CharArr;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.apache.solr.common.util.ByteArrayUtf8CharSequence.convertCharSeq;
+
/**
* Defines a space-efficient serialization/deserialization format for transferring data.
* <p>
@@ -810,7 +812,7 @@ public class JavaBinCodec implements PushWriter {
*/
public EnumFieldValue readEnumFieldValue(DataInputInputStream dis) throws IOException {
Integer intValue = (Integer) readVal(dis);
- String stringValue = (String) readVal(dis);
+ String stringValue = (String) convertCharSeq (readVal(dis));
return new EnumFieldValue(intValue, stringValue);
}
diff --git a/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java b/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java
index e60d8c7..829d05e 100644
--- a/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java
+++ b/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java
@@ -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
+ );
+
+ }
+
private SolrDocument generateSolrDocumentWithChildDocs() {
SolrDocument parentDocument = new SolrDocument();
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 {
try (JavaBinCodec jbc = new JavaBinCodec()) {
return jbc.unmarshal(new ByteArrayInputStream(bytes));