From c75eda77a7cd9db6d78bd90b512aedd8123e8ab2 Mon Sep 17 00:00:00 2001 From: Sanjay Malakar Date: Mon, 9 Mar 2026 07:10:01 +0000 Subject: [PATCH] Fix ListOutputStream.close() to close all streams on failure --- .../service/local/ListOutputStream.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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; } }