for #404 a few more tweaks to make sure things are getting closed!

This commit is contained in:
n8fr8 2015-09-10 14:58:51 -04:00
parent b3f8ac0a5b
commit b6939dcce4
2 changed files with 10 additions and 1 deletions

View File

@ -184,6 +184,7 @@ public abstract class Downloader {
} }
outputStream.flush(); outputStream.flush();
outputStream.close();
} }
protected void sendProgress(int bytesRead, int totalBytes) { protected void sendProgress(int bytesRead, int totalBytes) {

View File

@ -34,6 +34,7 @@ public class HttpDownloader extends Downloader {
protected static final String HEADER_FIELD_ETAG = "ETag"; protected static final String HEADER_FIELD_ETAG = "ETag";
protected HttpURLConnection connection; protected HttpURLConnection connection;
private InputStream stream;
private int statusCode = -1; private int statusCode = -1;
private boolean onlyStream = false; private boolean onlyStream = false;
@ -64,7 +65,8 @@ public class HttpDownloader extends Downloader {
public InputStream getInputStream() throws IOException { public InputStream getInputStream() throws IOException {
setupConnection(); setupConnection();
return new BufferedInputStream(connection.getInputStream()); stream = new BufferedInputStream(connection.getInputStream());
return stream;
} }
public BufferedReader getBufferedReader () throws IOException public BufferedReader getBufferedReader () throws IOException
@ -169,6 +171,12 @@ public class HttpDownloader extends Downloader {
public void close () public void close ()
{ {
try {
if (stream != null)
stream.close();
}
catch (IOException e) {}
connection.disconnect(); connection.disconnect();
} }
} }