SOLR-14250: Do not log error when trying to consume non-existing input stream due to Expect: 100-continue (#1250)

This commit is contained in:
Jan Høydahl 2020-02-21 10:30:10 +01:00 committed by GitHub
parent f8a2c39906
commit 89b13377a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -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
---------------------

View File

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