Skip to content

Commit

Permalink
SOLR-14768: Fix multipart POST to Solr. (#1838)
Browse files Browse the repository at this point in the history
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 7b53671)
  • Loading branch information
dsmiley committed Sep 22, 2020
1 parent aec5292 commit 08dcd24
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 4 additions & 1 deletion solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------------------

Expand Down Expand Up @@ -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
Expand Down
18 changes: 8 additions & 10 deletions solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
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;
Expand Down Expand Up @@ -593,7 +592,7 @@ public SolrParams parseParamsAndFillStreams(
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));
}
Expand All @@ -618,21 +617,20 @@ public InputStream getStream() throws IOException {
}


/** 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;
}

log.debug("Deleting multipart files");

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;
}

Expand Down Expand Up @@ -812,7 +810,7 @@ public SolrParams parseParamsAndFillStreams(final HttpServletRequest req, ArrayL
return formdata.parseParamsAndFillStreams(req, streams, input);
}

if (multipart.isMultipart(req)) {
if (MultipartRequestParser.isMultipart(req)) {
return multipart.parseParamsAndFillStreams(req, streams);
}

Expand Down

0 comments on commit 08dcd24

Please sign in to comment.