aboutsummaryrefslogtreecommitdiff
path: root/juick-notifications/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-09-20 15:19:50 +0300
committerGravatar Vitaly Takmazov2018-09-20 15:19:50 +0300
commit0f81b6e6b16932e472f770ea18842d367edb6d79 (patch)
treec0a6fc2660eff1e69df35df82d3efec6d14b4fb1 /juick-notifications/src/main/java/com/juick
parentf58bb4d659f5d7dd43255a61ac8cb5023859d59d (diff)
APNS: fix NPE
Diffstat (limited to 'juick-notifications/src/main/java/com/juick')
-rw-r--r--juick-notifications/src/main/java/com/juick/components/Notifications.java13
1 files changed, 9 insertions, 4 deletions
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<Date> 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);
}