diff --git a/src/main/java/io/appium/java_client/service/local/ListOutputStream.java b/src/main/java/io/appium/java_client/service/local/ListOutputStream.java index 7173963ad..f2dc66eb2 100644 --- a/src/main/java/io/appium/java_client/service/local/ListOutputStream.java +++ b/src/main/java/io/appium/java_client/service/local/ListOutputStream.java @@ -62,8 +62,20 @@ public void flush() throws IOException { @Override public void close() throws IOException { + IOException first = null; for (OutputStream stream : streams) { - stream.close(); + try { + stream.close(); + } catch (IOException e) { + if (first == null) { + first = e; + } else { + first.addSuppressed(e); + } + } + } + if (first != null) { + throw first; } }