SOLR-17222: QueryResponseWriterUtil.NonFlushingStream should support bulk write methods (#2386)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index f609169..c30d05b 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -219,6 +219,8 @@
* 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.java
index 05f79bf..44455a8 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 @@
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 @@
}
@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);
}
}
}