Source:
protected void channelRead0(final ChannelHandlerContext context, final RejectedNotification rejectedNotification) { log.debug(String.format("APNs gateway rejected notification with sequence number %d from %s (%s).", rejectedNotification.getSequenceNumber(), this.apnsConnection.name, rejectedNotification.getReason())); this.apnsConnection.sentNotificationBuffer.clearNotificationsBeforeSequenceNumber(rejectedNotification.getSequenceNumber()); final boolean isKnownBadRejection = this.apnsConnection.shutdownNotification != null && rejectedNotification.getSequenceNumber() == this.apnsConnection.shutdownNotification.getSequenceNumber(); if (!isKnownBadRejection && !RejectedNotificationReason.SHUTDOWN.equals(rejectedNotification.getReason())) { final T notification = this.apnsConnection.sentNotificationBuffer.getNotificationWithSequenceNumber( rejectedNotification.getSequenceNumber()); if (notification != null) { this.apnsConnection.listener.handleRejectedNotification( this.apnsConnection, notification, rejectedNotification.getReason()); } else { log.error(String.format("%s failed to find rejected notification with sequence number %d; this " + "most likely means the sent notification buffer is too small. Please report this as a bug.", this.apnsConnection.name, rejectedNotification.getSequenceNumber())); } } final Collection<T> unprocessedNotifications = this.apnsConnection.sentNotificationBuffer.getAllNotificationsAfterSequenceNumber( rejectedNotification.getSequenceNumber()); if (!unprocessedNotifications.isEmpty()) { this.apnsConnection.listener.handleUnprocessedNotifications(this.apnsConnection, unprocessedNotifications); } }

Target:
protected void channelRead0(final ChannelHandlerContext context, final RejectedNotification rejectedNotification) { log.debug("APNs gateway rejected notification with sequence number from ({}).", rejectedNotification.getSequenceNumber(), this.apnsConnection.name, rejectedNotification.getReason()); this.apnsConnection.rejectionReceived = true; this.apnsConnection.sentNotificationBuffer.clearNotificationsBeforeSequenceNumber(rejectedNotification.getSequenceNumber()); final boolean isKnownBadRejection = this.apnsConnection.shutdownNotification != null && rejectedNotification.getSequenceNumber() == this.apnsConnection.shutdownNotification.getSequenceNumber(); if (!isKnownBadRejection && !RejectedNotificationReason.SHUTDOWN.equals(rejectedNotification.getReason())) { final T notification = this.apnsConnection.sentNotificationBuffer.getNotificationWithSequenceNumber( rejectedNotification.getSequenceNumber()); if (notification != null) { this.apnsConnection.listener.handleRejectedNotification( this.apnsConnection, notification, rejectedNotification.getReason()); } else { log.error("{} failed to find rejected notification with sequence number {}; this may mean the " + "sent notification buffer is too small. Please report this as a bug.", this.apnsConnection.name, rejectedNotification.getSequenceNumber()); } } final Collection<T> unprocessedNotifications = this.apnsConnection.sentNotificationBuffer.getAllNotificationsAfterSequenceNumber( rejectedNotification.getSequenceNumber()); if (!unprocessedNotifications.isEmpty()) { this.apnsConnection.listener.handleUnprocessedNotifications(this.apnsConnection, unprocessedNotifications); } this.apnsConnection.sentNotificationBuffer.clearAllNotifications(); }