From 7ace9c46da8a42e47f9058afe4e8e5da0f27ab23 Mon Sep 17 00:00:00 2001 From: MageFroh Date: Tue, 9 Jul 2013 23:00:47 +0100 Subject: [PATCH] fix null ptr exception in feed/get/{id} rest call when all entries are read - map of the unread counts does not contain any element for the feed if no entry is unread, leading to a null pointer exception when building the response - problem occurs for example when showing the feed details and all entries are read: all fields are blank --- .../java/com/commafeed/frontend/rest/resources/FeedREST.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/commafeed/frontend/rest/resources/FeedREST.java b/src/main/java/com/commafeed/frontend/rest/resources/FeedREST.java index 42a525be..2dfb0e61 100644 --- a/src/main/java/com/commafeed/frontend/rest/resources/FeedREST.java +++ b/src/main/java/com/commafeed/frontend/rest/resources/FeedREST.java @@ -308,6 +308,9 @@ public class FeedREST extends AbstractResourceREST { return Response.status(Status.NOT_FOUND).build(); } Long unreadCount = feedSubscriptionService.getUnreadCount(getUser()).get(id); + if (unreadCount == null) { + unreadCount = new Long(0); + } return Response.ok( Subscription.build(sub, applicationSettingsService.get() .getPublicUrl(), unreadCount)).build();