Skip to content

Commit 1f0a2f8

Browse files
fix: ListOutputStream.close() to close all streams on failure (#2392)
1 parent 1abd110 commit 1f0a2f8

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/main/java/io/appium/java_client/service/local/ListOutputStream.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,20 @@ public void flush() throws IOException {
6262

6363
@Override
6464
public void close() throws IOException {
65+
IOException first = null;
6566
for (OutputStream stream : streams) {
66-
stream.close();
67+
try {
68+
stream.close();
69+
} catch (IOException e) {
70+
if (first == null) {
71+
first = e;
72+
} else {
73+
first.addSuppressed(e);
74+
}
75+
}
76+
}
77+
if (first != null) {
78+
throw first;
6779
}
6880
}
6981

0 commit comments

Comments
 (0)