Skip to content

Commit 0e0c0fe

Browse files
committed
Add missing null check
Signed-off-by: Pekka Helenius <[email protected]>
1 parent bf9a113 commit 0e0c0fe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,10 @@ public String webFormUpdateBook(
213213
Book bookI = bookRepository.findByIsbn(book.getIsbn());
214214

215215
// If existing ISBN value is not attached to the current book...
216-
if (bookI.getId() != book.getId()) {
217-
bindingResult.rejectValue("isbn", "error.user", "ISBN code already exists");
216+
if (bookI != null) {
217+
if (bookI.getId() != book.getId()) {
218+
bindingResult.rejectValue("isbn", "error.user", "ISBN code already exists");
219+
}
218220
}
219221

220222
if (bindingResult.hasErrors()) {

0 commit comments

Comments
 (0)