From 39da96f605ddfd500ffe7de2155760357dd49c06 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Tue, 17 Feb 2009 19:06:35 +0000 Subject: [PATCH] made more robust even when the file doesn't exist: http://www.nabble.com/stuck-on-InputStream-from-FilePath.read%28%29-td22053991.html git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15388 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/FilePath.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index 70fa58a79f..cea14dfc73 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -761,11 +761,15 @@ public final class FilePath implements Serializable { final Pipe p = Pipe.createRemoteToLocal(); channel.callAsync(new Callable() { public Void call() throws IOException { - FileInputStream fis = new FileInputStream(new File(remote)); - Util.copyStream(fis,p.getOut()); - fis.close(); - p.getOut().close(); - return null; + FileInputStream fis=null; + try { + fis = new FileInputStream(new File(remote)); + Util.copyStream(fis,p.getOut()); + return null; + } finally { + IOUtils.closeQuietly(fis); + IOUtils.closeQuietly(p.getOut()); + } } }); -- GitLab