sumeetsinghani / bus-stop-alarm

Automatically exported from code.google.com/p/bus-stop-alarm
MIT License
0 stars 0 forks source link

better exception handling in loadRecentSettings() #55

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Instead of just printing the stack trace, we should tell the user that the 
file is either missing (in this case, it actually throws a 
FileNotFoundException which extends IOException) or the some other I/O error 
has occurred. Before doing the following lines in loadRecentSettings() we 
should also check if the length of the array is at least 4 so we don't get 
ArrayOutOfBoundsException:

        dataVibrate = settingResult[0];
        dataRingtone = settingResult[1];
        dataProximity = settingResult[2];
        dataProximityUnit = settingResult[3];

Original issue reported on code.google.com by chen...@gmail.com on 7 Mar 2010 at 2:05

GoogleCodeExporter commented 9 years ago

Original comment by daver0...@gmail.com on 7 Mar 2010 at 2:17

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Modify the settings files so that it contains less than 4 tokens.

What is the expected output? 
- Set attributes that are missing in the file to default values. 

What do you see instead?
- It would crash, theoretically due to index out of bounds.

NOTE: This has been fixed by me.

Original comment by chen...@gmail.com on 11 Mar 2010 at 9:50