CB-4907 Close stream when we're finished with it

This commit is contained in:
Bas Bosman
2014-01-26 22:40:23 +01:00
committed by Andrew Grieve
parent d3b21b35fc
commit 6f91ac3a30

View File

@@ -582,15 +582,19 @@ public class FileTransfer extends CordovaPlugin {
if(err != null)
{
BufferedReader reader = new BufferedReader(new InputStreamReader(err, "UTF-8"));
String line = reader.readLine();
while(line != null)
{
bodyBuilder.append(line);
line = reader.readLine();
if(line != null)
bodyBuilder.append('\n');
try {
String line = reader.readLine();
while(line != null) {
bodyBuilder.append(line);
line = reader.readLine();
if(line != null) {
bodyBuilder.append('\n');
}
}
body = bodyBuilder.toString();
} finally {
reader.close();
}
body = bodyBuilder.toString();
}
}
// IOException can leave connection object in a bad state, so catch all exceptions.