Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23459] Android: Ti.Filesystem.getFile causes hard crash with null argument

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2016-06-22T08:35:25.000+0000
Affected Version/sRelease 5.4.0
Fix Version/sRelease 6.0.0
ComponentsAndroid
Labelsn/a
ReporterChristopher Williams
AssigneeHieu Pham
Created2016-05-31T18:00:42.000+0000
Updated2016-08-19T21:20:57.000+0000

Description

In our mocha tests suite we used Ti.Filesystem.applicationDirectory to access files from the app Resources directory (xml files, js files, etc). Apparently this property is undefined/null on Android and we should instead be using Ti.Filesystem.resourcesDirectory. However, if we do something like:
Ti.Filesystem.getFile(Ti.Filesystem.applicationDirectory, 'app.js');
That code will hard-crash Android with an NPE. Considering that is valid code on iOS, and that we don't complain/spit out an error - but actually crash the app, I'd think we might want to safeguard a little better here. If we see a null in the path arguments, we should probably spit out an error and return null.

Comments

  1. Hieu Pham 2016-05-31

    master PR: https://github.com/appcelerator/titanium_mobile/pull/8038
  2. Ashraf Abu 2016-06-22

    PR merged. Will require another PR to add log warnings.
  3. Ashraf Abu 2016-06-22

    PR for master: https://github.com/appcelerator/titanium_mobile/pull/8079
  4. Ashraf Abu 2016-06-22

    PR Merged.
  5. Lokesh Choudhary 2016-08-19

    Verified the fix. Ti.Filesystem.getFile does not cause a hard crash. Closing. Environment: Appc Studio : 4.7.1.201608190732 Ti SDK : 6.0.0.v20160819105028 Ti CLI : 5.0.9 Alloy : 1.9.1 MAC El Capitan : 10.11.6 Appc NPM : 4.2.7 Appc CLI : 6.0.0-26 Node: 4.4.4 Nexus 6 - Android 6.0.1

JSON Source