From a5a2406b1d0cfa5fd6dbfb6a4cd37d1875b0c5ef Mon Sep 17 00:00:00 2001
From: buczekp <buczekp>
Date: Fri, 27 May 2011 14:10:18 +0000
Subject: [PATCH] [LMS-2276] close input and output streams when finished
 downloading file in dss-client

SVN: 21498
---
 .../dss/client/api/v1/FileInfoDssDownloader.java       | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/v1/FileInfoDssDownloader.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/v1/FileInfoDssDownloader.java
index 39d7974e701..1279a0bc151 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/v1/FileInfoDssDownloader.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/v1/FileInfoDssDownloader.java
@@ -114,14 +114,20 @@ public final class FileInfoDssDownloader
 
     private void downloadFile(FileInfoDssDTO fileInfo, File file)
     {
+        FileOutputStream fos = null;
+        InputStream is = null;
         try
         {
-            FileOutputStream fos = new FileOutputStream(file);
-            InputStream is = dataSetDss.getFile(fileInfo.getPathInDataSet());
+            fos = new FileOutputStream(file);
+            is = dataSetDss.getFile(fileInfo.getPathInDataSet());
             IOUtils.copyLarge(is, fos);
         } catch (IOException e)
         {
             throw new IOExceptionUnchecked(e);
+        } finally
+        {
+            IOUtils.closeQuietly(fos);
+            IOUtils.closeQuietly(is);
         }
     }
 }
-- 
GitLab