public AdHocThrottle getThrottle ( AdHocThrottleEndpoint endpoint ) { String key = endpoint . toString ( ) ; AdHocThrottle throttle = _throttleMap . get ( key ) ; if ( throttle == null ) { // No throttle set, allow unlimited throttle = AdHocThrottle . unlimitedInstance ( ) ; } else if ( throttle . getExpiration ( ) . isBefore ( Instant . now ( ) ) ) { // Throttle is expired; remove it and allow unlimited. There is a slight chance for a race condition // here but since throttles are rarely put in place this is extremely unlikely. To help avoid this // wait 24 hours before removing. if ( throttle . getExpiration ( ) . isBefore ( Instant . now ( ) . minus ( Duration . ofDays ( 1 ) ) ) ) { try { _throttleMap . remove ( key ) ; } catch ( Exception e ) { _log . warn ( "Failed to remove expired throttle for {} {}" , endpoint . getMethod ( ) , endpoint . getPath ( ) , e ) ; } } throttle = AdHocThrottle . unlimitedInstance ( ) ; } return throttle ; }
Returns the throttle in effect for the given HTTP method and path . This method is always guaranteed to return a non - null throttle that is not expired . If no throttle has been configured or if the configured throttle has expired then it will return an unlimited throttle with an effectively infinite expiration date .