Source:
private void sendNextNotification(final long timeout, final TimeUnit timeUnit) throws InterruptedException { final T notification; synchronized(pushManager.getQueue()) { notification = this.pushManager.getQueue().poll(timeout, timeUnit); pushManager.getQueue().notifyAll(); } if (this.isInterrupted()) { this.pushManager.enqueuePushNotification(notification, true); } else if (notification != null) { final SendableApnsPushNotification<T> sendableNotification = new SendableApnsPushNotification<T>(notification, this.sequenceNumber++); final String threadName = this.getName(); if (log.isTraceEnabled()) { log.trace(String.format("%s sending %s", threadName, sendableNotification)); } this.sentNotificationBuffer.addSentNotification(sendableNotification); this.channel.write(sendableNotification).addListener(new GenericFutureListener<ChannelFuture>() { public void operationComplete(final ChannelFuture future) { if (future.cause() != null) { if (log.isTraceEnabled()) { log.trace(String.format("%s failed to write notification %s", threadName, sendableNotification), future.cause()); } requestReconnection(); final T failedNotification = sentNotificationBuffer.getAndRemoveNotificationWithSequenceNumber( sendableNotification.getSequenceNumber()); if (failedNotification != null) { pushManager.enqueuePushNotification(failedNotification, true); } } else { if (log.isTraceEnabled()) { log.trace(String.format("%s successfully wrote notification %d", threadName, sendableNotification.getSequenceNumber())); } } } }); this.hasEverSentNotification = true; if (++this.writesSinceLastFlush >= ApnsClientThread.BATCH_SIZE) { this.channel.flush(); this.writesSinceLastFlush = 0; } } else { if (this.writesSinceLastFlush > 0) { this.channel.flush(); this.writesSinceLastFlush = 0; } } }

Target:
private void sendNextNotification(final long timeout, final TimeUnit timeUnit) throws InterruptedException { final T notification = this.pushManager.getQueue().poll(timeout, timeUnit); if (this.isInterrupted()) { this.pushManager.enqueuePushNotification(notification, true); } else if (notification != null) { final SendableApnsPushNotification<T> sendableNotification = new SendableApnsPushNotification<T>(notification, this.sequenceNumber++); final String threadName = this.getName(); if (log.isTraceEnabled()) { log.trace(String.format("%s sending %s", threadName, sendableNotification)); } this.sentNotificationBuffer.addSentNotification(sendableNotification); this.channel.write(sendableNotification).addListener(new GenericFutureListener<ChannelFuture>() { public void operationComplete(final ChannelFuture future) { synchronized(pushManager.getQueue()) { pushManager.getQueue().notifyAll(); } if (future.cause() != null) { if (log.isTraceEnabled()) { log.trace(String.format("%s failed to write notification %s", threadName, sendableNotification), future.cause()); } requestReconnection(); final T failedNotification = sentNotificationBuffer.getAndRemoveNotificationWithSequenceNumber( sendableNotification.getSequenceNumber()); if (failedNotification != null) { pushManager.enqueuePushNotification(failedNotification, true); } } else { if (log.isTraceEnabled()) { log.trace(String.format("%s successfully wrote notification %d", threadName, sendableNotification.getSequenceNumber())); } } } }); this.hasEverSentNotification = true; if (++this.writesSinceLastFlush >= ApnsClientThread.BATCH_SIZE) { this.channel.flush(); this.writesSinceLastFlush = 0; } } else { if (this.writesSinceLastFlush > 0) { this.channel.flush(); this.writesSinceLastFlush = 0; } } }