diff --git a/src/main/java/org/springframework/classify/BinaryExceptionClassifierBuilder.java b/src/main/java/org/springframework/classify/BinaryExceptionClassifierBuilder.java index 949c13a..8cc1de5 100644 --- a/src/main/java/org/springframework/classify/BinaryExceptionClassifierBuilder.java +++ b/src/main/java/org/springframework/classify/BinaryExceptionClassifierBuilder.java @@ -52,7 +52,7 @@ public class BinaryExceptionClassifierBuilder { private boolean traverseCauses = false; - private List> exceptionClasses = new ArrayList<>(); + private final List> exceptionClasses = new ArrayList<>(); public BinaryExceptionClassifierBuilder retryOn(Class throwable) { Assert.isTrue(isWhiteList == null || isWhiteList, "Please use only retryOn() or only notRetryOn()"); diff --git a/src/main/java/org/springframework/classify/util/AnnotationMethodResolver.java b/src/main/java/org/springframework/classify/util/AnnotationMethodResolver.java index b4b3bf1..6993bd4 100644 --- a/src/main/java/org/springframework/classify/util/AnnotationMethodResolver.java +++ b/src/main/java/org/springframework/classify/util/AnnotationMethodResolver.java @@ -36,7 +36,7 @@ import org.springframework.util.ReflectionUtils; */ public class AnnotationMethodResolver implements MethodResolver { - private Class annotationType; + private final Class annotationType; /** * Create a MethodResolver for the specified Method-level annotation type diff --git a/src/main/java/org/springframework/retry/annotation/RetryConfiguration.java b/src/main/java/org/springframework/retry/annotation/RetryConfiguration.java index b6a5239..dac3cb5 100644 --- a/src/main/java/org/springframework/retry/annotation/RetryConfiguration.java +++ b/src/main/java/org/springframework/retry/annotation/RetryConfiguration.java @@ -242,7 +242,7 @@ public class RetryConfiguration extends AbstractPointcutAdvisor private static class AnnotationMethodsResolver { - private Class annotationType; + private final Class annotationType; public AnnotationMethodsResolver(Class annotationType) { this.annotationType = annotationType; diff --git a/src/main/java/org/springframework/retry/backoff/ExponentialBackOffPolicy.java b/src/main/java/org/springframework/retry/backoff/ExponentialBackOffPolicy.java index 3baa4ac..5523b5b 100644 --- a/src/main/java/org/springframework/retry/backoff/ExponentialBackOffPolicy.java +++ b/src/main/java/org/springframework/retry/backoff/ExponentialBackOffPolicy.java @@ -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 map = Collections.synchronizedMap(new HashMap<>()); + private final Map map = Collections.synchronizedMap(new HashMap<>()); private int capacity; diff --git a/src/main/java/org/springframework/retry/policy/SoftReferenceMapRetryContextCache.java b/src/main/java/org/springframework/retry/policy/SoftReferenceMapRetryContextCache.java index 7128490..e6b0409 100644 --- a/src/main/java/org/springframework/retry/policy/SoftReferenceMapRetryContextCache.java +++ b/src/main/java/org/springframework/retry/policy/SoftReferenceMapRetryContextCache.java @@ -39,7 +39,7 @@ public class SoftReferenceMapRetryContextCache implements RetryContextCache { */ public static final int DEFAULT_CAPACITY = 4096; - private Map> map = Collections.synchronizedMap(new HashMap<>()); + private final Map> map = Collections.synchronizedMap(new HashMap<>()); private int capacity; diff --git a/src/main/java/org/springframework/retry/policy/TimeoutRetryPolicy.java b/src/main/java/org/springframework/retry/policy/TimeoutRetryPolicy.java index fb1a546..a6a7b82 100644 --- a/src/main/java/org/springframework/retry/policy/TimeoutRetryPolicy.java +++ b/src/main/java/org/springframework/retry/policy/TimeoutRetryPolicy.java @@ -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); diff --git a/src/main/java/org/springframework/retry/stats/DefaultRetryStatistics.java b/src/main/java/org/springframework/retry/stats/DefaultRetryStatistics.java index 4e013e1..e554819 100644 --- a/src/main/java/org/springframework/retry/stats/DefaultRetryStatistics.java +++ b/src/main/java/org/springframework/retry/stats/DefaultRetryStatistics.java @@ -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() { } diff --git a/src/main/java/org/springframework/retry/stats/DefaultStatisticsRepository.java b/src/main/java/org/springframework/retry/stats/DefaultStatisticsRepository.java index 0d52509..0cea8b7 100644 --- a/src/main/java/org/springframework/retry/stats/DefaultStatisticsRepository.java +++ b/src/main/java/org/springframework/retry/stats/DefaultStatisticsRepository.java @@ -28,7 +28,7 @@ import org.springframework.retry.RetryStatistics; */ public class DefaultStatisticsRepository implements StatisticsRepository { - private ConcurrentMap map = new ConcurrentHashMap<>(); + private final ConcurrentMap map = new ConcurrentHashMap<>(); private RetryStatisticsFactory factory = new DefaultRetryStatisticsFactory(); diff --git a/src/test/java/org/springframework/retry/AbstractExceptionTests.java b/src/test/java/org/springframework/retry/AbstractExceptionTests.java index 2e3d220..f721d68 100644 --- a/src/test/java/org/springframework/retry/AbstractExceptionTests.java +++ b/src/test/java/org/springframework/retry/AbstractExceptionTests.java @@ -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); } diff --git a/src/test/java/org/springframework/retry/AnyThrowTests.java b/src/test/java/org/springframework/retry/AnyThrowTests.java index 6f28612..af3e7b8 100644 --- a/src/test/java/org/springframework/retry/AnyThrowTests.java +++ b/src/test/java/org/springframework/retry/AnyThrowTests.java @@ -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")); } diff --git a/src/test/java/org/springframework/retry/BackOffInterruptedExceptionTests.java b/src/test/java/org/springframework/retry/BackOffInterruptedExceptionTests.java index 51a9c7a..63d7e9e 100644 --- a/src/test/java/org/springframework/retry/BackOffInterruptedExceptionTests.java +++ b/src/test/java/org/springframework/retry/BackOffInterruptedExceptionTests.java @@ -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... } diff --git a/src/test/java/org/springframework/retry/ExhaustedRetryExceptionTests.java b/src/test/java/org/springframework/retry/ExhaustedRetryExceptionTests.java index e8bede7..f2e420a 100644 --- a/src/test/java/org/springframework/retry/ExhaustedRetryExceptionTests.java +++ b/src/test/java/org/springframework/retry/ExhaustedRetryExceptionTests.java @@ -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... } diff --git a/src/test/java/org/springframework/retry/RetryExceptionTests.java b/src/test/java/org/springframework/retry/RetryExceptionTests.java index 5dc2a7d..95aab72 100644 --- a/src/test/java/org/springframework/retry/RetryExceptionTests.java +++ b/src/test/java/org/springframework/retry/RetryExceptionTests.java @@ -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... } diff --git a/src/test/java/org/springframework/retry/TerminatedRetryExceptionTests.java b/src/test/java/org/springframework/retry/TerminatedRetryExceptionTests.java index da75a5a..e15037b 100644 --- a/src/test/java/org/springframework/retry/TerminatedRetryExceptionTests.java +++ b/src/test/java/org/springframework/retry/TerminatedRetryExceptionTests.java @@ -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... } diff --git a/src/test/java/org/springframework/retry/annotation/CircuitBreakerResetTimeoutTests.java b/src/test/java/org/springframework/retry/annotation/CircuitBreakerResetTimeoutTests.java index 405565d..37d8cba 100644 --- a/src/test/java/org/springframework/retry/annotation/CircuitBreakerResetTimeoutTests.java +++ b/src/test/java/org/springframework/retry/annotation/CircuitBreakerResetTimeoutTests.java @@ -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 { diff --git a/src/test/java/org/springframework/retry/annotation/EnableRetryWithBackoffTests.java b/src/test/java/org/springframework/retry/annotation/EnableRetryWithBackoffTests.java index b2ba832..88e8164 100644 --- a/src/test/java/org/springframework/retry/annotation/EnableRetryWithBackoffTests.java +++ b/src/test/java/org/springframework/retry/annotation/EnableRetryWithBackoffTests.java @@ -133,10 +133,10 @@ public class EnableRetryWithBackoffTests { @SuppressWarnings("serial") protected static class PeriodSleeper implements Sleeper { - private List periods = new ArrayList<>(); + private final List periods = new ArrayList<>(); @Override - public void sleep(long period) throws InterruptedException { + public void sleep(long period) { periods.add(period); } diff --git a/src/test/java/org/springframework/retry/backoff/BackOffPolicySerializationTests.java b/src/test/java/org/springframework/retry/backoff/BackOffPolicySerializationTests.java index be88e74..c2d7560 100644 --- a/src/test/java/org/springframework/retry/backoff/BackOffPolicySerializationTests.java +++ b/src/test/java/org/springframework/retry/backoff/BackOffPolicySerializationTests.java @@ -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 policies() { diff --git a/src/test/java/org/springframework/retry/backoff/DummySleeper.java b/src/test/java/org/springframework/retry/backoff/DummySleeper.java index 0fd7baf..a9850f9 100644 --- a/src/test/java/org/springframework/retry/backoff/DummySleeper.java +++ b/src/test/java/org/springframework/retry/backoff/DummySleeper.java @@ -28,7 +28,7 @@ import java.util.List; @SuppressWarnings("serial") public class DummySleeper implements Sleeper { - private List backOffs = new ArrayList<>(); + private final List backOffs = new ArrayList<>(); /** * Public getter for the long. diff --git a/src/test/java/org/springframework/retry/backoff/ExponentialBackOffPolicyTests.java b/src/test/java/org/springframework/retry/backoff/ExponentialBackOffPolicyTests.java index 7267c52..dca7ac8 100644 --- a/src/test/java/org/springframework/retry/backoff/ExponentialBackOffPolicyTests.java +++ b/src/test/java/org/springframework/retry/backoff/ExponentialBackOffPolicyTests.java @@ -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; diff --git a/src/test/java/org/springframework/retry/backoff/ExponentialRandomBackOffPolicyTests.java b/src/test/java/org/springframework/retry/backoff/ExponentialRandomBackOffPolicyTests.java index 61e3f09..1218c45 100644 --- a/src/test/java/org/springframework/retry/backoff/ExponentialRandomBackOffPolicyTests.java +++ b/src/test/java/org/springframework/retry/backoff/ExponentialRandomBackOffPolicyTests.java @@ -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); diff --git a/src/test/java/org/springframework/retry/backoff/FixedBackOffPolicyTests.java b/src/test/java/org/springframework/retry/backoff/FixedBackOffPolicyTests.java index 8a372fe..87b9cb2 100644 --- a/src/test/java/org/springframework/retry/backoff/FixedBackOffPolicyTests.java +++ b/src/test/java/org/springframework/retry/backoff/FixedBackOffPolicyTests.java @@ -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); diff --git a/src/test/java/org/springframework/retry/interceptor/RetryOperationsInterceptorTests.java b/src/test/java/org/springframework/retry/interceptor/RetryOperationsInterceptorTests.java index 62d6e32..474592f 100644 --- a/src/test/java/org/springframework/retry/interceptor/RetryOperationsInterceptorTests.java +++ b/src/test/java/org/springframework/retry/interceptor/RetryOperationsInterceptorTests.java @@ -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() { diff --git a/src/test/java/org/springframework/retry/interceptor/StatefulRetryOperationsInterceptorTests.java b/src/test/java/org/springframework/retry/interceptor/StatefulRetryOperationsInterceptorTests.java index 177c9e6..91a002a 100644 --- a/src/test/java/org/springframework/retry/interceptor/StatefulRetryOperationsInterceptorTests.java +++ b/src/test/java/org/springframework/retry/interceptor/StatefulRetryOperationsInterceptorTests.java @@ -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); diff --git a/src/test/java/org/springframework/retry/listener/RetryListenerTests.java b/src/test/java/org/springframework/retry/listener/RetryListenerTests.java index ce3ce8a..09bd174 100644 --- a/src/test/java/org/springframework/retry/listener/RetryListenerTests.java +++ b/src/test/java/org/springframework/retry/listener/RetryListenerTests.java @@ -40,7 +40,7 @@ public class RetryListenerTests { List list = new ArrayList<>(); @Test - public void testOpenInterceptors() throws Throwable { + public void testOpenInterceptors() { template.setListeners(new RetryListener[] { new RetryListenerSupport() { public boolean open(RetryContext context, RetryCallback callback) { count++; @@ -61,7 +61,7 @@ public class RetryListenerTests { } @Test - public void testOpenCanVetoRetry() throws Throwable { + public void testOpenCanVetoRetry() { template.registerListener(new RetryListenerSupport() { public boolean open(RetryContext context, RetryCallback 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 void close(RetryContext context, RetryCallback 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 void onError(RetryContext context, RetryCallback callback, @@ -138,7 +138,7 @@ public class RetryListenerTests { } @Test - public void testCloseInterceptorsAfterRetry() throws Throwable { + public void testCloseInterceptorsAfterRetry() { template.registerListener(new RetryListenerSupport() { public void close(RetryContext context, RetryCallback callback, Throwable t) { diff --git a/src/test/java/org/springframework/retry/policy/AlwaysRetryPolicyTests.java b/src/test/java/org/springframework/retry/policy/AlwaysRetryPolicyTests.java index ca959f6..e9f3255 100644 --- a/src/test/java/org/springframework/retry/policy/AlwaysRetryPolicyTests.java +++ b/src/test/java/org/springframework/retry/policy/AlwaysRetryPolicyTests.java @@ -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); diff --git a/src/test/java/org/springframework/retry/policy/CircuitBreakerRetryTemplateTests.java b/src/test/java/org/springframework/retry/policy/CircuitBreakerRetryTemplateTests.java index 5c199ee..4aac8ae 100644 --- a/src/test/java/org/springframework/retry/policy/CircuitBreakerRetryTemplateTests.java +++ b/src/test/java/org/springframework/retry/policy/CircuitBreakerRetryTemplateTests.java @@ -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 { diff --git a/src/test/java/org/springframework/retry/policy/CompositeRetryPolicyTests.java b/src/test/java/org/springframework/retry/policy/CompositeRetryPolicyTests.java index 99d73dd..ec894d8 100644 --- a/src/test/java/org/springframework/retry/policy/CompositeRetryPolicyTests.java +++ b/src/test/java/org/springframework/retry/policy/CompositeRetryPolicyTests.java @@ -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 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 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() { diff --git a/src/test/java/org/springframework/retry/policy/ExceptionClassifierRetryPolicyTests.java b/src/test/java/org/springframework/retry/policy/ExceptionClassifierRetryPolicyTests.java index 6846fab..ce70edc 100644 --- a/src/test/java/org/springframework/retry/policy/ExceptionClassifierRetryPolicyTests.java +++ b/src/test/java/org/springframework/retry/policy/ExceptionClassifierRetryPolicyTests.java @@ -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., 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., 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); diff --git a/src/test/java/org/springframework/retry/policy/NeverRetryPolicyTests.java b/src/test/java/org/springframework/retry/policy/NeverRetryPolicyTests.java index 4d0e35a..d5c1590 100644 --- a/src/test/java/org/springframework/retry/policy/NeverRetryPolicyTests.java +++ b/src/test/java/org/springframework/retry/policy/NeverRetryPolicyTests.java @@ -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); diff --git a/src/test/java/org/springframework/retry/policy/RetryContextSerializationTests.java b/src/test/java/org/springframework/retry/policy/RetryContextSerializationTests.java index 02a694c..a5aa255 100644 --- a/src/test/java/org/springframework/retry/policy/RetryContextSerializationTests.java +++ b/src/test/java/org/springframework/retry/policy/RetryContextSerializationTests.java @@ -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 policies() { diff --git a/src/test/java/org/springframework/retry/policy/SerializedMapRetryContextCache.java b/src/test/java/org/springframework/retry/policy/SerializedMapRetryContextCache.java index e516ed8..0252acb 100644 --- a/src/test/java/org/springframework/retry/policy/SerializedMapRetryContextCache.java +++ b/src/test/java/org/springframework/retry/policy/SerializedMapRetryContextCache.java @@ -26,7 +26,7 @@ public class SerializedMapRetryContextCache implements RetryContextCache { private static final int DEFAULT_CAPACITY = 4096; - private Map map = Collections.synchronizedMap(new HashMap<>()); + private final Map map = Collections.synchronizedMap(new HashMap<>()); @Override public boolean containsKey(Object key) { diff --git a/src/test/java/org/springframework/retry/policy/SimpleRetryPolicyTests.java b/src/test/java/org/springframework/retry/policy/SimpleRetryPolicyTests.java index ee03fdc..e59b4de 100644 --- a/src/test/java/org/springframework/retry/policy/SimpleRetryPolicyTests.java +++ b/src/test/java/org/springframework/retry/policy/SimpleRetryPolicyTests.java @@ -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, 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, 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); diff --git a/src/test/java/org/springframework/retry/policy/StatefulRetryIntegrationTests.java b/src/test/java/org/springframework/retry/policy/StatefulRetryIntegrationTests.java index 9494bea..e17fe9f 100644 --- a/src/test/java/org/springframework/retry/policy/StatefulRetryIntegrationTests.java +++ b/src/test/java/org/springframework/retry/policy/StatefulRetryIntegrationTests.java @@ -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) { diff --git a/src/test/java/org/springframework/retry/policy/TimeoutRetryPolicyTests.java b/src/test/java/org/springframework/retry/policy/TimeoutRetryPolicyTests.java index 1ac9856..81a4505 100644 --- a/src/test/java/org/springframework/retry/policy/TimeoutRetryPolicyTests.java +++ b/src/test/java/org/springframework/retry/policy/TimeoutRetryPolicyTests.java @@ -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); diff --git a/src/test/java/org/springframework/retry/stats/CircuitBreakerStatisticsTests.java b/src/test/java/org/springframework/retry/stats/CircuitBreakerStatisticsTests.java index a5639d8..1e82410 100644 --- a/src/test/java/org/springframework/retry/stats/CircuitBreakerStatisticsTests.java +++ b/src/test/java/org/springframework/retry/stats/CircuitBreakerStatisticsTests.java @@ -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 { diff --git a/src/test/java/org/springframework/retry/stats/ExponentialAverageRetryStatisticsTests.java b/src/test/java/org/springframework/retry/stats/ExponentialAverageRetryStatisticsTests.java index e2641d2..ab311af 100644 --- a/src/test/java/org/springframework/retry/stats/ExponentialAverageRetryStatisticsTests.java +++ b/src/test/java/org/springframework/retry/stats/ExponentialAverageRetryStatisticsTests.java @@ -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 diff --git a/src/test/java/org/springframework/retry/stats/StatisticsListenerTests.java b/src/test/java/org/springframework/retry/stats/StatisticsListenerTests.java index 80ebef0..2670d68 100644 --- a/src/test/java/org/springframework/retry/stats/StatisticsListenerTests.java +++ b/src/test/java/org/springframework/retry/stats/StatisticsListenerTests.java @@ -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 { diff --git a/src/test/java/org/springframework/retry/support/RetrySynchronizationManagerTests.java b/src/test/java/org/springframework/retry/support/RetrySynchronizationManagerTests.java index 85e13cf..1071205 100644 --- a/src/test/java/org/springframework/retry/support/RetrySynchronizationManagerTests.java +++ b/src/test/java/org/springframework/retry/support/RetrySynchronizationManagerTests.java @@ -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()); diff --git a/src/test/java/org/springframework/retry/support/RetryTemplateTests.java b/src/test/java/org/springframework/retry/support/RetryTemplateTests.java index edea4b9..f77b1a8 100644 --- a/src/test/java/org/springframework/retry/support/RetryTemplateTests.java +++ b/src/test/java/org/springframework/retry/support/RetryTemplateTests.java @@ -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)); diff --git a/src/test/java/org/springframework/retry/support/StatefulRecoveryRetryTests.java b/src/test/java/org/springframework/retry/support/StatefulRecoveryRetryTests.java index 7d9e6b9..1ac47a3 100644 --- a/src/test/java/org/springframework/retry/support/StatefulRecoveryRetryTests.java +++ b/src/test/java/org/springframework/retry/support/StatefulRecoveryRetryTests.java @@ -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 list = new ArrayList<>(); + private final List 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);