diff --git a/dspace-lni/dspace-lni-client/src/main/java/LNISmokeTest.java b/dspace-lni/dspace-lni-client/src/main/java/LNISmokeTest.java index 20f49b0b17..db4dc43540 100644 --- a/dspace-lni/dspace-lni-client/src/main/java/LNISmokeTest.java +++ b/dspace-lni/dspace-lni-client/src/main/java/LNISmokeTest.java @@ -58,6 +58,7 @@ import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.PosixParser; import org.apache.commons.codec.binary.Base64; +import org.apache.log4j.Logger; import org.dspace.app.dav.client.LNIClientUtils; import org.dspace.app.dav.client.LNISoapServlet; import org.dspace.app.dav.client.LNISoapServletServiceLocator; @@ -88,6 +89,7 @@ import org.jdom.output.XMLOutputter; */ public class LNISmokeTest { + private static final Logger log = Logger.getLogger(LNISmokeTest.class); /** * The Constant NS_DAV. @@ -547,13 +549,36 @@ public class LNISmokeTest fixBasicAuth(url, conn); conn.connect(); - InputStream in = new FileInputStream(source); - OutputStream out = conn.getOutputStream(); + InputStream in = null; + OutputStream out = null; try { + in = new FileInputStream(source); + out = conn.getOutputStream(); copyStream(in, out); } finally { - in.close(); - out.close(); + if (in != null) + { + try + { + in.close(); + } + catch (IOException e) + { + log.error("Unable to close input stream", e); + } + } + + if (out!= null) + { + try + { + out.close(); + } + catch (IOException e) + { + log.error("Unable to close output stream", e); + } + } } int status = conn.getResponseCode(); diff --git a/dspace-lni/dspace-lni-core/src/main/java/org/dspace/app/dav/DAVItem.java b/dspace-lni/dspace-lni-core/src/main/java/org/dspace/app/dav/DAVItem.java index 19eeb2fa02..4f462a41e9 100644 --- a/dspace-lni/dspace-lni-core/src/main/java/org/dspace/app/dav/DAVItem.java +++ b/dspace-lni/dspace-lni-core/src/main/java/org/dspace/app/dav/DAVItem.java @@ -509,9 +509,19 @@ class DAVItem extends DAVDSpaceObject dip.disseminate(this.context, this.item, pparams, tempFile); // Copy temporary file contents to response stream - FileInputStream fileIn = new FileInputStream(tempFile); - Utils.copy(fileIn, this.response.getOutputStream()); - fileIn.close(); + FileInputStream fileIn = null; + try + { + fileIn = new FileInputStream(tempFile); + Utils.copy(fileIn, this.response.getOutputStream()); + } + finally + { + if (fileIn != null) + { + fileIn.close(); + } + } } catch (CrosswalkException pe) {