Bug 274 - [PredictSys] java.lang.ArrayIndexOutOfBoundsException thrown when doing New Prediction with invalid parameters
Summary: [PredictSys] java.lang.ArrayIndexOutOfBoundsException thrown when doing New P...
Status: RESOLVED FIXED
Alias: None
Product: MovieXXX
Classification: Unclassified
Component: MovieAnalysisEngine (show other bugs)
Version: 2.0
Hardware: PC Windows
: High blocker
Deadline: 2018-11-24
Assignee: clwong274-c
URL:
Depends on:
Blocks:
 
Reported: 2018-11-30 00:53 HKT by tomfong521
Modified: 2018-11-30 01:12 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tomfong521 2018-11-30 00:53:17 HKT
Details:
After enter parameters to process prediction, an java.lang.ArrayIndexOutOfBoundsException is thrown

Reproducible steps
1. Enter "1" to select "Office Box Prediction" in [System Home]
2. Enter "1" to select "Start New Prediction" in [Office Box Prediction]
3. Enter invalid keyword (e.g. "tomJai") to process recommendation

Expected results:
- At step (3), error message indicating invalid parameters should be shown
- After error message prompted, either (1)terminate new prediction and go back to [Office Box Prediction] home, or (2)prompt to ask user entering parameters again

Actual results:
- At step (3), java.lang.ArrayIndexOutOfBoundsException is thrown and the program is interrupted

Detailed console output:
 >> Enter genre, director, leading actor, leading actress and budget of new movie to predict box office (seperate by comma): tomJai
 >> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
 >> 	at movieRating.PredictSys.doNewPrediction(PredictSys.java:24)
 >> 	at movieRating.PredictSys.enter(PredictSys.java:65)
 >> 	at movieRating.Main.main(Main.java:24)
Comment 1 clwong274-c 2018-11-30 01:12:20 HKT
Root cause
- Checking for validation of input is missing in PredictSys::doNewPrediction()

How to fix
- Added PredictSys::checkParameter() to check validation of parameter, prompt to ask user entering parameter again if invalid

Expected behavior
- If invalid parameter is input, accurate error message indicating instruction to input correct parameter should be shown
- After error message, prompt to ask user entering parameters again

Potential affected areas
- PredictSys

Affected versions
- >=v3

Test cases
1. Enter "1" to select "Office Box Prediction" in [System Home]
2. Enter "1" to select "Start New Prediction" in [Office Box Prediction]
3. Enter invalid keyword (e.g. "tomJai") to process recommendation


Test result
- At testing step(3), error message "Please input the exact number of data as specified!" is shown
- After error message, enter message is prompted to ask user entering parameters again