diff --git a/pom.xml b/pom.xml index 561e0f2e2..be05c4232 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ 1.2.0 9.4-1201-jdbc41 3.17.1 - 0.14.2 + 0.15.0 1.5.0 3.1.0 1.7.30 diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/push/RetryingApnsClient.java b/service/src/main/java/org/whispersystems/textsecuregcm/push/RetryingApnsClient.java index 0f6a63c30..3fa47d713 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/push/RetryingApnsClient.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/push/RetryingApnsClient.java @@ -88,12 +88,15 @@ public class RetryingApnsClient { if (response != null) { if (response.isAccepted()) { future.set(new ApnResult(ApnResult.Status.SUCCESS, null)); - } else if ("Unregistered".equals(response.getRejectionReason()) || - "BadDeviceToken".equals(response.getRejectionReason())) { - future.set(new ApnResult(ApnResult.Status.NO_SUCH_USER, response.getRejectionReason())); } else { - logger.warn("Got APN failure: " + response.getRejectionReason()); - future.set(new ApnResult(ApnResult.Status.GENERIC_FAILURE, response.getRejectionReason())); + final String rejectionReason = response.getRejectionReason().orElse(null); + + if ("Unregistered".equals(rejectionReason) || "BadDeviceToken".equals(rejectionReason)) { + future.set(new ApnResult(ApnResult.Status.NO_SUCH_USER, rejectionReason)); + } else { + logger.warn("Got APN failure: {}", rejectionReason); + future.set(new ApnResult(ApnResult.Status.GENERIC_FAILURE, rejectionReason)); + } } } else { logger.warn("Execution exception", cause); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/push/APNSenderTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/push/APNSenderTest.java index b56bac8fd..7f0f11af8 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/push/APNSenderTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/push/APNSenderTest.java @@ -128,7 +128,7 @@ public class APNSenderTest { PushNotificationResponse response = mock(PushNotificationResponse.class); when(response.isAccepted()).thenReturn(false); - when(response.getRejectionReason()).thenReturn("Unregistered"); + when(response.getRejectionReason()).thenReturn(Optional.of("Unregistered")); when(apnsClient.sendNotification(any(SimpleApnsPushNotification.class))) .thenAnswer((Answer) invocationOnMock -> new MockPushNotificationFuture<>(invocationOnMock.getArgument(0), response)); @@ -232,7 +232,7 @@ public class APNSenderTest { PushNotificationResponse response = mock(PushNotificationResponse.class); when(response.isAccepted()).thenReturn(false); - when(response.getRejectionReason()).thenReturn("Unregistered"); + when(response.getRejectionReason()).thenReturn(Optional.of("Unregistered")); when(apnsClient.sendNotification(any(SimpleApnsPushNotification.class))) .thenAnswer((Answer) invocationOnMock -> new MockPushNotificationFuture<>(invocationOnMock.getArgument(0), response)); @@ -327,7 +327,7 @@ public class APNSenderTest { PushNotificationResponse response = mock(PushNotificationResponse.class); when(response.isAccepted()).thenReturn(false); - when(response.getRejectionReason()).thenReturn("BadTopic"); + when(response.getRejectionReason()).thenReturn(Optional.of("BadTopic")); when(apnsClient.sendNotification(any(SimpleApnsPushNotification.class))) .thenAnswer((Answer) invocationOnMock -> new MockPushNotificationFuture<>(invocationOnMock.getArgument(0), response));