Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-1943] Android: stack overflow trying to read from file that doesn't exist

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:57:36.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0
ComponentsAndroid
Labelsandroid, defect
ReporterBill Dawson
AssigneeBill Dawson
Created2011-04-15T03:06:14.000+0000
Updated2011-04-17T01:57:36.000+0000

Description

failcase app.js (assuming the file name aurelio.txt does not exist in the application data directory :) ):

Titanium.UI.setBackgroundColor('#000');
var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'aurelio.txt');
var blob = file.read();
var txt = blob.text;

If you run that, the app will crash, and if you look at the log you'll see a stack overflow.

Expected behavior: see a NullPointerException instead. (Developers should check file.exists() before trying to access the file.)

Comments

  1. Bill Dawson 2011-04-15

    (from [2d6dc2218e90e485e5485379e9828d2ed0ec94bf]) [#1943 state:fixed-in-qa] In getInputStream, don't let caught exception fall throught to default of swtich statement http://github.com/appcelerator/titanium_mobile/commit/2d6dc2218e90e485e5485379e9828d2ed0ec94bf"> http://github.com/appcelerator/titanium_mobile/commit/2d6dc2218e90e...

  2. Thomas Huelbert 2011-04-15

    1.4.2.4ce7ff G1 running 1.6, 2.2 simulator

JSON Source