mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 06:53:09 +00:00
[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:
@@ -58,6 +58,7 @@ import org.apache.commons.cli.Options;
|
|||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
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.LNIClientUtils;
|
||||||
import org.dspace.app.dav.client.LNISoapServlet;
|
import org.dspace.app.dav.client.LNISoapServlet;
|
||||||
import org.dspace.app.dav.client.LNISoapServletServiceLocator;
|
import org.dspace.app.dav.client.LNISoapServletServiceLocator;
|
||||||
@@ -88,6 +89,7 @@ import org.jdom.output.XMLOutputter;
|
|||||||
*/
|
*/
|
||||||
public class LNISmokeTest
|
public class LNISmokeTest
|
||||||
{
|
{
|
||||||
|
private static final Logger log = Logger.getLogger(LNISmokeTest.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Constant NS_DAV.
|
* The Constant NS_DAV.
|
||||||
@@ -547,14 +549,37 @@ public class LNISmokeTest
|
|||||||
fixBasicAuth(url, conn);
|
fixBasicAuth(url, conn);
|
||||||
conn.connect();
|
conn.connect();
|
||||||
|
|
||||||
InputStream in = new FileInputStream(source);
|
InputStream in = null;
|
||||||
OutputStream out = conn.getOutputStream();
|
OutputStream out = null;
|
||||||
try {
|
try {
|
||||||
|
in = new FileInputStream(source);
|
||||||
|
out = conn.getOutputStream();
|
||||||
copyStream(in, out);
|
copyStream(in, out);
|
||||||
} finally {
|
} finally {
|
||||||
|
if (in != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
in.close();
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
log.error("Unable to close input stream", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out!= null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
log.error("Unable to close output stream", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int status = conn.getResponseCode();
|
int status = conn.getResponseCode();
|
||||||
if (status < 200 || status >= 300)
|
if (status < 200 || status >= 300)
|
||||||
|
@@ -509,10 +509,20 @@ class DAVItem extends DAVDSpaceObject
|
|||||||
dip.disseminate(this.context, this.item, pparams, tempFile);
|
dip.disseminate(this.context, this.item, pparams, tempFile);
|
||||||
|
|
||||||
// Copy temporary file contents to response stream
|
// Copy temporary file contents to response stream
|
||||||
FileInputStream fileIn = new FileInputStream(tempFile);
|
FileInputStream fileIn = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fileIn = new FileInputStream(tempFile);
|
||||||
Utils.copy(fileIn, this.response.getOutputStream());
|
Utils.copy(fileIn, this.response.getOutputStream());
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (fileIn != null)
|
||||||
|
{
|
||||||
fileIn.close();
|
fileIn.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (CrosswalkException pe)
|
catch (CrosswalkException pe)
|
||||||
{
|
{
|
||||||
throw new DAVStatusException(
|
throw new DAVStatusException(
|
||||||
|
Reference in New Issue
Block a user