mehb-groww / test1

Boxed Boolean values should not be used in conditional expressions JAVA-E1054
Bug risk
Major
a year agoa year old
This would throw a NullPointerException if bookread were null
45        query = "SELECT * FROM Books WHERE author LIKE '%" + bookauthor + "%'";
46      } else if (bookread != null) {
47        // Filter by if the book has been read or not
48        Integer read = bookread ? 1 : 0;49        query = "SELECT * FROM Books WHERE read = '" + read.toString() + "'";
50      } else {
51        // All books
This would throw a NullPointerException if read were null
73			try (PreparedStatement prepStmt = connection.prepareStatement(query);) {
74			  prepStmt.setString(1, book.name);
75			  prepStmt.setString(2, book.author);
76			  prepStmt.setInt(3, book.read? 1 : 0);77	
78			  prepStmt.executeUpdate();
79