Source:
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.pendingOperationLock.lock(); try { this.apnsConnection.pendingOperationCount += 1; } finally { this.apnsConnection.pendingOperationLock.unlock(); } 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 %d; 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.pendingOperationLock.lock(); try { this.apnsConnection.pendingOperationCount -= 1; if (this.apnsConnection.pendingOperationCount == 0) { this.apnsConnection.pendingOperationsFinished.signalAll(); } } finally { this.apnsConnection.pendingOperationLock.unlock(); } }

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(); }