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/22 21:46:15 UTC

[lucene-solr] branch branch_8x 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_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


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

commit 08dcd24b17b6caa7bd49452dd30a66cfafbaaf89
Author: David Smiley <ds...@salesforce.com>
AuthorDate: Tue Sep 22 17:42:18 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                                       |  5 ++++-
 .../org/apache/solr/servlet/SolrRequestParsers.java    | 18 ++++++++----------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 8ed7a5a..f14a2f6 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -113,6 +113,9 @@ Bug Fixes
   Also, params with macros will be processed more strictly by LTR FeatureWeight.
   (David Smiley, Cesar Rodriguez, Christine Poerschke)
 
+* 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)
+
 Other Changes
 ---------------------
 
@@ -140,7 +143,7 @@ Other Changes
 
 * SOLR-14641: PeerSync, remove canHandleVersionRanges check (Cao Manh Dat)
 
-* SOLR-14579: Comment SolrJ 'Utils' generic map functions 
+* SOLR-14579: Comment SolrJ 'Utils' generic map functions
   (Megan Carey and a lot of education from Uwe Schindler via Erick Erickson)
 
 * SOLR-10471: Update default Zookeeper session timeout to 30s in bin/solr and bin/solr.cmd
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);
       }