From 0f81b6e6b16932e472f770ea18842d367edb6d79 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 20 Sep 2018 15:19:50 +0300 Subject: APNS: fix NPE --- .../src/main/java/com/juick/components/Notifications.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'juick-notifications/src/main/java/com/juick/components') diff --git a/juick-notifications/src/main/java/com/juick/components/Notifications.java b/juick-notifications/src/main/java/com/juick/components/Notifications.java index 53bf8684..a42f23cb 100644 --- a/juick-notifications/src/main/java/com/juick/components/Notifications.java +++ b/juick-notifications/src/main/java/com/juick/components/Notifications.java @@ -229,10 +229,15 @@ public class Notifications extends TextWebSocketHandler implements NotificationC invalidAPNSTokens.add(token); } } - if (pushNotificationResponse.getTokenInvalidationTimestamp().before(new Date())) { - logger.info("Token invalidated: {}", token); - invalidAPNSTokens.add(token); - } + Optional invalidationDate = Optional.ofNullable( + pushNotificationResponse.getTokenInvalidationTimestamp()); + invalidationDate.ifPresent(date -> { + if (date.before(new Date())) { + logger.info("Token invalidated: {}", token); + invalidAPNSTokens.add(token); + } + }); + } catch (final ExecutionException | InterruptedException ex) { logger.info("APNS exception", ex); } -- cgit v1.2.3