Skip to content

Commit 1fed5a7

Browse files
committed
Fix Sonar issues in deprecated RepeatProcessor
1 parent 868979d commit 1fed5a7

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

spring-rabbit-junit/src/main/java/org/springframework/amqp/rabbit/junit/RepeatProcessor.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.junit.Before;
3535
import org.junit.internal.runners.statements.RunAfters;
3636
import org.junit.internal.runners.statements.RunBefores;
37-
import org.junit.jupiter.api.RepeatedTest;
3837
import org.junit.rules.MethodRule;
3938
import org.junit.runners.model.FrameworkMethod;
4039
import org.junit.runners.model.Statement;
@@ -47,15 +46,15 @@
4746
* A JUnit method @Rule that looks at Spring repeat annotations on methods and executes the test multiple times
4847
* (without re-initializing the test case if necessary). To avoid re-initializing use the {@link #isInitialized()}
4948
* method to protect the @Before and @After methods.
50-
* @deprecated in favor of JUnit 5 {@link RepeatedTest}.
49+
* @deprecated in favor of JUnit 5 {@link org.junit.jupiter.api.RepeatedTest}.
5150
*
5251
* @author Dave Syer
5352
*
5453
*/
5554
@Deprecated
5655
public class RepeatProcessor implements MethodRule {
5756

58-
private static final Log logger = LogFactory.getLog(RepeatProcessor.class);
57+
private static final Log LOGGER = LogFactory.getLog(RepeatProcessor.class);
5958

6059
private final int concurrency;
6160

@@ -95,7 +94,7 @@ public void evaluate() throws Throwable {
9594
try {
9695
base.evaluate();
9796
}
98-
catch (Throwable t) {
97+
catch (Throwable t) { // NOSONAR
9998
throw new IllegalStateException(
10099
"Failed on iteration: " + i + " of " + repeats + " (started at 0)", t);
101100
}
@@ -107,7 +106,7 @@ public void evaluate() throws Throwable {
107106
}
108107
};
109108
}
110-
return new Statement() {
109+
return new Statement() { // NOSONAR
111110
@Override
112111
public void evaluate() throws Throwable {
113112
List<Future<Boolean>> results = new ArrayList<Future<Boolean>>();
@@ -122,7 +121,7 @@ public Boolean call() {
122121
try {
123122
base.evaluate();
124123
}
125-
catch (Throwable t) {
124+
catch (Throwable t) { // NOSONAR
126125
throw new IllegalStateException("Failed on iteration: " + count, t);
127126
}
128127
return true;
@@ -147,15 +146,15 @@ private void finalizeIfNecessary(Object target) {
147146
List<FrameworkMethod> afters = new TestClass(target.getClass()).getAnnotatedMethods(After.class);
148147
try {
149148
if (!afters.isEmpty()) {
150-
logger.debug("Running @After methods");
149+
LOGGER.debug("Running @After methods");
151150
try {
152151
new RunAfters(new Statement() {
153152
@Override
154153
public void evaluate() {
155154
}
156155
}, afters, target).evaluate();
157156
}
158-
catch (Throwable e) {
157+
catch (Throwable e) { // NOSONAR
159158
fail("Unexpected throwable " + e);
160159
}
161160
}
@@ -169,15 +168,15 @@ private void initializeIfNecessary(Object target) {
169168
TestClass testClass = new TestClass(target.getClass());
170169
List<FrameworkMethod> befores = testClass.getAnnotatedMethods(Before.class);
171170
if (!befores.isEmpty()) {
172-
logger.debug("Running @Before methods");
171+
LOGGER.debug("Running @Before methods");
173172
try {
174173
new RunBefores(new Statement() {
175174
@Override
176175
public void evaluate() {
177176
}
178177
}, befores, target).evaluate();
179178
}
180-
catch (Throwable e) {
179+
catch (Throwable e) { // NOSONAR
181180
fail("Unexpected throwable " + e);
182181
}
183182
this.initialized = true;

0 commit comments

Comments
 (0)