SOLR-8669: Non binary responses use chunked encoding because we flush the outputstream early.

This commit is contained in:
markrmiller 2016-02-16 13:11:37 -05:00
parent 44b58ee4f8
commit 13dda5debb
3 changed files with 21 additions and 3 deletions

View File

@ -188,6 +188,9 @@ Optimizations
* SOLR-8532: Optimize GraphQuery when maxDepth is set by not collecting edges at the maxDepth level.
(Kevin Watters via yonik)
* SOLR-8669: Non binary responses use chunked encoding because we flush the outputstream early.
(Mark Miller)
Other Changes
----------------------
@ -533,7 +536,7 @@ Bug Fixes
* SOLR-8578: Successful or not, requests are not always fully consumed by Solrj clients and we
count on HttpClient or the JVM. (Mark Miller)
Optimizations
----------------------
@ -544,6 +547,9 @@ Optimizations
* SOLR-7281: Add an overseer action to publish an entire node as 'down'. (Mark Miller, shalin)
* SOLR-8669: Non binary responses use chunked encoding because we flush the outputstream early.
(Mark Miller)
Other Changes
----------------------

View File

@ -48,7 +48,20 @@ public final class QueryResponseWriterUtil {
BinaryQueryResponseWriter binWriter = (BinaryQueryResponseWriter) responseWriter;
binWriter.write(outputStream, solrRequest, solrResponse);
} else {
Writer writer = buildWriter(outputStream, ContentStreamBase.getCharsetFromContentType(contentType));
OutputStream out = new OutputStream() {
@Override
public void write(int b) throws IOException {
outputStream.write(b);
}
@Override
public void flush() throws IOException {
// We don't flush here, which allows us to flush below
// and only flush internal buffers, not the response.
// If we flush the response early, we trigger chunked encoding.
// See SOLR-8669.
}
};
Writer writer = buildWriter(out, ContentStreamBase.getCharsetFromContentType(contentType));
responseWriter.write(writer, solrRequest, solrResponse);
writer.flush();
}

View File

@ -580,7 +580,6 @@ public class HttpSolrCall {
OutputStream os = resp.getOutputStream();
IOUtils.copyLarge(is, os);
os.flush();
}
} catch (IOException e) {