diff --git a/src/main/java/org/ntlab/citrusserver/repositories/PublicBookManager.java b/src/main/java/org/ntlab/citrusserver/repositories/PublicBookManager.java index bde074a..f8cc181 100644 --- a/src/main/java/org/ntlab/citrusserver/repositories/PublicBookManager.java +++ b/src/main/java/org/ntlab/citrusserver/repositories/PublicBookManager.java @@ -113,7 +113,12 @@ case 1: ArrayList booksForSort = new ArrayList<>(); for(Book book : books){ - booksForSort.add(new BookForSort(book, favoriteManager.getFavorited(book.getAccountId(), book.getBookId()).size())); + HashSet favorites = favoriteManager.getFavorited(book.getAccountId(), book.getBookId()); + int count = 0; + if(favorites != null){ + count = favorites.size(); + } + booksForSort.add(new BookForSort(book, count)); } booksForSort.sort(Comparator.comparing(BookForSort::favoriteNum).reversed()); ArrayList res = new ArrayList<>();