Skip to content

Commit 5579875

Browse files
committed
provide default value for pages if it's missing
1 parent 88ab48c commit 5579875

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

srv/src/main/java/my/bookshop/handlers/CatalogServiceHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public void discountBooks(Stream<Books> books) {
150150
@After(event = CqnService.EVENT_READ)
151151
public void bigBooks(Stream<Books> books) {
152152
books.filter(b -> b.getDetails() != null).forEach(b -> {
153-
int pages = (int) b.getDetails().get("pages");
153+
int pages = (int) b.getDetails().getOrDefault("pages", 0);
154154
if (pages > 400) {
155155
b.setTitle("%s -- Big Book".formatted(b.getTitle()));
156156
}

0 commit comments

Comments
 (0)