Apache Solr open-source search software
SOLR-17222: QueryResponseWriterUtil.NonFlushingStream should support bulk write methods (#2386)
Michael Gibney8afd6975ff5c
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex f609169a0bb..c30d05b15f4 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -219,6 +219,8 @@ Other Changes* SOLR-17232: PropertiesOutputStream is renamed IndexOutputOutputStream and overrides write(byte[], int, int).(Bruno Roustant)+* SOLR-17222: QueryResponseWriterUtil.NonFlushingStream should support bulk write methods (Michael Gibney)+================== 9.5.0 ==================New Features---------------------diff --git a/solr/core/src/java/org/apache/solr/response/QueryResponseWriterUtil.java b/solr/core/src/java/org/apache/solr/response/QueryResponseWriterUtil.javaindex 05f79bf9113..44455a8cf36 100644--- a/solr/core/src/java/org/apache/solr/response/QueryResponseWriterUtil.java+++ b/solr/core/src/java/org/apache/solr/response/QueryResponseWriterUtil.java@@ -75,6 +75,14 @@ public final class QueryResponseWriterUtil {return new FastWriter(writer);}+ /**+ * Delegates write methods to an underlying {@link OutputStream}, but does not delegate {@link+ * OutputStream#flush()}, (nor {@link OutputStream#close()}). This allows code writing to this+ * stream to flush internal buffers without flushing the response. If we were to flush the+ * response early, that would trigger chunked encoding.+ *+ * <p>See SOLR-8669.+ */private static class NonFlushingStream extends OutputStream {private final OutputStream outputStream;@@ -88,11 +96,13 @@ public final class QueryResponseWriterUtil {}@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.+ public void write(byte[] b) throws IOException {+ outputStream.write(b);+ }++ @Override+ public void write(byte[] b, int off, int len) throws IOException {+ outputStream.write(b, off, len);}}}