Polishing

This commit is contained in:
Sam Brannen 2025-07-02 10:58:50 +02:00
parent 5cae769c2d
commit b794abd8cb
6 changed files with 20 additions and 24 deletions

View File

@ -30,7 +30,7 @@ import org.springframework.util.ConcurrencyThrottleSupport;
*
* <p>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).
*
* <p>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
*/

View File

@ -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);

View File

@ -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

View File

@ -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}.
*
* <p>These annotations can also be individually enabled through
* defining a {@link RetryAnnotationBeanPostProcessor} and/or a
* <p>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.
* <p>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;

View File

@ -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.<Integer>getNumber("order"));
proxySupport.setOrder(this.enableResilientMethods.getNumber("order"));
}
}

View File

@ -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