From 821383090013b3d9f9b40eae158943b25bcac0e5 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Wed, 23 Apr 2008 06:13:45 +0000 Subject: [PATCH] [MRM-781] make sure file is closed Submitted by: James William Dumay git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@650757 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/webdav/ArchivaDavResource.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java index 6a3d51576..7c7361cd1 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java @@ -132,9 +132,20 @@ public class ArchivaDavResource implements DavResource { if (!isCollection()) { - IOUtils.copy(new FileInputStream(localResource), outputContext.getOutputStream()); - outputContext.setContentLength(getContentLength()); - outputContext.setContentType(getContentType()); + FileInputStream is = null; + try + { + outputContext.setContentLength(getContentLength()); + outputContext.setContentType(getContentType()); + + //Write content to stream + is = new FileInputStream(localResource); + IOUtils.copy(is, outputContext.getOutputStream()); + } + finally + { + IOUtils.closeQuietly(is); + } } else { -- 2.39.5