Jacob G created CB-8689:
---------------------------
Summary: Unhandled NullPointerException thrown resolving a file
entry
Key: CB-8689
URL: https://issues.apache.org/jira/browse/CB-8689
Project: Apache Cordova
Issue Type: Bug
Components: Plugin File
Affects Versions: 3.5.0, 3.3.0
Reporter: Jacob G
This is the log of the exception:
{noformat}
03-16 20:38:33.961 31560-31859/com.f.tc E/FileTransfer﹕
{"code":3,"source":"https:\/\/localdev.f.com\/static\/tc\/resources\/css\/app.css","target":"file:\/\/\/data\/data\/com.f.tc\/files\/wwwTmp\/resources\/css\/app.css","http_status":200,"exception":"Attempt
to read from field 'java.lang.String
org.apache.cordova.file.LocalFilesystemURL.path' on a null object reference"}
java.lang.NullPointerException: Attempt to read from field
'java.lang.String org.apache.cordova.file.LocalFilesystemURL.path' on a null
object reference
at
org.apache.cordova.file.Filesystem.makeEntryForURL(Filesystem.java:56)
at
org.apache.cordova.file.Filesystem.makeEntryForNativeUri(Filesystem.java:91)
at
org.apache.cordova.file.Filesystem.makeEntryForFile(Filesystem.java:99)
at
org.apache.cordova.file.FileUtils.getEntryForFile(FileUtils.java:895)
at
org.apache.cordova.filetransfer.FileTransfer$4.run(FileTransfer.java:902)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
{noformat}
The fix is that in FileSystem.java, the following method:
{code}
public JSONObject makeEntryForNativeUri(Uri nativeUri) {
LocalFilesystemURL inputUrl = toLocalUri(nativeUri);
return makeEntryForURL(inputUrl, nativeUri);
}
{code}
should be changed to:
{code}
public JSONObject makeEntryForNativeUri(Uri nativeUri) {
LocalFilesystemURL inputUrl = toLocalUri(nativeUri);
return inputUrl != null ? makeEntryForURL(inputUrl, nativeUri) : null;
}
{code}
With that change, I can successfully download the file using FileTransfer,
which depends on the File plugin.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]