Commit a094d144 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Ensure that we close streams (JM-1050).

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8192 b35dd754-fafc-0310-a699-88a17e54d16e
parent e525380f
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
package org.jivesoftware.openfire.filetransfer.proxy; package org.jivesoftware.openfire.filetransfer.proxy;
import org.jivesoftware.util.cache.CacheSizes; import org.jivesoftware.util.cache.CacheSizes;
import org.jivesoftware.util.Log;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.io.IOException; import java.io.IOException;
...@@ -109,11 +110,15 @@ public class DefaultProxyTransfer implements ProxyTransfer { ...@@ -109,11 +110,15 @@ public class DefaultProxyTransfer implements ProxyTransfer {
} }
public void doTransfer() throws IOException { public void doTransfer() throws IOException {
if(!isActivatable()) { if (!isActivatable()) {
throw new IOException("Transfer missing party"); throw new IOException("Transfer missing party");
} }
InputStream in = getInputStream(); InputStream in = null;
OutputStream out = new ProxyOutputStream(getOutputStream()); OutputStream out = null;
try {
in = getInputStream();
out = new ProxyOutputStream(getOutputStream());
final byte[] b = new byte[BUFFER_SIZE]; final byte[] b = new byte[BUFFER_SIZE];
int count = 0; int count = 0;
...@@ -128,9 +133,25 @@ public class DefaultProxyTransfer implements ProxyTransfer { ...@@ -128,9 +133,25 @@ public class DefaultProxyTransfer implements ProxyTransfer {
// read more bytes from the input stream // read more bytes from the input stream
count = in.read(b); count = in.read(b);
} while (count >= 0); } while (count >= 0);
}
getInputStream().close(); finally {
getOutputStream().close(); if (in != null) {
try {
in.close();
}
catch (Exception e) {
Log.error(e);
}
}
if (out != null) {
try {
out.close();
}
catch (Exception e) {
Log.error(e);
}
}
}
} }
public int getCachedSize() { public int getCachedSize() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment