You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by kr...@apache.org on 2022/12/15 23:12:32 UTC
[solr] 01/02: SOLR-16589: Large fields with large=true can be truncated when using unicode values (#1241)
This is an automated email from the ASF dual-hosted git repository.
krisden pushed a commit to branch branch_9_1
in repository https://gitbox.apache.org/repos/asf/solr.git
commit d558cec6582a6084d0bb163d55b960e00d340a44
Author: Kevin Risden <ri...@users.noreply.github.com>
AuthorDate: Thu Dec 15 14:15:01 2022 -0500
SOLR-16589: Large fields with large=true can be truncated when using unicode values (#1241)
---
solr/CHANGES.txt | 7 +++++++
solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java | 2 +-
solr/core/src/test/org/apache/solr/search/LargeFieldTest.java | 7 +++++--
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 99c9014b95f..bb24d8be9a7 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -4,6 +4,13 @@ This file lists Solr's raw release notes with details of every change to Solr.
Most people will find the solr-upgrade-notes.adoc file more approachable.
https://github.com/apache/solr/blob/main/solr/solr-ref-guide/modules/upgrade-notes/pages/solr-upgrade-notes.adoc
+================== 9.1.1 ==================
+
+Bug Fixes
+---------------------
+
+* SOLR-16589: Large fields with large=true can be truncated when using unicode values (Kevin Risden)
+
================== 9.1.0 ==================
New Features
diff --git a/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java b/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java
index eab3a837315..a7a700a33ee 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrDocumentFetcher.java
@@ -509,7 +509,7 @@ public class SolrDocumentFetcher {
public void stringField(FieldInfo fieldInfo, String value) throws IOException {
Objects.requireNonNull(value, "String value should not be null");
bytesRef.bytes = value.getBytes(StandardCharsets.UTF_8);
- bytesRef.length = value.length();
+ bytesRef.length = bytesRef.bytes.length;
done = true;
}
diff --git a/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java b/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java
index d85be338a50..5045a3561bd 100644
--- a/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java
+++ b/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java
@@ -23,6 +23,7 @@ import java.util.Objects;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.misc.document.LazyDocument;
+import org.apache.lucene.tests.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.schema.IndexSchema;
import org.junit.AfterClass;
@@ -36,7 +37,6 @@ public class LargeFieldTest extends SolrTestCaseJ4 {
private static final String BIG_FIELD = "bigField";
@BeforeClass
- @SuppressWarnings({"unchecked"})
public static void initManagedSchemaCore() throws Exception {
// This testing approach means no schema file or per-test temp solr-home!
System.setProperty("managed.schema.mutable", "true");
@@ -85,7 +85,8 @@ public class LargeFieldTest extends SolrTestCaseJ4 {
@Test
public void test() throws Exception {
// add just one document (docid 0)
- assertU(adoc(ID_FLD, "101", LAZY_FIELD, "lzy", BIG_FIELD, "big document field one"));
+ String bigFieldValue = TestUtil.randomUnicodeString(random());
+ assertU(adoc(ID_FLD, "101", LAZY_FIELD, "lzy", BIG_FIELD, bigFieldValue));
assertU(commit());
// trigger the ID_FLD to get into the doc cache; don't reference other fields
@@ -109,6 +110,8 @@ public class LargeFieldTest extends SolrTestCaseJ4 {
assertEager(d, ID_FLD);
assertLazyLoaded(d, LAZY_FIELD);
assertLazyLoaded(d, BIG_FIELD); // loaded now
+
+ assertEquals(bigFieldValue, d.getField(BIG_FIELD).stringValue());
}
private void assertEager(Document d, String fieldName) {