Browse Source

Add missing null check

Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.1-alpha v0.0.1-alpha
Pekka Helenius 4 years ago
parent
commit
0e0c0feb00
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java

+ 4
- 2
bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java View File

@ -213,8 +213,10 @@ public class BookController {
Book bookI = bookRepository.findByIsbn(book.getIsbn());
// If existing ISBN value is not attached to the current book...
if (bookI.getId() != book.getId()) {
bindingResult.rejectValue("isbn", "error.user", "ISBN code already exists");
if (bookI != null) {
if (bookI.getId() != book.getId()) {
bindingResult.rejectValue("isbn", "error.user", "ISBN code already exists");
}
}
if (bindingResult.hasErrors()) {


Loading…
Cancel
Save