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/10/26 02:44:02 UTC

[solr] branch branch_9x updated (5656eb4c5a3 -> fd55c602a85)

This is an automated email from the ASF dual-hosted git repository.

krisden pushed a change to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git


    from 5656eb4c5a3 SOLR-16416: Register all handlers before doing overseer operations (#1129)
     new b4afb37e1ab SOLR-16363: DirectUpdateHandler2 should not throw UnknownFormatConversionException (#1121)
     new fd55c602a85 SOLR-16363: DirectUpdateHandler2 remove String.format from error logging (#1124)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 solr/CHANGES.txt                                   |  2 +
 .../apache/solr/update/DirectUpdateHandler2.java   | 45 +++++++++-------------
 .../test/org/apache/solr/update/TestUpdate.java    | 44 +++++++++++++++------
 3 files changed, 54 insertions(+), 37 deletions(-)


[solr] 02/02: SOLR-16363: DirectUpdateHandler2 remove String.format from error logging (#1124)

Posted by kr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

krisden pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git

commit fd55c602a85ba259e58b25a3068e41ce40b9a79e
Author: Kevin Risden <ri...@users.noreply.github.com>
AuthorDate: Tue Oct 25 22:35:06 2022 -0400

    SOLR-16363: DirectUpdateHandler2 remove String.format from error logging (#1124)
---
 .../apache/solr/update/DirectUpdateHandler2.java   | 45 +++++++++-------------
 1 file changed, 19 insertions(+), 26 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
index b511461b2fb..bc94e1227bf 100644
--- a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
+++ b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
@@ -22,7 +22,6 @@ import java.lang.invoke.MethodHandles;
 import java.lang.reflect.Array;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Locale;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.atomic.LongAdder;
@@ -301,33 +300,27 @@ public class DirectUpdateHandler2 extends UpdateHandler
     } catch (SolrException e) {
       throw e;
     } catch (AlreadyClosedException e) {
-      throw new SolrException(
-          SolrException.ErrorCode.SERVER_ERROR,
-          String.format(
-              Locale.ROOT,
-              "Server error writing document id %s to the index",
-              cmd.getPrintableId()),
-          e);
+      String errorMsg =
+          "Server error writing document id " + cmd.getPrintableId() + " to the index.";
+      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, errorMsg, e);
     } catch (IllegalArgumentException iae) {
-      throw new SolrException(
-          SolrException.ErrorCode.BAD_REQUEST,
-          String.format(
-              Locale.ROOT,
-              "Exception writing document id %s to the index; possible analysis error: %s%s",
-              cmd.getPrintableId(),
-              iae.getMessage(),
-              (iae.getCause() instanceof BytesRefHash.MaxBytesLengthExceededException
-                  ? ". Perhaps the document has an indexed string field (solr.StrField) which is too large"
-                  : "")),
-          iae);
+      String errorDetails =
+          (iae.getCause() instanceof BytesRefHash.MaxBytesLengthExceededException
+              ? ". Perhaps the document has an indexed string field (solr.StrField) which is too large"
+              : "");
+      String errorMsg =
+          "Exception writing document id "
+              + cmd.getPrintableId()
+              + " to the index; possible analysis error: "
+              + iae.getMessage()
+              + errorDetails;
+      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, errorMsg, iae);
     } catch (RuntimeException t) {
-      throw new SolrException(
-          SolrException.ErrorCode.BAD_REQUEST,
-          String.format(
-              Locale.ROOT,
-              "Exception writing document id %s to the index; possible analysis error.",
-              cmd.getPrintableId()),
-          t);
+      String errorMsg =
+          "Exception writing document id "
+              + cmd.getPrintableId()
+              + " to the index; possible analysis error.";
+      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, errorMsg, t);
     }
   }
 


