Bug 269 - [SearchEngine] java.lang.NumberFormatException thrown when searching movie
Summary: [SearchEngine] java.lang.NumberFormatException thrown when searching movie
Status: RESOLVED FIXED
Alias: None
Product: MovieXXX
Classification: Unclassified
Component: MovieAnalysisEngine (show other bugs)
Version: 1.0
Hardware: PC Windows
: High blocker
Deadline: 2018-11-17
Assignee: clwong274-c
URL:
Depends on:
Blocks:
 
Reported: 2018-11-29 22:39 HKT by tomfong521
Modified: 2018-11-30 00:05 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-29 22:39:46 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. "german") 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: 
 >> german
 >> Exception in thread "main" java.lang.NumberFormatException: For input string: ""
 >> 	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:31)
 >> 	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 00:05:54 HKT
Root cause
- There are empty data cells in the database, when these data are read as string and being phrased into other type (e.g. integer in SearchEngine.java:31) format exception will be thrown

How to fix
- Added to check if the read data is empty string before phrasing, pass "" instead if so

Expected behavior
- No exception or error should be shown, recommendation can be performed and printed successfully

Potential affected areas
- SearchEngine

Affected versions
- >=v2

Test cases
1. Edit a test database with four movies in it. Enter movie info to satisfy following (e.g. given search parameter "german"):
   MovieA: movie_title="1984" title_year="2018" language="english"
   MovieB: movie_title="Hello world" title_year=""(empty) 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
- Movie row in database with empty data can be used to construct a Film class object
- Printed output: MovieB