Polish
This commit is contained in:
@@ -52,7 +52,7 @@ public class BinaryExceptionClassifierBuilder {
|
||||
|
||||
private boolean traverseCauses = false;
|
||||
|
||||
private List<Class<? extends Throwable>> exceptionClasses = new ArrayList<>();
|
||||
private final List<Class<? extends Throwable>> exceptionClasses = new ArrayList<>();
|
||||
|
||||
public BinaryExceptionClassifierBuilder retryOn(Class<? extends Throwable> throwable) {
|
||||
Assert.isTrue(isWhiteList == null || isWhiteList, "Please use only retryOn() or only notRetryOn()");
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
*/
|
||||
public class AnnotationMethodResolver implements MethodResolver {
|
||||
|
||||
private Class<? extends Annotation> annotationType;
|
||||
private final Class<? extends Annotation> annotationType;
|
||||
|
||||
/**
|
||||
* Create a MethodResolver for the specified Method-level annotation type
|
||||
|
||||
@@ -242,7 +242,7 @@ public class RetryConfiguration extends AbstractPointcutAdvisor
|
||||
|
||||
private static class AnnotationMethodsResolver {
|
||||
|
||||
private Class<? extends Annotation> annotationType;
|
||||
private final Class<? extends Annotation> annotationType;
|
||||
|
||||
public AnnotationMethodsResolver(Class<? extends Annotation> annotationType) {
|
||||
this.annotationType = annotationType;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2020 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -189,7 +189,7 @@ public class ExponentialBackOffPolicy implements SleepingBackOffPolicy<Exponenti
|
||||
|
||||
private long interval;
|
||||
|
||||
private long maxInterval;
|
||||
private final long maxInterval;
|
||||
|
||||
public ExponentialBackOffContext(long interval, double multiplier, long maxInterval) {
|
||||
this.interval = interval;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,7 +47,7 @@ public class UniformRandomBackOffPolicy extends StatelessBackOffPolicy
|
||||
|
||||
private volatile long maxBackOffPeriod = DEFAULT_BACK_OFF_MAX_PERIOD;
|
||||
|
||||
private Random random = new Random(System.currentTimeMillis());
|
||||
private final Random random = new Random(System.currentTimeMillis());
|
||||
|
||||
private Sleeper sleeper = new ThreadWaitSleeper();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,7 @@ package org.springframework.retry.interceptor;
|
||||
*/
|
||||
public class FixedKeyGenerator implements MethodArgumentsKeyGenerator {
|
||||
|
||||
private String label;
|
||||
private final String label;
|
||||
|
||||
public FixedKeyGenerator(String label) {
|
||||
this.label = label;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,7 @@ public class CircuitBreakerRetryPolicy implements RetryPolicy {
|
||||
|
||||
public static final String CIRCUIT_SHORT_COUNT = "circuit.shortCount";
|
||||
|
||||
private static Log logger = LogFactory.getLog(CircuitBreakerRetryPolicy.class);
|
||||
private static final Log logger = LogFactory.getLog(CircuitBreakerRetryPolicy.class);
|
||||
|
||||
private final RetryPolicy delegate;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class MapRetryContextCache implements RetryContextCache {
|
||||
*/
|
||||
public static final int DEFAULT_CAPACITY = 4096;
|
||||
|
||||
private Map<Object, RetryContext> map = Collections.synchronizedMap(new HashMap<>());
|
||||
private final Map<Object, RetryContext> map = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
private int capacity;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class SoftReferenceMapRetryContextCache implements RetryContextCache {
|
||||
*/
|
||||
public static final int DEFAULT_CAPACITY = 4096;
|
||||
|
||||
private Map<Object, SoftReference<RetryContext>> map = Collections.synchronizedMap(new HashMap<>());
|
||||
private final Map<Object, SoftReference<RetryContext>> map = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
private int capacity;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -77,9 +77,9 @@ public class TimeoutRetryPolicy implements RetryPolicy {
|
||||
|
||||
private static class TimeoutRetryContext extends RetryContextSupport {
|
||||
|
||||
private long timeout;
|
||||
private final long timeout;
|
||||
|
||||
private long start;
|
||||
private final long start;
|
||||
|
||||
public TimeoutRetryContext(RetryContext parent, long timeout) {
|
||||
super(parent);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,15 +31,15 @@ public class DefaultRetryStatistics extends AttributeAccessorSupport
|
||||
|
||||
private String name;
|
||||
|
||||
private AtomicInteger startedCount = new AtomicInteger();
|
||||
private final AtomicInteger startedCount = new AtomicInteger();
|
||||
|
||||
private AtomicInteger completeCount = new AtomicInteger();
|
||||
private final AtomicInteger completeCount = new AtomicInteger();
|
||||
|
||||
private AtomicInteger recoveryCount = new AtomicInteger();
|
||||
private final AtomicInteger recoveryCount = new AtomicInteger();
|
||||
|
||||
private AtomicInteger errorCount = new AtomicInteger();
|
||||
private final AtomicInteger errorCount = new AtomicInteger();
|
||||
|
||||
private AtomicInteger abortCount = new AtomicInteger();
|
||||
private final AtomicInteger abortCount = new AtomicInteger();
|
||||
|
||||
DefaultRetryStatistics() {
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.retry.RetryStatistics;
|
||||
*/
|
||||
public class DefaultStatisticsRepository implements StatisticsRepository {
|
||||
|
||||
private ConcurrentMap<String, MutableRetryStatistics> map = new ConcurrentHashMap<>();
|
||||
private final ConcurrentMap<String, MutableRetryStatistics> map = new ConcurrentHashMap<>();
|
||||
|
||||
private RetryStatisticsFactory factory = new DefaultRetryStatisticsFactory();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,8 +34,8 @@ public abstract class AbstractExceptionTests {
|
||||
assertEquals("foo", exception.getMessage().substring(0, 3));
|
||||
}
|
||||
|
||||
public abstract Exception getException(String msg) throws Exception;
|
||||
public abstract Exception getException(String msg);
|
||||
|
||||
public abstract Exception getException(String msg, Throwable t) throws Exception;
|
||||
public abstract Exception getException(String msg, Throwable t);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,19 +30,19 @@ public class AnyThrowTests {
|
||||
public ExpectedException expected = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void testRuntimeException() throws Throwable {
|
||||
public void testRuntimeException() {
|
||||
expected.expect(RuntimeException.class);
|
||||
AnyThrow.throwAny(new RuntimeException("planned"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUncheckedRuntimeException() throws Throwable {
|
||||
public void testUncheckedRuntimeException() {
|
||||
expected.expect(RuntimeException.class);
|
||||
AnyThrow.throwUnchecked(new RuntimeException("planned"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckedException() throws Throwable {
|
||||
public void testCheckedException() {
|
||||
expected.expect(Exception.class);
|
||||
AnyThrow.throwAny(new Exception("planned"));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,15 +20,15 @@ import org.springframework.retry.backoff.BackOffInterruptedException;
|
||||
|
||||
public class BackOffInterruptedExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
public Exception getException(String msg) throws Exception {
|
||||
public Exception getException(String msg) {
|
||||
return new BackOffInterruptedException(msg);
|
||||
}
|
||||
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
public Exception getException(String msg, Throwable t) {
|
||||
return new BackOffInterruptedException(msg, t);
|
||||
}
|
||||
|
||||
public void testNothing() throws Exception {
|
||||
public void testNothing() {
|
||||
// fool coverage tools...
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,15 +20,15 @@ import org.springframework.retry.ExhaustedRetryException;
|
||||
|
||||
public class ExhaustedRetryExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
public Exception getException(String msg) throws Exception {
|
||||
public Exception getException(String msg) {
|
||||
return new ExhaustedRetryException(msg);
|
||||
}
|
||||
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
public Exception getException(String msg, Throwable t) {
|
||||
return new ExhaustedRetryException(msg, t);
|
||||
}
|
||||
|
||||
public void testNothing() throws Exception {
|
||||
public void testNothing() {
|
||||
// fool coverage tools...
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,15 +20,15 @@ import org.springframework.retry.RetryException;
|
||||
|
||||
public class RetryExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
public Exception getException(String msg) throws Exception {
|
||||
public Exception getException(String msg) {
|
||||
return new RetryException(msg);
|
||||
}
|
||||
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
public Exception getException(String msg, Throwable t) {
|
||||
return new RetryException(msg, t);
|
||||
}
|
||||
|
||||
public void testNothing() throws Exception {
|
||||
public void testNothing() {
|
||||
// fool coverage tools...
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,15 +20,15 @@ import org.springframework.retry.TerminatedRetryException;
|
||||
|
||||
public class TerminatedRetryExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
public Exception getException(String msg) throws Exception {
|
||||
public Exception getException(String msg) {
|
||||
return new TerminatedRetryException(msg);
|
||||
}
|
||||
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
public Exception getException(String msg, Throwable t) {
|
||||
return new TerminatedRetryException(msg, t);
|
||||
}
|
||||
|
||||
public void testNothing() throws Exception {
|
||||
public void testNothing() {
|
||||
// fool coverage tools...
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ import org.springframework.retry.support.RetrySynchronizationManager;
|
||||
|
||||
public class CircuitBreakerResetTimeoutTests {
|
||||
|
||||
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
private final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
CircuitBreakerResetTimeoutTests.TestConfiguration.class);
|
||||
|
||||
private TestService serviceInTest = context.getBean(TestService.class);
|
||||
private final TestService serviceInTest = context.getBean(TestService.class);
|
||||
|
||||
@Test
|
||||
public void circuitBreakerShouldBeClosedAfterResetTimeout() throws InterruptedException {
|
||||
|
||||
@@ -133,10 +133,10 @@ public class EnableRetryWithBackoffTests {
|
||||
@SuppressWarnings("serial")
|
||||
protected static class PeriodSleeper implements Sleeper {
|
||||
|
||||
private List<Long> periods = new ArrayList<>();
|
||||
private final List<Long> periods = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void sleep(long period) throws InterruptedException {
|
||||
public void sleep(long period) {
|
||||
periods.add(period);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ import static org.junit.Assert.assertTrue;
|
||||
@RunWith(Parameterized.class)
|
||||
public class BackOffPolicySerializationTests {
|
||||
|
||||
private static Log logger = LogFactory.getLog(BackOffPolicySerializationTests.class);
|
||||
private static final Log logger = LogFactory.getLog(BackOffPolicySerializationTests.class);
|
||||
|
||||
private BackOffPolicy policy;
|
||||
private final BackOffPolicy policy;
|
||||
|
||||
@Parameters(name = "{index}: {0}")
|
||||
public static List<Object[]> policies() {
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.List;
|
||||
@SuppressWarnings("serial")
|
||||
public class DummySleeper implements Sleeper {
|
||||
|
||||
private List<Long> backOffs = new ArrayList<>();
|
||||
private final List<Long> backOffs = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Public getter for the long.
|
||||
|
||||
@@ -27,10 +27,10 @@ import org.junit.Test;
|
||||
*/
|
||||
public class ExponentialBackOffPolicyTests {
|
||||
|
||||
private DummySleeper sleeper = new DummySleeper();
|
||||
private final DummySleeper sleeper = new DummySleeper();
|
||||
|
||||
@Test
|
||||
public void testSetMaxInterval() throws Exception {
|
||||
public void testSetMaxInterval() {
|
||||
ExponentialBackOffPolicy strategy = new ExponentialBackOffPolicy();
|
||||
strategy.setMaxInterval(1000);
|
||||
assertTrue(strategy.toString().contains("maxInterval=1000"));
|
||||
@@ -40,7 +40,7 @@ public class ExponentialBackOffPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetInitialInterval() throws Exception {
|
||||
public void testSetInitialInterval() {
|
||||
ExponentialBackOffPolicy strategy = new ExponentialBackOffPolicy();
|
||||
strategy.setInitialInterval(10000);
|
||||
assertTrue(strategy.toString().contains("initialInterval=10000,"));
|
||||
@@ -49,7 +49,7 @@ public class ExponentialBackOffPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetMultiplier() throws Exception {
|
||||
public void testSetMultiplier() {
|
||||
ExponentialBackOffPolicy strategy = new ExponentialBackOffPolicy();
|
||||
strategy.setMultiplier(3.);
|
||||
assertTrue(strategy.toString().contains("multiplier=3."));
|
||||
@@ -58,7 +58,7 @@ public class ExponentialBackOffPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleBackOff() throws Exception {
|
||||
public void testSingleBackOff() {
|
||||
ExponentialBackOffPolicy strategy = new ExponentialBackOffPolicy();
|
||||
strategy.setSleeper(sleeper);
|
||||
BackOffContext context = strategy.start(null);
|
||||
@@ -67,7 +67,7 @@ public class ExponentialBackOffPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaximumBackOff() throws Exception {
|
||||
public void testMaximumBackOff() {
|
||||
ExponentialBackOffPolicy strategy = new ExponentialBackOffPolicy();
|
||||
strategy.setMaxInterval(50);
|
||||
strategy.setSleeper(sleeper);
|
||||
@@ -77,7 +77,7 @@ public class ExponentialBackOffPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiBackOff() throws Exception {
|
||||
public void testMultiBackOff() {
|
||||
ExponentialBackOffPolicy strategy = new ExponentialBackOffPolicy();
|
||||
long seed = 40;
|
||||
double multiplier = 1.2;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,7 +52,7 @@ public class ExponentialRandomBackOffPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleBackoff() throws Exception {
|
||||
public void testSingleBackoff() {
|
||||
ExponentialBackOffPolicy backOffPolicy = makeBackoffPolicy();
|
||||
RetrySimulator simulator = new RetrySimulator(backOffPolicy, makeRetryPolicy());
|
||||
RetrySimulation simulation = simulator.executeSimulation(1);
|
||||
@@ -70,7 +70,7 @@ public class ExponentialRandomBackOffPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxInterval() throws Exception {
|
||||
public void testMaxInterval() {
|
||||
ExponentialBackOffPolicy backOffPolicy = makeBackoffPolicy();
|
||||
backOffPolicy.setInitialInterval(3000);
|
||||
long maxInterval = backOffPolicy.getMaxInterval();
|
||||
@@ -91,7 +91,7 @@ public class ExponentialRandomBackOffPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiBackOff() throws Exception {
|
||||
public void testMultiBackOff() {
|
||||
ExponentialBackOffPolicy backOffPolicy = makeBackoffPolicy();
|
||||
RetrySimulator simulator = new RetrySimulator(backOffPolicy, makeRetryPolicy());
|
||||
RetrySimulation simulation = simulator.executeSimulation(NUM_TRIALS);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,10 +27,10 @@ import org.junit.Test;
|
||||
*/
|
||||
public class FixedBackOffPolicyTests {
|
||||
|
||||
private DummySleeper sleeper = new DummySleeper();
|
||||
private final DummySleeper sleeper = new DummySleeper();
|
||||
|
||||
@Test
|
||||
public void testSetBackoffPeriodNegative() throws Exception {
|
||||
public void testSetBackoffPeriodNegative() {
|
||||
FixedBackOffPolicy strategy = new FixedBackOffPolicy();
|
||||
strategy.setBackOffPeriod(-1000L);
|
||||
strategy.setSleeper(sleeper);
|
||||
@@ -41,7 +41,7 @@ public class FixedBackOffPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleBackOff() throws Exception {
|
||||
public void testSingleBackOff() {
|
||||
int backOffPeriod = 50;
|
||||
FixedBackOffPolicy strategy = new FixedBackOffPolicy();
|
||||
strategy.setBackOffPeriod(backOffPeriod);
|
||||
@@ -52,7 +52,7 @@ public class FixedBackOffPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManyBackOffCalls() throws Exception {
|
||||
public void testManyBackOffCalls() {
|
||||
int backOffPeriod = 50;
|
||||
FixedBackOffPolicy strategy = new FixedBackOffPolicy();
|
||||
strategy.setBackOffPeriod(backOffPeriod);
|
||||
|
||||
@@ -67,7 +67,7 @@ public class RetryOperationsInterceptorTests {
|
||||
private RetryContext context;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
this.interceptor = new RetryOperationsInterceptor();
|
||||
RetryTemplate retryTemplate = new RetryTemplate();
|
||||
final AtomicBoolean calledFirst = new AtomicBoolean();
|
||||
@@ -183,7 +183,7 @@ public class RetryOperationsInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryExceptionAfterTooManyAttempts() throws Exception {
|
||||
public void testRetryExceptionAfterTooManyAttempts() {
|
||||
((Advised) this.service).addAdvice(this.interceptor);
|
||||
RetryTemplate template = new RetryTemplate();
|
||||
template.setRetryPolicy(new NeverRetryPolicy());
|
||||
@@ -239,7 +239,7 @@ public class RetryOperationsInterceptorTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object proceed() throws Throwable {
|
||||
public Object proceed() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -255,7 +255,7 @@ public class RetryOperationsInterceptorTests {
|
||||
|
||||
void service() throws Exception;
|
||||
|
||||
void doTansactional() throws Exception;
|
||||
void doTansactional();
|
||||
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ public class RetryOperationsInterceptorTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doTansactional() throws Exception {
|
||||
public void doTansactional() {
|
||||
if (TransactionSynchronizationManager.isActualTransactionActive() && !this.enteredTransaction) {
|
||||
transactionCount++;
|
||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
|
||||
|
||||
@@ -71,7 +71,7 @@ public class StatefulRetryOperationsInterceptorTests {
|
||||
private static int count;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
interceptor = new StatefulRetryOperationsInterceptor();
|
||||
retryTemplate.registerListener(new RetryListenerSupport() {
|
||||
@Override
|
||||
@@ -87,7 +87,7 @@ public class StatefulRetryOperationsInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultInterceptorSunnyDay() throws Exception {
|
||||
public void testDefaultInterceptorSunnyDay() {
|
||||
((Advised) service).addAdvice(interceptor);
|
||||
try {
|
||||
service.service("foo");
|
||||
@@ -101,7 +101,7 @@ public class StatefulRetryOperationsInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultInterceptorWithLabel() throws Exception {
|
||||
public void testDefaultInterceptorWithLabel() {
|
||||
interceptor.setLabel("FOO");
|
||||
((Advised) service).addAdvice(interceptor);
|
||||
try {
|
||||
@@ -117,7 +117,7 @@ public class StatefulRetryOperationsInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultTransformerInterceptorSunnyDay() throws Exception {
|
||||
public void testDefaultTransformerInterceptorSunnyDay() {
|
||||
((Advised) transformer).addAdvice(interceptor);
|
||||
try {
|
||||
transformer.transform("foo");
|
||||
@@ -131,7 +131,7 @@ public class StatefulRetryOperationsInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultInterceptorAlwaysRetry() throws Exception {
|
||||
public void testDefaultInterceptorAlwaysRetry() {
|
||||
retryTemplate.setRetryPolicy(new AlwaysRetryPolicy());
|
||||
interceptor.setRetryOperations(retryTemplate);
|
||||
((Advised) service).addAdvice(interceptor);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class RetryListenerTests {
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
@Test
|
||||
public void testOpenInterceptors() throws Throwable {
|
||||
public void testOpenInterceptors() {
|
||||
template.setListeners(new RetryListener[] { new RetryListenerSupport() {
|
||||
public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) {
|
||||
count++;
|
||||
@@ -61,7 +61,7 @@ public class RetryListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenCanVetoRetry() throws Throwable {
|
||||
public void testOpenCanVetoRetry() {
|
||||
template.registerListener(new RetryListenerSupport() {
|
||||
public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) {
|
||||
list.add("1");
|
||||
@@ -84,7 +84,7 @@ public class RetryListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCloseInterceptors() throws Throwable {
|
||||
public void testCloseInterceptors() {
|
||||
template.setListeners(new RetryListener[] { new RetryListenerSupport() {
|
||||
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback,
|
||||
Throwable t) {
|
||||
@@ -106,7 +106,7 @@ public class RetryListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnError() throws Throwable {
|
||||
public void testOnError() {
|
||||
template.setRetryPolicy(new NeverRetryPolicy());
|
||||
template.setListeners(new RetryListener[] { new RetryListenerSupport() {
|
||||
public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback,
|
||||
@@ -138,7 +138,7 @@ public class RetryListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCloseInterceptorsAfterRetry() throws Throwable {
|
||||
public void testCloseInterceptorsAfterRetry() {
|
||||
template.registerListener(new RetryListenerSupport() {
|
||||
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback,
|
||||
Throwable t) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,7 @@ import org.springframework.retry.RetryContext;
|
||||
public class AlwaysRetryPolicyTests {
|
||||
|
||||
@Test
|
||||
public void testSimpleOperations() throws Exception {
|
||||
public void testSimpleOperations() {
|
||||
AlwaysRetryPolicy policy = new AlwaysRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
assertNotNull(context);
|
||||
@@ -40,7 +40,7 @@ public class AlwaysRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryCount() throws Exception {
|
||||
public void testRetryCount() {
|
||||
AlwaysRetryPolicy policy = new AlwaysRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
assertNotNull(context);
|
||||
@@ -52,7 +52,7 @@ public class AlwaysRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParent() throws Exception {
|
||||
public void testParent() {
|
||||
AlwaysRetryPolicy policy = new AlwaysRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
RetryContext child = policy.open(context);
|
||||
|
||||
@@ -71,7 +71,7 @@ public class CircuitBreakerRetryTemplateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircuitOpenWithNoRecovery() throws Throwable {
|
||||
public void testCircuitOpenWithNoRecovery() {
|
||||
this.retryTemplate.setRetryPolicy(new CircuitBreakerRetryPolicy(new NeverRetryPolicy()));
|
||||
this.retryTemplate.setThrowLastExceptionOnExhausted(true);
|
||||
try {
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.retry.RetryPolicy;
|
||||
public class CompositeRetryPolicyTests {
|
||||
|
||||
@Test
|
||||
public void testEmptyPolicies() throws Exception {
|
||||
public void testEmptyPolicies() {
|
||||
CompositeRetryPolicy policy = new CompositeRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
assertNotNull(context);
|
||||
@@ -42,7 +42,7 @@ public class CompositeRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrivialPolicies() throws Exception {
|
||||
public void testTrivialPolicies() {
|
||||
CompositeRetryPolicy policy = new CompositeRetryPolicy();
|
||||
policy.setPolicies(new RetryPolicy[] { new MockRetryPolicySupport(), new MockRetryPolicySupport() });
|
||||
RetryContext context = policy.open(null);
|
||||
@@ -52,7 +52,7 @@ public class CompositeRetryPolicyTests {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
public void testNonTrivialPolicies() throws Exception {
|
||||
public void testNonTrivialPolicies() {
|
||||
CompositeRetryPolicy policy = new CompositeRetryPolicy();
|
||||
policy.setPolicies(new RetryPolicy[] { new MockRetryPolicySupport(), new MockRetryPolicySupport() {
|
||||
public boolean canRetry(RetryContext context) {
|
||||
@@ -66,7 +66,7 @@ public class CompositeRetryPolicyTests {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
public void testNonTrivialPoliciesWithThrowable() throws Exception {
|
||||
public void testNonTrivialPoliciesWithThrowable() {
|
||||
CompositeRetryPolicy policy = new CompositeRetryPolicy();
|
||||
policy.setPolicies(new RetryPolicy[] { new MockRetryPolicySupport(), new MockRetryPolicySupport() {
|
||||
boolean errorRegistered = false;
|
||||
@@ -88,7 +88,7 @@ public class CompositeRetryPolicyTests {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
public void testNonTrivialPoliciesClose() throws Exception {
|
||||
public void testNonTrivialPoliciesClose() {
|
||||
final List<String> list = new ArrayList<>();
|
||||
CompositeRetryPolicy policy = new CompositeRetryPolicy();
|
||||
policy.setPolicies(new RetryPolicy[] { new MockRetryPolicySupport() {
|
||||
@@ -108,7 +108,7 @@ public class CompositeRetryPolicyTests {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
public void testExceptionOnPoliciesClose() throws Exception {
|
||||
public void testExceptionOnPoliciesClose() {
|
||||
final List<String> list = new ArrayList<>();
|
||||
CompositeRetryPolicy policy = new CompositeRetryPolicy();
|
||||
policy.setPolicies(new RetryPolicy[] { new MockRetryPolicySupport() {
|
||||
@@ -134,7 +134,7 @@ public class CompositeRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryCount() throws Exception {
|
||||
public void testRetryCount() {
|
||||
CompositeRetryPolicy policy = new CompositeRetryPolicy();
|
||||
policy.setPolicies(new RetryPolicy[] { new MockRetryPolicySupport(), new MockRetryPolicySupport() });
|
||||
RetryContext context = policy.open(null);
|
||||
@@ -147,7 +147,7 @@ public class CompositeRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParent() throws Exception {
|
||||
public void testParent() {
|
||||
CompositeRetryPolicy policy = new CompositeRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
RetryContext child = policy.open(context);
|
||||
@@ -157,7 +157,7 @@ public class CompositeRetryPolicyTests {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
public void testOptimistic() throws Exception {
|
||||
public void testOptimistic() {
|
||||
CompositeRetryPolicy policy = new CompositeRetryPolicy();
|
||||
policy.setOptimistic(true);
|
||||
policy.setPolicies(new RetryPolicy[] { new MockRetryPolicySupport() {
|
||||
|
||||
@@ -33,16 +33,16 @@ import org.springframework.retry.RetryPolicy;
|
||||
|
||||
public class ExceptionClassifierRetryPolicyTests {
|
||||
|
||||
private ExceptionClassifierRetryPolicy policy = new ExceptionClassifierRetryPolicy();
|
||||
private final ExceptionClassifierRetryPolicy policy = new ExceptionClassifierRetryPolicy();
|
||||
|
||||
@Test
|
||||
public void testDefaultPolicies() throws Exception {
|
||||
public void testDefaultPolicies() {
|
||||
RetryContext context = policy.open(null);
|
||||
assertNotNull(context);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrivialPolicies() throws Exception {
|
||||
public void testTrivialPolicies() {
|
||||
policy.setPolicyMap(Collections.<Class<? extends Throwable>, RetryPolicy>singletonMap(Exception.class,
|
||||
new MockRetryPolicySupport()));
|
||||
RetryContext context = policy.open(null);
|
||||
@@ -51,14 +51,14 @@ public class ExceptionClassifierRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullPolicies() throws Exception {
|
||||
public void testNullPolicies() {
|
||||
policy.setPolicyMap(new HashMap<>());
|
||||
RetryContext context = policy.open(null);
|
||||
assertNotNull(context);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullContext() throws Exception {
|
||||
public void testNullContext() {
|
||||
policy.setPolicyMap(Collections.<Class<? extends Throwable>, RetryPolicy>singletonMap(Exception.class,
|
||||
new NeverRetryPolicy()));
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ExceptionClassifierRetryPolicyTests {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
public void testClassifierOperates() throws Exception {
|
||||
public void testClassifierOperates() {
|
||||
|
||||
RetryContext context = policy.open(null);
|
||||
assertNotNull(context);
|
||||
@@ -104,7 +104,7 @@ public class ExceptionClassifierRetryPolicyTests {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
public void testClose() throws Exception {
|
||||
public void testClose() {
|
||||
policy.setExceptionClassifier(throwable -> new MockRetryPolicySupport() {
|
||||
public void close(RetryContext context) {
|
||||
count++;
|
||||
@@ -124,7 +124,7 @@ public class ExceptionClassifierRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryCount() throws Exception {
|
||||
public void testRetryCount() {
|
||||
ExceptionClassifierRetryPolicy policy = new ExceptionClassifierRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
assertNotNull(context);
|
||||
@@ -136,7 +136,7 @@ public class ExceptionClassifierRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParent() throws Exception {
|
||||
public void testParent() {
|
||||
ExceptionClassifierRetryPolicy policy = new ExceptionClassifierRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
RetryContext child = policy.open(context);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,7 +29,7 @@ import org.springframework.retry.RetryContext;
|
||||
public class NeverRetryPolicyTests {
|
||||
|
||||
@Test
|
||||
public void testSimpleOperations() throws Exception {
|
||||
public void testSimpleOperations() {
|
||||
NeverRetryPolicy policy = new NeverRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
assertNotNull(context);
|
||||
@@ -43,7 +43,7 @@ public class NeverRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryCount() throws Exception {
|
||||
public void testRetryCount() {
|
||||
NeverRetryPolicy policy = new NeverRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
assertNotNull(context);
|
||||
@@ -55,7 +55,7 @@ public class NeverRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParent() throws Exception {
|
||||
public void testParent() {
|
||||
NeverRetryPolicy policy = new NeverRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
RetryContext child = policy.open(context);
|
||||
|
||||
@@ -49,9 +49,9 @@ import static org.junit.Assert.assertTrue;
|
||||
@RunWith(Parameterized.class)
|
||||
public class RetryContextSerializationTests {
|
||||
|
||||
private static Log logger = LogFactory.getLog(RetryContextSerializationTests.class);
|
||||
private static final Log logger = LogFactory.getLog(RetryContextSerializationTests.class);
|
||||
|
||||
private RetryPolicy policy;
|
||||
private final RetryPolicy policy;
|
||||
|
||||
@Parameters(name = "{index}: {0}")
|
||||
public static List<Object[]> policies() {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SerializedMapRetryContextCache implements RetryContextCache {
|
||||
|
||||
private static final int DEFAULT_CAPACITY = 4096;
|
||||
|
||||
private Map<Object, byte[]> map = Collections.synchronizedMap(new HashMap<>());
|
||||
private final Map<Object, byte[]> map = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
|
||||
@@ -34,14 +34,14 @@ import org.springframework.retry.RetryContext;
|
||||
public class SimpleRetryPolicyTests {
|
||||
|
||||
@Test
|
||||
public void testCanRetryIfNoException() throws Exception {
|
||||
public void testCanRetryIfNoException() {
|
||||
SimpleRetryPolicy policy = new SimpleRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
assertTrue(policy.canRetry(context));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyExceptionsNeverRetry() throws Exception {
|
||||
public void testEmptyExceptionsNeverRetry() {
|
||||
|
||||
// We can't retry any exceptions...
|
||||
SimpleRetryPolicy policy = new SimpleRetryPolicy(3,
|
||||
@@ -54,7 +54,7 @@ public class SimpleRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithExceptionDefaultAlwaysRetry() throws Exception {
|
||||
public void testWithExceptionDefaultAlwaysRetry() {
|
||||
|
||||
// We retry any exceptions except...
|
||||
SimpleRetryPolicy policy = new SimpleRetryPolicy(3,
|
||||
@@ -72,7 +72,7 @@ public class SimpleRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryLimitInitialState() throws Exception {
|
||||
public void testRetryLimitInitialState() {
|
||||
SimpleRetryPolicy policy = new SimpleRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
assertTrue(policy.canRetry(context));
|
||||
@@ -82,7 +82,7 @@ public class SimpleRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryLimitSubsequentState() throws Exception {
|
||||
public void testRetryLimitSubsequentState() {
|
||||
SimpleRetryPolicy policy = new SimpleRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
policy.setMaxAttempts(2);
|
||||
@@ -94,7 +94,7 @@ public class SimpleRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryCount() throws Exception {
|
||||
public void testRetryCount() {
|
||||
SimpleRetryPolicy policy = new SimpleRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
assertNotNull(context);
|
||||
@@ -106,7 +106,7 @@ public class SimpleRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFatalOverridesRetryable() throws Exception {
|
||||
public void testFatalOverridesRetryable() {
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<>();
|
||||
map.put(Exception.class, false);
|
||||
map.put(RuntimeException.class, true);
|
||||
@@ -118,7 +118,7 @@ public class SimpleRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryableWithCause() throws Exception {
|
||||
public void testRetryableWithCause() {
|
||||
Map<Class<? extends Throwable>, Boolean> map = new HashMap<>();
|
||||
map.put(RuntimeException.class, true);
|
||||
SimpleRetryPolicy policy = new SimpleRetryPolicy(3, map, true);
|
||||
@@ -129,7 +129,7 @@ public class SimpleRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParent() throws Exception {
|
||||
public void testParent() {
|
||||
SimpleRetryPolicy policy = new SimpleRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
RetryContext child = policy.open(context);
|
||||
|
||||
@@ -152,7 +152,7 @@ public class StatefulRetryIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExponentialBackOffIsExponential() throws Throwable {
|
||||
public void testExponentialBackOffIsExponential() {
|
||||
ExponentialBackOffPolicy policy = new ExponentialBackOffPolicy();
|
||||
policy.setInitialInterval(100);
|
||||
policy.setMultiplier(1.5);
|
||||
@@ -214,7 +214,7 @@ public class StatefulRetryIntegrationTests {
|
||||
|
||||
RetryContext context;
|
||||
|
||||
public String doWithRetry(RetryContext context) throws Exception {
|
||||
public String doWithRetry(RetryContext context) {
|
||||
attempts++;
|
||||
this.context = context;
|
||||
if (attempts < 2) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,7 +41,7 @@ public class TimeoutRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetryCount() throws Exception {
|
||||
public void testRetryCount() {
|
||||
TimeoutRetryPolicy policy = new TimeoutRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
assertNotNull(context);
|
||||
@@ -53,7 +53,7 @@ public class TimeoutRetryPolicyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParent() throws Exception {
|
||||
public void testParent() {
|
||||
TimeoutRetryPolicy policy = new TimeoutRetryPolicy();
|
||||
RetryContext context = policy.open(null);
|
||||
RetryContext child = policy.open(context);
|
||||
|
||||
@@ -54,9 +54,9 @@ public class CircuitBreakerStatisticsTests {
|
||||
|
||||
private DefaultRetryState state;
|
||||
|
||||
private StatisticsRepository repository = new DefaultStatisticsRepository();
|
||||
private final StatisticsRepository repository = new DefaultStatisticsRepository();
|
||||
|
||||
private StatisticsListener listener = new StatisticsListener(repository);
|
||||
private final StatisticsListener listener = new StatisticsListener(repository);
|
||||
|
||||
private RetryContextCache cache;
|
||||
|
||||
@@ -110,7 +110,7 @@ public class CircuitBreakerStatisticsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircuitOpenWithNoRecovery() throws Throwable {
|
||||
public void testCircuitOpenWithNoRecovery() {
|
||||
this.retryTemplate.setRetryPolicy(new CircuitBreakerRetryPolicy(new NeverRetryPolicy()));
|
||||
this.retryTemplate.setThrowLastExceptionOnExhausted(true);
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,17 +31,17 @@ import org.springframework.test.util.ReflectionTestUtils;
|
||||
*/
|
||||
public class ExponentialAverageRetryStatisticsTests {
|
||||
|
||||
private ExponentialAverageRetryStatistics stats = new ExponentialAverageRetryStatistics("test");
|
||||
private final ExponentialAverageRetryStatistics stats = new ExponentialAverageRetryStatistics("test");
|
||||
|
||||
@Test
|
||||
public void pointless() throws Exception {
|
||||
public void pointless() {
|
||||
stats.setName("spam");
|
||||
assertEquals("spam", stats.getName());
|
||||
assertNotNull(stats.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void attributes() throws Exception {
|
||||
public void attributes() {
|
||||
stats.setAttribute("foo", "bar");
|
||||
;
|
||||
assertEquals("bar", stats.getAttribute("foo"));
|
||||
@@ -49,7 +49,7 @@ public class ExponentialAverageRetryStatisticsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void abortCount() throws Exception {
|
||||
public void abortCount() {
|
||||
stats.incrementAbortCount();
|
||||
assertEquals(1, stats.getAbortCount());
|
||||
// rounds up to 1
|
||||
@@ -57,7 +57,7 @@ public class ExponentialAverageRetryStatisticsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void errorCount() throws Exception {
|
||||
public void errorCount() {
|
||||
stats.incrementErrorCount();
|
||||
assertEquals(1, stats.getErrorCount());
|
||||
// rounds up to 1
|
||||
@@ -65,7 +65,7 @@ public class ExponentialAverageRetryStatisticsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startedCount() throws Exception {
|
||||
public void startedCount() {
|
||||
stats.incrementStartedCount();
|
||||
assertEquals(1, stats.getStartedCount());
|
||||
// rounds up to 1
|
||||
@@ -73,7 +73,7 @@ public class ExponentialAverageRetryStatisticsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void completeCount() throws Exception {
|
||||
public void completeCount() {
|
||||
stats.incrementCompleteCount();
|
||||
assertEquals(1, stats.getCompleteCount());
|
||||
// rounds up to 1
|
||||
@@ -81,7 +81,7 @@ public class ExponentialAverageRetryStatisticsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void recoveryCount() throws Exception {
|
||||
public void recoveryCount() {
|
||||
stats.incrementRecoveryCount();
|
||||
assertEquals(1, stats.getRecoveryCount());
|
||||
// rounds up to 1
|
||||
@@ -89,7 +89,7 @@ public class ExponentialAverageRetryStatisticsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oldValuesDecay() throws Exception {
|
||||
public void oldValuesDecay() {
|
||||
stats.incrementAbortCount();
|
||||
assertEquals(1, stats.getAbortCount());
|
||||
// Wind back time to epoch 0
|
||||
|
||||
@@ -36,9 +36,9 @@ import org.springframework.retry.support.RetryTemplate;
|
||||
*/
|
||||
public class StatisticsListenerTests {
|
||||
|
||||
private StatisticsRepository repository = new DefaultStatisticsRepository();
|
||||
private final StatisticsRepository repository = new DefaultStatisticsRepository();
|
||||
|
||||
private StatisticsListener listener = new StatisticsListener(repository);
|
||||
private final StatisticsListener listener = new StatisticsListener(repository);
|
||||
|
||||
@Test
|
||||
public void testStatelessSuccessful() throws Throwable {
|
||||
@@ -60,7 +60,7 @@ public class StatisticsListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatefulSuccessful() throws Throwable {
|
||||
public void testStatefulSuccessful() {
|
||||
RetryTemplate retryTemplate = new RetryTemplate();
|
||||
retryTemplate.setListeners(new RetryListenerSupport[] { listener });
|
||||
RetryState state = new DefaultRetryState("foo");
|
||||
@@ -87,7 +87,7 @@ public class StatisticsListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatelessUnsuccessful() throws Throwable {
|
||||
public void testStatelessUnsuccessful() {
|
||||
RetryTemplate retryTemplate = new RetryTemplate();
|
||||
retryTemplate.setListeners(new RetryListenerSupport[] { listener });
|
||||
for (int x = 1; x <= 10; x++) {
|
||||
@@ -110,7 +110,7 @@ public class StatisticsListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatefulUnsuccessful() throws Throwable {
|
||||
public void testStatefulUnsuccessful() {
|
||||
RetryTemplate retryTemplate = new RetryTemplate();
|
||||
retryTemplate.setListeners(new RetryListenerSupport[] { listener });
|
||||
RetryState state = new DefaultRetryState("foo");
|
||||
@@ -156,7 +156,7 @@ public class StatisticsListenerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatefulRecovery() throws Throwable {
|
||||
public void testStatefulRecovery() {
|
||||
RetryTemplate retryTemplate = new RetryTemplate();
|
||||
retryTemplate.setListeners(new RetryListenerSupport[] { listener });
|
||||
RetryState state = new DefaultRetryState("foo");
|
||||
@@ -188,7 +188,7 @@ public class StatisticsListenerTests {
|
||||
|
||||
private int attemptsBeforeSuccess;
|
||||
|
||||
private Exception exceptionToThrow = new Exception();
|
||||
private final Exception exceptionToThrow = new Exception();
|
||||
|
||||
@Override
|
||||
public Object doWithRetry(RetryContext status) throws Exception {
|
||||
|
||||
@@ -36,14 +36,14 @@ public class RetrySynchronizationManagerTests {
|
||||
RetryTemplate template = new RetryTemplate();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
RetrySynchronizationManagerTests.clearAll();
|
||||
RetryContext status = RetrySynchronizationManager.getContext();
|
||||
assertNull(status);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatusIsStoredByTemplate() throws Throwable {
|
||||
public void testStatusIsStoredByTemplate() {
|
||||
|
||||
RetryContext status = RetrySynchronizationManager.getContext();
|
||||
assertNull(status);
|
||||
@@ -60,7 +60,7 @@ public class RetrySynchronizationManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStatusRegistration() throws Exception {
|
||||
public void testStatusRegistration() {
|
||||
RetryContext status = new RetryContextSupport(null);
|
||||
RetryContext value = RetrySynchronizationManager.register(status);
|
||||
assertNull(value);
|
||||
@@ -69,7 +69,7 @@ public class RetrySynchronizationManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClear() throws Exception {
|
||||
public void testClear() {
|
||||
RetryContext status = new RetryContextSupport(null);
|
||||
RetryContext value = RetrySynchronizationManager.register(status);
|
||||
assertNull(value);
|
||||
@@ -79,7 +79,7 @@ public class RetrySynchronizationManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParent() throws Exception {
|
||||
public void testParent() {
|
||||
RetryContext parent = new RetryContextSupport(null);
|
||||
RetryContext child = new RetryContextSupport(parent);
|
||||
assertSame(parent, child.getParent());
|
||||
|
||||
@@ -67,7 +67,7 @@ public class RetryTemplateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpecificExceptionRetry() throws Throwable {
|
||||
public void testSpecificExceptionRetry() {
|
||||
for (int x = 1; x <= 10; x++) {
|
||||
final int attemptsBeforeSuccess = x;
|
||||
final AtomicInteger attempts = new AtomicInteger(0);
|
||||
@@ -200,7 +200,7 @@ public class RetryTemplateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEarlyTermination() throws Throwable {
|
||||
public void testEarlyTermination() {
|
||||
try {
|
||||
RetryTemplate retryTemplate = new RetryTemplate();
|
||||
retryTemplate.execute(status -> {
|
||||
@@ -217,7 +217,7 @@ public class RetryTemplateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEarlyTerminationWithOriginalException() throws Throwable {
|
||||
public void testEarlyTerminationWithOriginalException() {
|
||||
try {
|
||||
RetryTemplate retryTemplate = new RetryTemplate();
|
||||
retryTemplate.setThrowLastExceptionOnExhausted(true);
|
||||
@@ -256,7 +256,7 @@ public class RetryTemplateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRethrowError() throws Throwable {
|
||||
public void testRethrowError() {
|
||||
RetryTemplate retryTemplate = new RetryTemplate();
|
||||
retryTemplate.setRetryPolicy(new NeverRetryPolicy());
|
||||
try {
|
||||
@@ -272,7 +272,7 @@ public class RetryTemplateTests {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Test
|
||||
public void testFailedPolicy() throws Throwable {
|
||||
public void testFailedPolicy() {
|
||||
RetryTemplate retryTemplate = new RetryTemplate();
|
||||
retryTemplate.setRetryPolicy(new NeverRetryPolicy() {
|
||||
@Override
|
||||
@@ -292,7 +292,7 @@ public class RetryTemplateTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackOffInterrupted() throws Throwable {
|
||||
public void testBackOffInterrupted() {
|
||||
RetryTemplate retryTemplate = new RetryTemplate();
|
||||
retryTemplate.setBackOffPolicy(new StatelessBackOffPolicy() {
|
||||
@Override
|
||||
@@ -313,10 +313,9 @@ public class RetryTemplateTests {
|
||||
|
||||
/**
|
||||
* {@link BackOffPolicy} should apply also for exceptions that are re-thrown.
|
||||
* @throws Throwable on error
|
||||
*/
|
||||
@Test
|
||||
public void testNoBackOffForRethrownException() throws Throwable {
|
||||
public void testNoBackOffForRethrownException() {
|
||||
|
||||
RetryTemplate tested = new RetryTemplate();
|
||||
tested.setRetryPolicy(new SimpleRetryPolicy(1));
|
||||
|
||||
@@ -43,14 +43,14 @@ import static org.junit.Assert.fail;
|
||||
|
||||
public class StatefulRecoveryRetryTests {
|
||||
|
||||
private RetryTemplate retryTemplate = new RetryTemplate();
|
||||
private final RetryTemplate retryTemplate = new RetryTemplate();
|
||||
|
||||
private int count = 0;
|
||||
|
||||
private List<String> list = new ArrayList<>();
|
||||
private final List<String> list = new ArrayList<>();
|
||||
|
||||
@Test
|
||||
public void testOpenSunnyDay() throws Exception {
|
||||
public void testOpenSunnyDay() {
|
||||
RetryContext context = this.retryTemplate.open(new NeverRetryPolicy(), new DefaultRetryState("foo"));
|
||||
assertNotNull(context);
|
||||
// we haven't called the processor yet...
|
||||
@@ -68,7 +68,7 @@ public class StatefulRecoveryRetryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClose() throws Exception {
|
||||
public void testClose() {
|
||||
NeverRetryPolicy retryPolicy = new NeverRetryPolicy();
|
||||
RetryState state = new DefaultRetryState("foo");
|
||||
RetryContext context = this.retryTemplate.open(retryPolicy, state);
|
||||
|
||||
Reference in New Issue
Block a user