You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ho...@apache.org on 2023/07/15 16:56:48 UTC
[solr] branch branch_9x updated: SOLR-16845: BinaryResponseWriter should not attempt cast to Utf8CharSequence (#1728)
This is an automated email from the ASF dual-hosted git repository.
houston pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new dc58d832801 SOLR-16845: BinaryResponseWriter should not attempt cast to Utf8CharSequence (#1728)
dc58d832801 is described below
commit dc58d832801620dae3b8afddc590801637f8e6cf
Author: Alex <st...@apache.org>
AuthorDate: Sat Jul 15 09:52:57 2023 -0700
SOLR-16845: BinaryResponseWriter should not attempt cast to Utf8CharSequence (#1728)
(cherry picked from commit c4fb1010285ddf4034976d003f8c713213ced032)
---
solr/CHANGES.txt | 3 ++-
.../apache/solr/response/BinaryResponseWriter.java | 19 ---------------
.../solr/response/TestBinaryResponseWriter.java | 28 ----------------------
3 files changed, 2 insertions(+), 48 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 600e648e4b2..d6881b35c67 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -16,7 +16,8 @@ Improvements
Optimizations
---------------------
-(No changes)
+
+* SOLR-16845: BinaryResponseWriter should not attempt cast to Utf8CharSequence (Alex Deparvu via Houston Putman)
Bug Fixes
---------------------
diff --git a/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java b/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java
index 7e248891009..7b72c7e78f6 100644
--- a/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java
+++ b/solr/core/src/java/org/apache/solr/response/BinaryResponseWriter.java
@@ -20,7 +20,6 @@ import static org.apache.solr.common.util.ByteArrayUtf8CharSequence.convertCharS
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -31,7 +30,6 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;
-import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.TotalHits;
import org.apache.solr.client.solrj.impl.BinaryResponseParser;
@@ -39,7 +37,6 @@ import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.util.JavaBinCodec;
import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.Utf8CharSequence;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.SchemaField;
@@ -62,15 +59,6 @@ public class BinaryResponseWriter implements BinaryQueryResponseWriter {
}
}
- private static void serialize(SolrQueryResponse response, Resolver resolver, String f)
- throws IOException {
- try (JavaBinCodec jbc = new JavaBinCodec(resolver);
- FileOutputStream fos = new FileOutputStream(f)) {
- jbc.setWritableDocFields(resolver).marshal(response.getValues(), fos);
- fos.flush();
- }
- }
-
@Override
public void write(Writer writer, SolrQueryRequest request, SolrQueryResponse response)
throws IOException {
@@ -95,13 +83,6 @@ public class BinaryResponseWriter implements BinaryQueryResponseWriter {
@Override
public Object resolve(Object o, JavaBinCodec codec) throws IOException {
- if (o instanceof StoredField) {
- CharSequence val = ((StoredField) o).getCharSequenceValue();
- if (val instanceof Utf8CharSequence) {
- codec.writeUTF8Str((Utf8CharSequence) val);
- return null;
- }
- }
if (o instanceof ResultContext) {
ReturnFields orig = returnFields;
ResultContext res = (ResultContext) o;
diff --git a/solr/core/src/test/org/apache/solr/response/TestBinaryResponseWriter.java b/solr/core/src/test/org/apache/solr/response/TestBinaryResponseWriter.java
index 2e0db1c763c..80dfe9db363 100644
--- a/solr/core/src/test/org/apache/solr/response/TestBinaryResponseWriter.java
+++ b/solr/core/src/test/org/apache/solr/response/TestBinaryResponseWriter.java
@@ -18,20 +18,14 @@ package org.apache.solr.response;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
-import org.apache.lucene.document.StoredField;
-import org.apache.lucene.document.TextField;
import org.apache.lucene.util.BytesRef;
import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.cli.SimplePostTool;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.util.ByteArrayUtf8CharSequence;
import org.apache.solr.common.util.ByteUtils;
import org.apache.solr.common.util.JavaBinCodec;
import org.apache.solr.common.util.NamedList;
@@ -61,28 +55,6 @@ public class TestBinaryResponseWriter extends SolrTestCaseJ4 {
"LIVE: सबरीमाला मंदिर के पास पहुंची दो महिलाएं, जमकर हो रहा विरोध-प्रदर्शन");
}
- public void testJavabinCodecWithCharSeq() throws IOException {
- SolrDocument document = new SolrDocument();
- document.put("id", "1");
- String text = "नए लुक में धमाल मचाने आ रहे हैं MS Dhoni, कुछ यूं दिखाया हेलीकॉप्टर शॉट";
- document.put(
- "desc",
- new StoredField("desc", new ByteArrayUtf8CharSequence(text) {}, TextField.TYPE_STORED));
-
- NamedList<Object> nl = new NamedList<>();
- nl.add("doc1", document);
- SimplePostTool.BAOS baos = new SimplePostTool.BAOS();
- new JavaBinCodec(new BinaryResponseWriter.Resolver(null, null)).marshal(nl, baos);
- ByteBuffer byteBuffer = baos.getByteBuffer();
- NamedList<?> result =
- (NamedList<?>)
- new JavaBinCodec()
- .unmarshal(
- new ByteArrayInputStream(
- byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.limit()));
- assertEquals(text, result._get("doc1/desc", null));
- }
-
private void compareStringFormat(String input) {
byte[] bytes1 = new byte[1024];
int len1 = ByteUtils.UTF16toUTF8(input, 0, input.length(), bytes1, 0);