[solr] 01/02: SOLR-16363: DirectUpdateHandler2 should not throw UnknownFormatConversionException (#1121)

Posted by kr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

krisden pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git

commit b4afb37e1abcb24a2910f41e55fddcf6d5459586
Author: Kevin Risden <ri...@users.noreply.github.com>
AuthorDate: Tue Oct 25 13:03:57 2022 -0400

    SOLR-16363: DirectUpdateHandler2 should not throw UnknownFormatConversionException (#1121)
---
 solr/CHANGES.txt                                   |  2 +
 .../apache/solr/update/DirectUpdateHandler2.java   | 12 +++---
 .../test/org/apache/solr/update/TestUpdate.java    | 44 ++++++++++++++++------
 3 files changed, 41 insertions(+), 17 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index f364d33bda2..73505602ac2 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -49,6 +49,8 @@ Bug Fixes
 
 * SOLR-16483: Fix IndexOutOfBounds in RecursiveNumericEvaluator (Bendegúz Ács via Kevin Risden)
 
+* SOLR-16363: DirectUpdateHandler2 should not throw UnknownFormatConversionException (Kevin Risden)
+
 Build
 ---------------------
 * Upgrade forbiddenapis to 3.4 (Uwe Schindler)
diff --git a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
index 0c9d9fc6ddc..b511461b2fb 100644
--- a/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
+++ b/solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
@@ -313,12 +313,12 @@ public class DirectUpdateHandler2 extends UpdateHandler
           SolrException.ErrorCode.BAD_REQUEST,
           String.format(
               Locale.ROOT,
-              "Exception writing document id %s to the index; possible analysis error: "
-                  + iae.getMessage()
-                  + (iae.getCause() instanceof BytesRefHash.MaxBytesLengthExceededException
-                      ? ". Perhaps the document has an indexed string field (solr.StrField) which is too large"
-                      : ""),
-              cmd.getPrintableId()),
+              "Exception writing document id %s to the index; possible analysis error: %s%s",
+              cmd.getPrintableId(),
+              iae.getMessage(),
+              (iae.getCause() instanceof BytesRefHash.MaxBytesLengthExceededException
+                  ? ". Perhaps the document has an indexed string field (solr.StrField) which is too large"
+                  : "")),
           iae);
     } catch (RuntimeException t) {
       throw new SolrException(
diff --git a/solr/core/src/test/org/apache/solr/update/TestUpdate.java b/solr/core/src/test/org/apache/solr/update/TestUpdate.java
index d64fda66ae7..a23e0bad45d 100644
--- a/solr/core/src/test/org/apache/solr/update/TestUpdate.java
+++ b/solr/core/src/test/org/apache/solr/update/TestUpdate.java
@@ -16,7 +16,6 @@
  */
 package org.apache.solr.update;
 
-import java.io.IOException;
 import java.util.concurrent.Callable;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrException;
@@ -258,21 +257,44 @@ public class TestUpdate extends SolrTestCaseJ4 {
   }
 
   @Test // SOLR-8866
-  public void testUpdateLogThrowsForUnknownTypes() throws IOException {
+  public void testUpdateLogThrowsForUnknownTypes() {
     SolrInputDocument doc = new SolrInputDocument();
     doc.addField("id", "444");
     doc.addField("text", new Object()); // Object shouldn't be serialized later...
 
     AddUpdateCommand cmd = new AddUpdateCommand(req());
     cmd.solrDoc = doc;
-    try {
-      h.getCore().getUpdateHandler().addDoc(cmd); // should throw
-    } catch (SolrException e) {
-      if (e.getMessage().contains("serialize")) {
-        return; // passed test
-      }
-      throw e;
-    }
-    fail();
+
+    SolrException thrown =
+        assertThrows(SolrException.class, () -> h.getCore().getUpdateHandler().addDoc(cmd));
+    assertEquals(
+        "TransactionLog doesn't know how to serialize class java.lang.Object; try implementing ObjectResolver?",
+        thrown.getMessage());
+  }
+
+  @Test // SOLR-16363
+  public void testAddDocLargeFieldThrowsSolrExceptionWrappedIllegalArgumentException() {
+    SolrInputDocument doc = new SolrInputDocument();
+    doc.addField("id", 555);
+    // use invalid String.format parameter in field name to test DirectUpdateHandler2#addDoc
+    // exception logging
+    doc.addField("t%)_s", "a".repeat(50000));
+
+    AddUpdateCommand cmd = new AddUpdateCommand(req());
+    cmd.solrDoc = doc;
+
+    SolrException thrown =
+        assertThrows(SolrException.class, () -> h.getCore().getUpdateHandler().addDoc(cmd));
+    assertEquals(IllegalArgumentException.class, thrown.getCause().getClass());
+    assertEquals(
+        "Exception writing document id 555 to the index; possible analysis error: "
+            + "Document contains at least one immense term in field=\"t%)_s\" "
+            + "(whose UTF8 encoding is longer than the max length 32766), all of which were skipped.  "
+            + "Please correct the analyzer to not produce such terms.  "
+            + "The prefix of the first immense term is: "
+            + "'[97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97]...', "
+            + "original message: bytes can be at most 32766 in length; got 50000. "
+            + "Perhaps the document has an indexed string field (solr.StrField) which is too large",
+        thrown.getMessage());
   }
 }