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 39d7974e701e9be3301ad04a08e68fada9fac097..1279a0bc15194a286f3f49dc2d75a67ce3c16656 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); } } }