private int processedFailedNotifications ( ) throws CommunicationException , KeystoreException { if ( useEnhancedNotificationFormat ) { logger . debug ( "Reading responses" ) ; int responsesReceived = ResponsePacketReader . processResponses ( this ) ; while ( responsesReceived > 0 ) { PushedNotification skippedNotification = null ; List < PushedNotification > notificationsToResend = new ArrayList < PushedNotification > ( ) ; boolean foundFirstFail = false ; for ( PushedNotification notification : pushedNotifications . values ( ) ) { if ( foundFirstFail || ! notification . isSuccessful ( ) ) { if ( foundFirstFail ) notificationsToResend . add ( notification ) ; else { foundFirstFail = true ; skippedNotification = notification ; } } } pushedNotifications . clear ( ) ; int toResend = notificationsToResend . size ( ) ; logger . debug ( "Found " + toResend + " notifications that must be re-sent" ) ; if ( toResend > 0 ) { logger . debug ( "Restarting connection to resend notifications" ) ; restartPreviousConnection ( ) ; for ( PushedNotification pushedNotification : notificationsToResend ) { sendNotification ( pushedNotification , false ) ; } } int remaining = responsesReceived = ResponsePacketReader . processResponses ( this ) ; if ( remaining == 0 ) { logger . debug ( "No notifications remaining to be resent" ) ; return 0 ; } } return responsesReceived ; } else { logger . debug ( "Not reading responses because using simple notification format" ) ; return 0 ; } }
Read and process any pending error - responses .