diff options
author | jonmv <venstad@gmail.com> | 2022-11-04 22:46:07 +0100 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2022-11-04 22:46:07 +0100 |
commit | 25bc8d1f050942ed29273b46efe0f7b2b0432045 (patch) | |
tree | dc27af3e69680611e41c56d688d9f1be4971129f /hosted-api | |
parent | 070c4b8060b622b5a10dead98a902cb4850610dc (diff) |
Revert "Merge pull request #24725 from vespa-engine/jonmv/application-package-streams"
This reverts commit c7a0effde1c205d8790e5d989437aefd724bc70f, reversing
changes made to 7bcb7768d75c1eef5bc70a2aa84c363f9b7ec643.
Diffstat (limited to 'hosted-api')
-rw-r--r-- | hosted-api/src/main/java/ai/vespa/hosted/api/MultiPartStreamer.java | 11 |
1 files changed, 4 insertions, 7 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 c47fc60e58b..f1cbc027e17 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,7 +15,6 @@ 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; @@ -90,12 +89,10 @@ 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(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(); } - }); + InputStream aggregate = new SequenceInputStream(Collections.enumeration(Stream.concat(streams.stream().map(Supplier::get), + Stream.of(end())) + .collect(Collectors.toList()))); + try { if (aggregate.skip(2) != 2)// This should never happen, as the first stream is a ByteArrayInputStream. throw new IllegalStateException("Failed skipping extraneous bytes."); |