From b794abd8cbe330231d9d10ec5c721f99729ad0c0 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Wed, 2 Jul 2025 10:58:50 +0200 Subject: [PATCH] Polishing --- .../ConcurrencyThrottleInterceptor.java | 4 +-- .../ConcurrencyThrottleInterceptorTests.java | 26 ++++++++----------- .../ConcurrencyLimitBeanPostProcessor.java | 2 +- .../annotation/EnableResilientMethods.java | 8 +++--- .../ResilientMethodsConfiguration.java | 2 +- .../RetryAnnotationBeanPostProcessor.java | 2 +- 6 files changed, 20 insertions(+), 24 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptor.java b/spring-aop/src/main/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptor.java index e7f267a942..528cbdb9f0 100644 --- a/spring-aop/src/main/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptor.java +++ b/spring-aop/src/main/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptor.java @@ -30,7 +30,7 @@ import org.springframework.util.ConcurrencyThrottleSupport; * *

Can be applied to methods of local services that involve heavy use * of system resources, in a scenario where it is more efficient to - * throttle concurrency for a specific service rather than restricting + * throttle concurrency for a specific service rather than restrict * the entire thread pool (for example, the web container's thread pool). * *

The default concurrency limit of this interceptor is 1. @@ -53,7 +53,7 @@ public class ConcurrencyThrottleInterceptor extends ConcurrencyThrottleSupport } /** - * Create a default {@code ConcurrencyThrottleInterceptor} + * Create a {@code ConcurrencyThrottleInterceptor} * with the given concurrency limit. * @since 7.0 */ diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java index ac4e62ebb8..82d5fa7ba5 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java @@ -19,6 +19,8 @@ package org.springframework.aop.interceptor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; @@ -30,21 +32,23 @@ import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; /** + * Tests for {@link ConcurrencyThrottleInterceptor}. + * * @author Juergen Hoeller * @author Chris Beams * @since 06.04.2004 */ class ConcurrencyThrottleInterceptorTests { - protected static final Log logger = LogFactory.getLog(ConcurrencyThrottleInterceptorTests.class); + private static final Log logger = LogFactory.getLog(ConcurrencyThrottleInterceptorTests.class); - public static final int NR_OF_THREADS = 100; + private static final int NR_OF_THREADS = 100; - public static final int NR_OF_ITERATIONS = 1000; + private static final int NR_OF_ITERATIONS = 1000; @Test - void testSerializable() throws Exception { + void interceptorMustBeSerializable() throws Exception { DerivedTestBean tb = new DerivedTestBean(); ProxyFactory proxyFactory = new ProxyFactory(); proxyFactory.setInterfaces(ITestBean.class); @@ -62,17 +66,9 @@ class ConcurrencyThrottleInterceptorTests { serializedProxy.getAge(); } - @Test - void testMultipleThreadsWithLimit1() { - testMultipleThreads(1); - } - - @Test - void testMultipleThreadsWithLimit10() { - testMultipleThreads(10); - } - - private void testMultipleThreads(int concurrencyLimit) { + @ParameterizedTest + @ValueSource(ints = {1, 10}) + void multipleThreadsWithLimit(int concurrencyLimit) { TestBean tb = new TestBean(); ProxyFactory proxyFactory = new ProxyFactory(); proxyFactory.setInterfaces(ITestBean.class); diff --git a/spring-context/src/main/java/org/springframework/resilience/annotation/ConcurrencyLimitBeanPostProcessor.java b/spring-context/src/main/java/org/springframework/resilience/annotation/ConcurrencyLimitBeanPostProcessor.java index 5bdf6f0be0..62f646ddc9 100644 --- a/spring-context/src/main/java/org/springframework/resilience/annotation/ConcurrencyLimitBeanPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/resilience/annotation/ConcurrencyLimitBeanPostProcessor.java @@ -39,7 +39,7 @@ import org.springframework.util.ConcurrentReferenceHashMap; /** * A convenient {@link org.springframework.beans.factory.config.BeanPostProcessor * BeanPostProcessor} that applies a concurrency interceptor to all bean methods - * annotated with {@link ConcurrencyLimit} annotations. + * annotated with {@link ConcurrencyLimit @ConcurrencyLimit}. * * @author Juergen Hoeller * @since 7.0 diff --git a/spring-context/src/main/java/org/springframework/resilience/annotation/EnableResilientMethods.java b/spring-context/src/main/java/org/springframework/resilience/annotation/EnableResilientMethods.java index edea2e0a7f..4facad6d4e 100644 --- a/spring-context/src/main/java/org/springframework/resilience/annotation/EnableResilientMethods.java +++ b/spring-context/src/main/java/org/springframework/resilience/annotation/EnableResilientMethods.java @@ -27,10 +27,10 @@ import org.springframework.core.Ordered; /** * Enables Spring's core resilience features for method invocations: - * {@link Retryable} as well as {@link ConcurrencyLimit}. + * {@link Retryable @Retryable} as well as {@link ConcurrencyLimit @ConcurrencyLimit}. * - *

These annotations can also be individually enabled through - * defining a {@link RetryAnnotationBeanPostProcessor} and/or a + *

These annotations can also be individually enabled by + * defining a {@link RetryAnnotationBeanPostProcessor} or a * {@link ConcurrencyLimitBeanPostProcessor}. * * @author Juergen Hoeller @@ -61,7 +61,7 @@ public @interface EnableResilientMethods { * Indicate the order in which the {@link RetryAnnotationBeanPostProcessor} * and {@link ConcurrencyLimitBeanPostProcessor} should be applied. *

The default is {@link Ordered#LOWEST_PRECEDENCE} in order to run - * after all other post-processors, so that it can add an advisor to + * after all other post-processors, so that they can add advisors to * existing proxies rather than double-proxy. */ int order() default Ordered.LOWEST_PRECEDENCE; diff --git a/spring-context/src/main/java/org/springframework/resilience/annotation/ResilientMethodsConfiguration.java b/spring-context/src/main/java/org/springframework/resilience/annotation/ResilientMethodsConfiguration.java index 338a8fe1fa..ae3f70102c 100644 --- a/spring-context/src/main/java/org/springframework/resilience/annotation/ResilientMethodsConfiguration.java +++ b/spring-context/src/main/java/org/springframework/resilience/annotation/ResilientMethodsConfiguration.java @@ -53,7 +53,7 @@ public class ResilientMethodsConfiguration implements ImportAware { private void configureProxySupport(ProxyProcessorSupport proxySupport) { if (this.enableResilientMethods != null) { proxySupport.setProxyTargetClass(this.enableResilientMethods.getBoolean("proxyTargetClass")); - proxySupport.setOrder(this.enableResilientMethods.getNumber("order")); + proxySupport.setOrder(this.enableResilientMethods.getNumber("order")); } } diff --git a/spring-context/src/main/java/org/springframework/resilience/annotation/RetryAnnotationBeanPostProcessor.java b/spring-context/src/main/java/org/springframework/resilience/annotation/RetryAnnotationBeanPostProcessor.java index 7c5afc175a..e9d80657d4 100644 --- a/spring-context/src/main/java/org/springframework/resilience/annotation/RetryAnnotationBeanPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/resilience/annotation/RetryAnnotationBeanPostProcessor.java @@ -45,7 +45,7 @@ import org.springframework.util.StringValueResolver; /** * A convenient {@link org.springframework.beans.factory.config.BeanPostProcessor * BeanPostProcessor} that applies a retry interceptor to all bean methods - * annotated with {@link Retryable} annotations. + * annotated with {@link Retryable @Retryable}. * * @author Juergen Hoeller * @since 7.0