diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index 4701bfc396..b73330a1d0 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -41,6 +41,7 @@ import hudson.console.ConsoleLogFilter; import hudson.console.ConsoleNote; import hudson.console.ModelHyperlinkNote; import hudson.console.PlainTextConsoleOutputStream; +import java.io.Closeable; import java.nio.file.Files; import java.nio.file.InvalidPathException; import java.nio.file.StandardOpenOption; @@ -51,7 +52,6 @@ import hudson.cli.declarative.CLIMethod; import hudson.model.Descriptor.FormException; import hudson.model.listeners.RunListener; import hudson.model.listeners.SaveableListener; -import hudson.model.queue.Executables; import hudson.model.queue.SubTask; import hudson.search.SearchIndexBuilder; import hudson.security.ACL; @@ -1801,6 +1801,7 @@ public abstract class Run ,RunT extends Run,RunT extends Run causes) { @@ -80,5 +93,41 @@ public class StreamBuildListener extends StreamTaskListener implements BuildList getLogger().println("Finished: "+result); } + @Override + public void close() throws IOException { + try { + super.close(); + } catch (IOException e) { + if (additionalClosables != null) { + for (Closeable c: additionalClosables) { + try { + c.close(); + } catch (IOException e1) { + e.addSuppressed(e1); + } + } + } + throw e; + } + if (additionalClosables != null) { + IOException e = null; + for (Closeable c : additionalClosables) { + try { + c.close(); + } catch (IOException e1) { + if (e == null) { + e = e1; + } else { + e.addSuppressed(e1); + } + } + } + if (e != null) { + throw e; + } + } + + } + private static final long serialVersionUID = 1L; }