aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java17
1 files changed, 6 insertions, 11 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java
index 459888190f..7e950f6529 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java
@@ -12,8 +12,8 @@ package org.eclipse.jgit.util.io;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Iterator;
-import java.util.LinkedList;
+import java.util.ArrayDeque;
+import java.util.Deque;
/**
* An InputStream which reads from one or more InputStreams.
@@ -34,7 +34,7 @@ public class UnionInputStream extends InputStream {
}
};
- private final LinkedList<InputStream> streams = new LinkedList<>();
+ private final Deque<InputStream> streams = new ArrayDeque<>();
/**
* Create an empty InputStream that is currently at EOF state.
@@ -91,7 +91,6 @@ public class UnionInputStream extends InputStream {
return streams.isEmpty();
}
- /** {@inheritDoc} */
@Override
public int read() throws IOException {
for (;;) {
@@ -106,7 +105,6 @@ public class UnionInputStream extends InputStream {
}
}
- /** {@inheritDoc} */
@Override
public int read(byte[] b, int off, int len) throws IOException {
if (len == 0)
@@ -123,13 +121,11 @@ public class UnionInputStream extends InputStream {
}
}
- /** {@inheritDoc} */
@Override
public int available() throws IOException {
return head().available();
}
- /** {@inheritDoc} */
@Override
public long skip(long count) throws IOException {
long skipped = 0;
@@ -163,19 +159,18 @@ public class UnionInputStream extends InputStream {
return skipped;
}
- /** {@inheritDoc} */
@Override
public void close() throws IOException {
IOException err = null;
- for (Iterator<InputStream> i = streams.iterator(); i.hasNext();) {
+ for (InputStream stream : streams) {
try {
- i.next().close();
+ stream.close();
} catch (IOException closeError) {
err = closeError;
}
- i.remove();
}
+ streams.clear();
if (err != null)
throw err;