From 89b13377a1b805b2ae56c532b52572b222a0476a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B8ydahl?= Date: Fri, 21 Feb 2020 10:30:10 +0100 Subject: [PATCH] SOLR-14250: Do not log error when trying to consume non-existing input stream due to Expect: 100-continue (#1250) --- solr/CHANGES.txt | 2 ++ .../org/apache/solr/servlet/SolrDispatchFilter.java | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 14dccb0a8ef..b7adc7c5614 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -166,6 +166,8 @@ Bug Fixes * SOLR-12550: ConcurrentUpdateSolrClient doesn't respect timeouts for commits and optimize. (Marc A. Morissette, Bérénice MAUREL via shalin) +* SOLR-14250: Do not log error when trying to consume non-existing input stream due to Expect: 100-continue (janhoy) + Other Changes --------------------- diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java index 4ff013835d8..a3968d86840 100644 --- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java +++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java @@ -60,6 +60,7 @@ import io.opentracing.Tracer; import io.opentracing.tag.Tags; import org.apache.commons.io.FileCleaningTracker; import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpHeaders; import org.apache.http.client.HttpClient; import org.apache.lucene.util.Version; import org.apache.solr.api.V2HttpCall; @@ -442,19 +443,23 @@ public class SolrDispatchFilter extends BaseSolrFilter { if (scope != null) scope.close(); GlobalTracer.get().clearContext(); - consumeInputFully(request); + consumeInputFully(request, response); } } // we make sure we read the full client request so that the client does // not hit a connection reset and we can reuse the // connection - see SOLR-8453 and SOLR-8683 - private void consumeInputFully(HttpServletRequest req) { + private void consumeInputFully(HttpServletRequest req, HttpServletResponse response) { try { ServletInputStream is = req.getInputStream(); while (!is.isFinished() && is.read() != -1) {} } catch (IOException e) { - log.info("Could not consume full client request", e); + if (req.getHeader(HttpHeaders.EXPECT) != null && response.isCommitted()) { + log.debug("No input stream to consume from client"); + } else { + log.info("Could not consume full client request", e); + } } }