You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ma...@apache.org on 2024/04/19 15:55:35 UTC
(solr) branch branch_9x updated: SOLR-17222: QueryResponseWriterUtil.NonFlushingStream should support bulk write methods (#2386)
This is an automated email from the ASF dual-hosted git repository.
magibney pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 0fe23471d9e SOLR-17222: QueryResponseWriterUtil.NonFlushingStream should support bulk write methods (#2386)
0fe23471d9e is described below
commit 0fe23471d9ea71c97fc6af968bfce82455db9506
Author: Michael Gibney <mi...@michaelgibney.net>
AuthorDate: Fri Apr 19 11:50:34 2024 -0400
SOLR-17222: QueryResponseWriterUtil.NonFlushingStream should support bulk write methods (#2386)
(cherry picked from commit 8afd6975ff5c32c38adc1216efa3d5d24a36f111)
---
solr/CHANGES.txt | 2 ++
.../solr/response/QueryResponseWriterUtil.java | 20 +++++++++++++++-----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 7b2bd49341c..83108db13c6 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -131,6 +131,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.java
index 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);
}
}
}