You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2020/09/26 02:46:18 UTC

[lucene-solr] branch branch_8_6 updated: SOLR-14768: Fix multipart POST to Solr. (#1838)

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

dsmiley pushed a commit to branch branch_8_6
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8_6 by this push:
     new 55a6c0f  SOLR-14768: Fix multipart POST to Solr. (#1838)
55a6c0f is described below

commit 55a6c0ffdbba435141417bb130ffa11516a42539
Author: David Smiley <ds...@apache.org>
AuthorDate: Fri Sep 25 22:45:54 2020 -0400

    SOLR-14768: Fix multipart POST to Solr. (#1838)
    
    Regression from 8.6
    Multipart POST would fail due to a NoClassDefFoundError of Jetty MultiPart. Solr cannot access many Jetty classes, which is not noticeable in our tests.
    
    (cherry picked from commit 7b53671920840bb6fe6906436260d6bf906156f9)
---
 solr/CHANGES.txt                                       |  3 +++
 .../org/apache/solr/servlet/SolrRequestParsers.java    | 18 ++++++++----------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index dbba06a..0653d16 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -13,6 +13,9 @@ Bug Fixes
 * SOLR-14859: DateRangeField now throws errors when invalid field/fieldType options specified; no longer silently accepts incompatible option values
   (Jason Gerlowski, Chris Hostetter, Munendra S N)
 
+* SOLR-14768: Fix HTTP multipart POST to Solr -- a regression from 8.6.0.
+  Many Jetty classes are not classpath-visible from the Solr webapp.  (David Smiley)
+
 ==================  8.6.2 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java b/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
index 52696ba..4a8cffa 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
@@ -62,7 +62,6 @@ import org.apache.solr.util.RTimerTree;
 import org.apache.solr.util.tracing.GlobalTracer;
 import org.eclipse.jetty.http.HttpFields;
 import org.eclipse.jetty.http.MimeTypes;
-import org.eclipse.jetty.server.MultiParts;
 import org.eclipse.jetty.server.Request;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -593,7 +592,7 @@ public class SolrRequestParsers {
       return params;
     }
 
-    boolean isMultipart(HttpServletRequest req) {
+    static boolean isMultipart(HttpServletRequest req) {
       // Jetty utilities
       return MimeTypes.Type.MULTIPART_FORM_DATA.is(HttpFields.valueParameters(req.getContentType(), null));
     }
@@ -618,11 +617,9 @@ public class SolrRequestParsers {
   }
 
 
-  /** Clean up any tmp files created by MultiPartInputStream. */
+  /** Clean up any files created by MultiPartInputStream. */
   static void cleanupMultipartFiles(HttpServletRequest request) {
-    // See Jetty MultiPartCleanerListener from which we drew inspiration
-    MultiParts multiParts = (MultiParts) request.getAttribute(Request.MULTIPARTS);
-    if (multiParts == null || multiParts.getContext() != request.getServletContext()) {
+    if (!MultipartRequestParser.isMultipart(request)) {
       return;
     }
 
@@ -630,9 +627,10 @@ public class SolrRequestParsers {
 
     Collection<Part> parts;
     try {
-      parts = multiParts.getParts();
-    } catch (IOException e) {
-      log.warn("Errors deleting multipart tmp files", e);
+      parts = request.getParts();
+    } catch (Exception e) {
+      assert false : e.toString();
+      log.error("Couldn't get multipart parts in order to delete them", e);
       return;
     }
 
@@ -812,7 +810,7 @@ public class SolrRequestParsers {
         return formdata.parseParamsAndFillStreams(req, streams, input);
       }
 
-      if (multipart.isMultipart(req)) {
+      if (MultipartRequestParser.isMultipart(req)) {
         return multipart.parseParamsAndFillStreams(req, streams);
       }