From f488dfac9cc516a05044279b5aa7e1254d15fa77 Mon Sep 17 00:00:00 2001 From: David Smiley Date: Thu, 14 Apr 2016 13:51:57 -0400 Subject: [PATCH] SOLR-8937: bin/post (SimplePostTool) should tell JDK to stream stdin instead of fully buffer (cherry picked from commit 037a403) --- solr/CHANGES.txt | 2 ++ solr/core/src/java/org/apache/solr/util/SimplePostTool.java | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index b36bf6135eb..fd71c1c026c 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -99,6 +99,8 @@ Optimizations produced. This resulted in up to 3x throughput when small filter creation was the bottleneck, as well as orders of magnitude less garbage. (Jeff Wartes, yonik) +* SOLR-8937: bin/post (SimplePostTool) now streams the standard input instead of buffering fully. + (David Smiley) Other Changes ---------------------- diff --git a/solr/core/src/java/org/apache/solr/util/SimplePostTool.java b/solr/core/src/java/org/apache/solr/util/SimplePostTool.java index 448897a1388..44a35ca1987 100644 --- a/solr/core/src/java/org/apache/solr/util/SimplePostTool.java +++ b/solr/core/src/java/org/apache/solr/util/SimplePostTool.java @@ -890,7 +890,11 @@ public class SimplePostTool { String encoding = DatatypeConverter.printBase64Binary(url.getUserInfo().getBytes(StandardCharsets.US_ASCII)); urlc.setRequestProperty("Authorization", "Basic " + encoding); } - if (null != length) urlc.setFixedLengthStreamingMode(length); + if (null != length) { + urlc.setFixedLengthStreamingMode(length); + } else { + urlc.setChunkedStreamingMode(-1);//use JDK default chunkLen, 4k in Java 8. + } urlc.connect(); } catch (IOException e) { fatal("Connection error (is Solr running at " + solrUrl + " ?): " + e);