@@ -78,7 +78,7 @@ public abstract class SecretCacheObject<T> {
7878     * AWS Secrets Manager request.  This is used to calculate an exponential 
7979     * backoff. 
8080     */ 
81-     private  long  exceptionCount  = 0 ;
81+     private  long  exceptionBackoffPower  = 0 ;
8282
8383    /** 
8484     * The time to wait before retrying a failed AWS Secrets Manager request. 
@@ -187,20 +187,24 @@ private void refresh() {
187187        try  {
188188            this .setResult (this .executeRefresh ());
189189            this .exception  = null ;
190-             this .exceptionCount  = 0 ;
190+             this .exceptionBackoffPower  = 0 ;
191191        } catch  (RuntimeException  ex ) {
192192            this .exception  = ex ;
193193            // Determine the amount of growth in exception backoff time based on the growth 
194194            // factor and default backoff duration. 
195195            Long  growth  = 1L ;
196-             if  (this .exceptionCount  > 0 ) {
197-                 growth  = (long )Math .pow (EXCEPTION_BACKOFF_GROWTH_FACTOR , this .exceptionCount );
196+             if  (this .exceptionBackoffPower  > 0 ) {
197+                 growth  = (long )Math .pow (EXCEPTION_BACKOFF_GROWTH_FACTOR , this .exceptionBackoffPower );
198198            }
199-             this .exceptionCount  += 1 ;
200199            growth  *= EXCEPTION_BACKOFF ;
201200            // Add in EXCEPTION_BACKOFF time to make sure the random jitter will not reduce 
202201            // the wait time too low. 
203202            Long  retryWait  = Math .min (EXCEPTION_BACKOFF  + growth , BACKOFF_PLATEAU );
203+             if  ( retryWait  < BACKOFF_PLATEAU  ) {
204+                 // Only increase the backoff power if we haven't hit the backoff plateau yet. 
205+                 this .exceptionBackoffPower  += 1 ;
206+             }
207+ 
204208            // Use random jitter with the wait time 
205209            retryWait  = ThreadLocalRandom .current ().nextLong (retryWait  / 2 , retryWait  + 1 );
206210            this .nextRetryTime  = System .currentTimeMillis () + retryWait ;
0 commit comments