@ FFDCIgnore ( { NumberFormatException . class , IllegalArgumentException . class , ParseException . class } ) private long handleRetry ( String retryValue ) { // RETRY_AFTER is a String that can either correspond to seconds (long) // or a HTTP-Date (which can be one of 7 variations)" if ( ! ( retryValue . contains ( ":" ) ) ) { // Must be a long since all dates include ":" try { Long retryLong = Long . valueOf ( retryValue ) ; //The RETRY_AFTER value is in seconds so change units return TimeUnit . MILLISECONDS . convert ( retryLong . longValue ( ) , TimeUnit . SECONDS ) ; } catch ( NumberFormatException e ) { LOG . fine ( "SSE RETRY_AFTER Incorrect time value: " + e ) ; } } else { char [ ] retryValueArray = retryValue . toCharArray ( ) ; //handle date try { SimpleDateFormat sdf = null ; // Determine the appropriate HTTP-Date pattern if ( retryValueArray [ 3 ] == ' ' ) { sdf = new SimpleDateFormat ( "EEE, dd MMM yyyy HH:mm:ss z" ) ; // RTC 822, updated by RFC 1123 } else if ( retryValueArray [ 6 ] == ' ' ) { sdf = new SimpleDateFormat ( "EEEEEE, dd-MMM-yy HH:mm:ss z" ) ; // RFC 850, obsoleted by RFC 1036 } else if ( retryValueArray [ 7 ] == ' ' ) { sdf = new SimpleDateFormat ( "EEEEEEE, dd-MMM-yy HH:mm:ss z" ) ; // RFC 850, obsoleted by RFC 1036 } else if ( retryValueArray [ 8 ] == ' ' ) { sdf = new SimpleDateFormat ( "EEEEEEEE, dd-MMM-yy HH:mm:ss z" ) ; // RFC 850, obsoleted by RFC 1036 } else if ( retryValueArray [ 9 ] == ' ' ) { sdf = new SimpleDateFormat ( "EEEEEEEEE, dd-MMM-yy HH:mm:ss z" ) ; // RFC 850, obsoleted by RFC 1036 } else if ( retryValueArray [ 8 ] == ' ' ) { sdf = new SimpleDateFormat ( "EEEEEEEE, dd-MMM-yy HH:mm:ss z" ) ; // RFC 850, obsoleted by RFC 1036 } else if ( retryValueArray [ 8 ] == ' ' ) { sdf = new SimpleDateFormat ( "EEE MMM d HH:mm:ss yyyy" ) ; // ANSI C's asctime() format } else { sdf = new SimpleDateFormat ( "EEE MMM dd HH:mm:ss yyyy" ) ; // ANSI C's asctime() format } Date retryDate = sdf . parse ( retryValue ) ; long retryTime = retryDate . getTime ( ) ; long now = System . currentTimeMillis ( ) ; long delayTime = retryTime - now ; if ( delayTime > 0 ) { return delayTime ; //HTTP Date is in milliseconds } LOG . fine ( "SSE RETRY_AFTER Date value represents a time already past" ) ; } catch ( IllegalArgumentException ex ) { LOG . fine ( "SSE RETRY_AFTER Date value format incorrect: " + ex ) ; } catch ( ParseException e2 ) { LOG . fine ( "SSE RETRY_AFTER Date value cannot be parsed: " + e2 ) ; } } return - 1L ; }
return the milliseconds to delay before reconnecting ; - 1 means don t reconnect