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,28 +110,48 @@ public class DefaultProxyTransfer implements ProxyTransfer { ...@@ -109,28 +110,48 @@ 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;
final byte[] b = new byte[BUFFER_SIZE]; try {
int count = 0; in = getInputStream();
amountWritten = 0; out = new ProxyOutputStream(getOutputStream());
do { final byte[] b = new byte[BUFFER_SIZE];
// write to the output stream int count = 0;
out.write(b, 0, count); amountWritten = 0;
amountWritten += count; do {
// write to the output stream
out.write(b, 0, count);
// read more bytes from the input stream amountWritten += count;
count = in.read(b);
} while (count >= 0);
getInputStream().close(); // read more bytes from the input stream
getOutputStream().close(); count = in.read(b);
} while (count >= 0);
}
finally {
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