You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2012/08/30 23:01:57 UTC

android commit: Fixing 'FileTransfer.download() - should handle unknown host' failing mobile-spec test case

Updated Branches:
  refs/heads/master c3e17fb18 -> b3f5e039f


Fixing 'FileTransfer.download() - should handle unknown host' failing mobile-spec test case


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/b3f5e039
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/b3f5e039
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/b3f5e039

Branch: refs/heads/master
Commit: b3f5e039f2d1cb3da597b59ea885996aba04e574
Parents: c3e17fb
Author: Simon MacDonald <si...@gmail.com>
Authored: Thu Aug 30 17:01:16 2012 -0400
Committer: Simon MacDonald <si...@gmail.com>
Committed: Thu Aug 30 17:01:16 2012 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/FileTransfer.java |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/b3f5e039/framework/src/org/apache/cordova/FileTransfer.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/FileTransfer.java b/framework/src/org/apache/cordova/FileTransfer.java
index ce7120b..15b2f2e 100644
--- a/framework/src/org/apache/cordova/FileTransfer.java
+++ b/framework/src/org/apache/cordova/FileTransfer.java
@@ -490,8 +490,14 @@ public class FileTransfer extends Plugin {
                 connection.connect();
 
                 Log.d(LOG_TAG, "Download file:" + url);
+                InputStream inputStream;
+                try {
+                    inputStream = connection.getInputStream();
+                } catch(FileNotFoundException e) {
+                    Log.e(LOG_TAG, e.toString(), e);
+                    throw new IOException("Received error from server");
+                }
 
-                InputStream inputStream = connection.getInputStream();
                 byte[] buffer = new byte[1024];
                 int bytesRead = 0;
 
@@ -521,6 +527,7 @@ public class FileTransfer extends Plugin {
 
         } catch (FileNotFoundException e) {
             JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source, target, connection);
+            Log.d(LOG_TAG, "I got a file not found exception");
             Log.e(LOG_TAG, error.toString(), e);
             return new PluginResult(PluginResult.Status.IO_EXCEPTION, error);
         } catch (MalformedURLException e) {