[DS-707] Stream clean up

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5642 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Graham Triggs
2010-10-26 09:28:35 +00:00
parent 1d9d92c619
commit 41fd35b4f1
2 changed files with 42 additions and 7 deletions

View File

@@ -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();

View File

@@ -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)
{