@@ -190,6 +190,24 @@ void configuringRateAndRetryViaAnnotationsShouldWork() {
190190 assertEquals (Duration .ofSeconds (3 ), rateLimiter .getRefreshPeriod ());
191191 }
192192
193+ @ Test
194+ void configuringRateLimitAndGradualRetryViaSuperClassShouldWork () {
195+ var config = configFor (new GradualRetryAndRateLimitedOnSuperClass ());
196+ final var retry = config .getRetry ();
197+ final var testRetry = assertInstanceOf (GenericRetry .class , retry );
198+ assertEquals (
199+ BaseClassWithGradualRetryAndRateLimited .RETRY_MAX_ATTEMPTS ,
200+ testRetry .getMaxAttempts ());
201+
202+ final var rateLimiter = assertInstanceOf (LinearRateLimiter .class , config .getRateLimiter ());
203+ assertEquals (
204+ BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_MAX_RECONCILIATIONS ,
205+ rateLimiter .getLimitForPeriod ());
206+ assertEquals (
207+ Duration .ofSeconds (BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_WITHIN_SECONDS ),
208+ rateLimiter .getRefreshPeriod ());
209+ }
210+
193211 @ Test
194212 void checkingRetryingGraduallyWorks () {
195213 var config = configFor (new CheckRetryingGraduallyConfiguration ());
@@ -250,6 +268,7 @@ public UpdateControl<ConfigMap> reconcile(ConfigMap resource, Context<ConfigMap>
250268 @ ControllerConfiguration (
251269 dependents = @ Dependent (type = ReadOnlyDependent .class , name = NamedDepReconciler .NAME ))
252270 private static class NamedDepReconciler implements Reconciler <ConfigMap > {
271+
253272 private static final String NAME = "foo" ;
254273
255274 @ Override
@@ -325,6 +344,7 @@ public UpdateControl<ConfigMap> reconcile(ConfigMap resource, Context<ConfigMap>
325344 }
326345
327346 public static class TestRetry implements Retry , AnnotationConfigurable <TestRetryConfiguration > {
347+
328348 private int value ;
329349
330350 public TestRetry () {}
@@ -347,6 +367,7 @@ public void initFrom(TestRetryConfiguration configuration) {
347367 @ Target (ElementType .TYPE )
348368 @ Retention (RetentionPolicy .RUNTIME )
349369 private @interface TestRetryConfiguration {
370+
350371 int value () default 42 ;
351372 }
352373
@@ -382,7 +403,30 @@ public UpdateControl<ConfigMap> reconcile(ConfigMap resource, Context<ConfigMap>
382403 }
383404 }
384405
406+ @ ControllerConfiguration
407+ private static class GradualRetryAndRateLimitedOnSuperClass
408+ extends BaseClassWithGradualRetryAndRateLimited
409+ implements Reconciler <ConfigMap > {
410+
411+ @ Override
412+ public UpdateControl <ConfigMap > reconcile (ConfigMap resource , Context <ConfigMap > context ) {
413+ return null ;
414+ }
415+ }
416+
417+ @ RateLimited (
418+ maxReconciliations = BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_MAX_RECONCILIATIONS ,
419+ within = BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_WITHIN_SECONDS )
420+ @ GradualRetry (maxAttempts = BaseClassWithGradualRetryAndRateLimited .RETRY_MAX_ATTEMPTS )
421+ private static class BaseClassWithGradualRetryAndRateLimited {
422+
423+ public static final int RATE_LIMITED_MAX_RECONCILIATIONS = 7 ;
424+ public static final int RATE_LIMITED_WITHIN_SECONDS = 3 ;
425+ public static final int RETRY_MAX_ATTEMPTS = 3 ;
426+ }
427+
385428 private static class ControllerConfigurationOnSuperClass extends BaseClass {
429+
386430 }
387431
388432 @ ControllerConfiguration
@@ -443,10 +487,12 @@ private static class ChildCustomAnnotatedDep extends CustomAnnotatedDep {
443487
444488 @ Retention (RetentionPolicy .RUNTIME )
445489 private @interface CustomAnnotation {
490+
446491 int value ();
447492 }
448493
449494 private static class CustomConfig {
495+
450496 private final int value ;
451497
452498 private CustomConfig (int value ) {
@@ -460,6 +506,7 @@ public int getValue() {
460506
461507 private static class CustomConfigConverter
462508 implements ConfigurationConverter <CustomAnnotation , CustomConfig , CustomAnnotatedDep > {
509+
463510 static final int CONVERTER_PROVIDED_DEFAULT = 7 ;
464511
465512 @ Override
0 commit comments