summaryrefslogtreecommitdiffstats
path: root/hosted-api
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2022-11-05 09:24:21 +0100
committerjonmv <venstad@gmail.com>2022-11-07 09:59:27 +0100
commitf8a4549269d9df145a4f27c5368a2578f18128a7 (patch)
treeee802d429172bbb301221a1dea2fe48a34bed9b6 /hosted-api
parenta2eca5f54c45838d072f9641505baa3ae0d26746 (diff)
Revert "Merge pull request #24763 from vespa-engine/jonmv/revert-streams"
This reverts commit 6d8bca79a1f600501290593ecd920eca0b237c78, reversing changes made to 36374eb2d3cc94c3792dd0a70963244abb6284b4.
Diffstat (limited to 'hosted-api')
-rw-r--r--hosted-api/src/main/java/ai/vespa/hosted/api/MultiPartStreamer.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/MultiPartStreamer.java b/hosted-api/src/main/java/ai/vespa/hosted/api/MultiPartStreamer.java
index f1cbc027e17..c47fc60e58b 100644
--- a/hosted-api/src/main/java/ai/vespa/hosted/api/MultiPartStreamer.java
+++ b/hosted-api/src/main/java/ai/vespa/hosted/api/MultiPartStreamer.java
@@ -15,6 +15,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Enumeration;
import java.util.List;
import java.util.UUID;
import java.util.function.Supplier;
@@ -89,10 +90,12 @@ public class MultiPartStreamer {
/** Returns an input stream which is an aggregate of all current parts in this, plus an end marker. */
public InputStream data() {
- InputStream aggregate = new SequenceInputStream(Collections.enumeration(Stream.concat(streams.stream().map(Supplier::get),
- Stream.of(end()))
- .collect(Collectors.toList())));
-
+ InputStream aggregate = new SequenceInputStream(new Enumeration<>() {
+ final int j = streams.size();
+ int i = -1;
+ @Override public boolean hasMoreElements() { return i < j; }
+ @Override public InputStream nextElement() { return ++i < j ? streams.get(i).get() : end(); }
+ });
try {
if (aggregate.skip(2) != 2)// This should never happen, as the first stream is a ByteArrayInputStream.
throw new IllegalStateException("Failed skipping extraneous bytes.");