Bug 272

Summary: [SearchEngine] java.lang.NumberFormatException thrown when searching movie
Product: MovieXXX Reporter: tomfong521
Component: MovieAnalysisEngineAssignee: clwong274-c
Status: RESOLVED FIXED    
Severity: blocker    
Priority: High    
Version: 2.0   
Hardware: PC   
OS: Windows   
Deadline: 2018-11-24   

Description tomfong521 2018-11-30 00:29:56 HKT
Details:
After enter keyword to filter recommendation, an java.lang.NumberFormatException is thrown

Reproducible steps
1. Enter "2" to select "Film Recommendation" in [System Home]
2. Enter "1" to select "Start New Recommendation" in [Office Box Prediction]
3. Enter keyword (e.g. "-L korean") to process recommendation

Expected results:
- At step (3), no exception or error should be shown, recommendation can be performed and printed successfully. 

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

Detailed console output:
 >> Enter any keyword to filter your customised recommendation: 
 >> korean
 >> Exception in thread "main" java.lang.NumberFormatException: For input string: "4200000000"
 >> 	at java.lang.NumberFormatException.forInputString(Unknown Source)
 >> 	at java.lang.Integer.parseInt(Unknown Source)
 >> 	at java.lang.Integer.parseInt(Unknown Source)
 >> 	at movieRating.SearchEngine.searchMovie(SearchEngine.java:33)
 >> 	at movieRating.RecommendSys.doNewRecommendation(RecommendSys.java:21)
 >> 	at movieRating.RecommendSys.enter(RecommendSys.java:47)
 >> 	at movieRating.Main.main(Main.java:28)
Comment 1 clwong274-c 2018-11-30 01:04:42 HKT
Root cause
- There are data in the database from columns "budget" and "gross" that exceed the value range of int (-2,147,483,648 .. 2,147,483,647). When these data are read as string and being phrased into int type, number format exception will be thrown

How to fix
- Changed the variable types for "budget" and "gross"

Expected behavior
- No exception or error should be shown, reading database and search can be performed successfully and properly

Potential affected areas
- SearchEngine

Affected versions
- >=v3

Test cases
1. Edit a test database. Enter movie info to satisfy following (e.g. given search parameter "german"):
   MovieA: budget="1687311" language="english"
   MovieB: budget="12215500000" language="german"
2. Enter "2" to select "Film Recommendation" in [System Home]
3. Enter "1" to select "Start New Recommendation" in [Office Box Prediction]
4. Enter keyword (e.g. "german") to process recommendation


Test result
- At step (4), no exception or error is shown, recommendation is performed and printed successfully
- Printed output: MovieB