Source:
<code>public void sendPushMessage(final Variant variant, final Collection<String> tokens, final UnifiedPushMessage pushMessage, final String pushMessageInformationId, final NotificationSenderCallback senderCallback) { <START> if (tokens.isEmpty()) { <END> System.out.println(tokens); return; } final iOSVariant iOSVariant = (iOSVariant) variant; final String payload; { try { payload = createPushPayload(pushMessage.getMessage(), pushMessageInformationId); } catch (IllegalArgumentException iae) { logger.info(iae.getMessage(), iae); senderCallback.onError("Nothing sent to APNs since the payload is too large"); return; } } final ApnsClient apnsClient = buildApnsClient(iOSVariant); final Future<Void> connectFuture = apnsClient.connect(ApnsClient.DEVELOPMENT_APNS_HOST, ApnsClient.DEFAULT_APNS_PORT); connectFuture.addListener(future -> { if (future.isSuccess()) { logger.debug("connected!"); System.out.println("connected ? " + apnsClient.isConnected()); if (apnsClient.isConnected()) { senderCallback.onSuccess(); final String defaultApnsTopic = ApnsUtil.readDefaultTopic(iOSVariant.getCertificate(), iOSVariant.getPassphrase().toCharArray()); logger.error("sending payload for all tokens for to APNs ({})", iOSVariant.getVariantID(), defaultApnsTopic); tokens.forEach(token -> { System.out.println("processing token: " + token); final SimpleApnsPushNotification pushNotification = new SimpleApnsPushNotification(token, defaultApnsTopic, payload); final Future<PushNotificationResponse<SimpleApnsPushNotification>> notificationSendFuture = apnsClient.sendNotification(pushNotification); notificationSendFuture.addListener(sendfuture -> { if (sendfuture .isSuccess()) { handlePushNotificationResponsePerToken(notificationSendFuture.get(), pushMessageInformationId, variant.getId()); } }); }); } else { logger.error("Unable to send notifications, client is not connected. Removing from cache pool"); senderCallback.onError("Unable to send notifications, client is not connected"); } } else { final Throwable t = future.cause(); logger.warn(t.getMessage(), t); } }); }</code><technical_language>method is public, is exposed uncontrolled calls. I suggest checking for null well</technical_language>

Target:
public void sendPushMessage(final Variant variant, final Collection<String> tokens, final UnifiedPushMessage pushMessage, final String pushMessageInformationId, final NotificationSenderCallback senderCallback) { Objects.requireNonNull(variant, "Variant can not be null"); Objects.requireNonNull(tokens, "device tokens can not be null"); Objects.requireNonNull(pushMessage, "push message content can not be null"); Objects.requireNonNull(pushMessageInformationId, "push message ID can not be null"); Objects.requireNonNull(senderCallback, "sender cb can not be null"); if (tokens.isEmpty()) { return; } final iOSVariant iOSVariant = (iOSVariant) variant; final String payload; { try { payload = createPushPayload(pushMessage.getMessage(), pushMessageInformationId); } catch (IllegalArgumentException iae) { logger.info(iae.getMessage(), iae); senderCallback.onError("Nothing sent to APNs since the payload is too large"); return; } } final ApnsClient apnsClient; { try { apnsClient = receiveApnsConnection(iOSVariant); } catch (IllegalArgumentException iae) { logger.error(iae.getMessage(), iae); senderCallback.onError(String.format("Unable to connect to APNs (%s))", iae.getMessage())); return; } } if (apnsClient.isConnected()) { senderCallback.onSuccess(); final String defaultApnsTopic = ApnsUtil.readDefaultTopic(iOSVariant.getCertificate(), iOSVariant.getPassphrase().toCharArray()); logger.error("sending payload for all tokens for to APNs ({})", iOSVariant.getVariantID(), defaultApnsTopic); tokens.forEach(token -> { final SimpleApnsPushNotification pushNotification = new SimpleApnsPushNotification(token, defaultApnsTopic, payload); final Future<PushNotificationResponse<SimpleApnsPushNotification>> notificationSendFuture = apnsClient.sendNotification(pushNotification); notificationSendFuture.addListener(future -> { if (future.isSuccess()) { handlePushNotificationResponsePerToken(notificationSendFuture.get(), pushMessageInformationId, variant.getId()); } }); }); } else { logger.error("Unable to send notifications, client is not connected. Removing from cache pool"); senderCallback.onError("Unable to send notifications, client is not connected"); } }