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)
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