From 24e1148fea9ba0ec085f9986ab902a43f2ed85e3 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Fri, 27 Dec 2019 12:25:29 -0500 Subject: [PATCH] Fix Sonar issues --- .../kafka/test/rule/EmbeddedKafkaRule.java | 3 +- .../DefaultAfterRollbackProcessor.java | 22 ++++++------- .../listener/SeekToCurrentErrorHandler.java | 31 +++++++++---------- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/spring-kafka-test/src/main/java/org/springframework/kafka/test/rule/EmbeddedKafkaRule.java b/spring-kafka-test/src/main/java/org/springframework/kafka/test/rule/EmbeddedKafkaRule.java index f5918cde..55c27662 100644 --- a/spring-kafka-test/src/main/java/org/springframework/kafka/test/rule/EmbeddedKafkaRule.java +++ b/spring-kafka-test/src/main/java/org/springframework/kafka/test/rule/EmbeddedKafkaRule.java @@ -19,12 +19,11 @@ package org.springframework.kafka.test.rule; import java.util.Map; import org.junit.rules.ExternalResource; -import org.junit.rules.TestRule; import org.springframework.kafka.test.EmbeddedKafkaBroker; /** - * A {@link TestRule} wrapper around an {@link EmbeddedKafkaBroker}. + * A {@link org.junit.rules.TestRule} wrapper around an {@link EmbeddedKafkaBroker}. * * @author Artem Bilan * diff --git a/spring-kafka/src/main/java/org/springframework/kafka/listener/DefaultAfterRollbackProcessor.java b/spring-kafka/src/main/java/org/springframework/kafka/listener/DefaultAfterRollbackProcessor.java index 7b787d9b..731fa596 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/listener/DefaultAfterRollbackProcessor.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/listener/DefaultAfterRollbackProcessor.java @@ -29,7 +29,6 @@ import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.support.SeekUtils; import org.springframework.lang.Nullable; import org.springframework.util.backoff.BackOff; -import org.springframework.util.backoff.FixedBackOff; /** * Default implementation of {@link AfterRollbackProcessor}. Seeks all @@ -66,11 +65,12 @@ public class DefaultAfterRollbackProcessor extends FailedRecordProcessor i * 'maxFailures' have occurred for a topic/partition/offset. * @param maxFailures the maxFailures; a negative value is treated as infinity. * @deprecated in favor of {@link #DefaultAfterRollbackProcessor(BackOff)}. - * IMPORTANT When using a {@link FixedBackOff}, the maxAttempts property - * represents retries (one less than maxFailures). To retry indefinitely, use a - * fixed or exponential {@link BackOff} configured appropriately. - * To use the other constructor with the semantics of this one, with maxFailures - * equal to 3, use {@code new DefaultAfterRollbackProcessor(new FixedBackOff(0L, 2L)}. + * IMPORTANT When using a + * {@link org.springframework.util.backoff.FixedBackOff}, the maxAttempts property + * represents retries (one less than maxFailures). To retry indefinitely, use a fixed + * or exponential {@link BackOff} configured appropriately. To use the other + * constructor with the semantics of this one, with maxFailures equal to 3, use + * {@code new DefaultAfterRollbackProcessor(new FixedBackOff(0L, 2L)}. * @since 2.2.1 */ @Deprecated @@ -105,11 +105,11 @@ public class DefaultAfterRollbackProcessor extends FailedRecordProcessor i * @param recoverer the recoverer; if null, the default (logging) recoverer is used. * @param maxFailures the maxFailures; a negative value is treated as infinity. * @deprecated in favor of {@link #DefaultAfterRollbackProcessor(BackOff)}. - * IMPORTANT When using a {@link FixedBackOff}, the maxAttempts property - * represents retries (one less than maxFailures). To retry indefinitely, use a - * fixed or exponential {@link BackOff} configured appropriately. - * To use the other constructor with the semantics of this one, with maxFailures - * equal to 3, use + * IMPORTANT When using a + * {@link org.springframework.util.backoff.FixedBackOff}, the maxAttempts property + * represents retries (one less than maxFailures). To retry indefinitely, use a fixed + * or exponential {@link BackOff} configured appropriately. To use the other + * constructor with the semantics of this one, with maxFailures equal to 3, use * {@code new DefaultAfterRollbackProcessor(recoverer, new FixedBackOff(0L, 2L)}. * @since 2.2 */ diff --git a/spring-kafka/src/main/java/org/springframework/kafka/listener/SeekToCurrentErrorHandler.java b/spring-kafka/src/main/java/org/springframework/kafka/listener/SeekToCurrentErrorHandler.java index 06866759..6de9a9a5 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/listener/SeekToCurrentErrorHandler.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/listener/SeekToCurrentErrorHandler.java @@ -32,14 +32,10 @@ import org.springframework.classify.BinaryExceptionClassifier; import org.springframework.kafka.KafkaException; import org.springframework.kafka.listener.ContainerProperties.AckMode; import org.springframework.kafka.support.SeekUtils; -import org.springframework.kafka.support.serializer.DeserializationException; import org.springframework.lang.Nullable; -import org.springframework.messaging.converter.MessageConversionException; -import org.springframework.messaging.handler.invocation.MethodArgumentResolutionException; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; import org.springframework.util.backoff.BackOff; -import org.springframework.util.backoff.FixedBackOff; /** * An error handler that seeks to the current offset for each topic in the remaining @@ -73,11 +69,12 @@ public class SeekToCurrentErrorHandler extends FailedRecordProcessor implements * 'maxFailures' have occurred for a topic/partition/offset. * @param maxFailures the maxFailures; a negative value is treated as infinity. * @deprecated in favor of {@link #SeekToCurrentErrorHandler(BackOff)}. - * IMPORTANT When using a {@link FixedBackOff}, the maxAttempts property - * represents retries (one less than maxFailures). To retry indefinitely, use a - * fixed or exponential {@link BackOff} configured appropriately. - * To use the other constructor with the semantics of this one, with maxFailures - * equal to 3, use {@code new SeekToCurrentErrorHandler(new FixedBackOff(0L, 2L)}. + * IMPORTANT When using a + * {@link org.springframework.util.backoff.FixedBackOff}, the maxAttempts property + * represents retries (one less than maxFailures). To retry indefinitely, use a fixed + * or exponential {@link BackOff} configured appropriately. To use the other + * constructor with the semantics of this one, with maxFailures equal to 3, use + * {@code new SeekToCurrentErrorHandler(new FixedBackOff(0L, 2L)}. * @since 2.2.1 */ @Deprecated @@ -112,11 +109,11 @@ public class SeekToCurrentErrorHandler extends FailedRecordProcessor implements * @param recoverer the recoverer; if null, the default (logging) recoverer is used. * @param maxFailures the maxFailures; a negative value is treated as infinity. * @deprecated in favor of {@link #SeekToCurrentErrorHandler(BiConsumer, BackOff)}. - * IMPORTANT When using a {@link FixedBackOff}, the maxAttempts property - * represents retries (one less than maxFailures). To retry indefinitely, use a - * fixed or exponential {@link BackOff} configured appropriately. - * To use the other constructor with the semantics of this one, with maxFailures - * equal to 3, use + * IMPORTANT When using a + * {@link org.springframework.util.backoff.FixedBackOff}, the maxAttempts property + * represents retries (one less than maxFailures). To retry indefinitely, use a fixed + * or exponential {@link BackOff} configured appropriately. To use the other + * constructor with the semantics of this one, with maxFailures equal to 3, use * {@code new SeekToCurrentErrorHandler(recoverer, new FixedBackOff(0L, 2L)}. * @since 2.2 */ @@ -155,9 +152,9 @@ public class SeekToCurrentErrorHandler extends FailedRecordProcessor implements * (until exhaustion) or not. If not, we go straight to the recoverer. By default, * the following exceptions will not be retried: *
    - *
  • {@link DeserializationException}
  • - *
  • {@link MessageConversionException}
  • - *
  • {@link MethodArgumentResolutionException}
  • + *
  • {@link org.springframework.kafka.support.serializer.DeserializationException}
  • + *
  • {@link org.springframework.messaging.converter.MessageConversionException}
  • + *
  • {@link org.springframework.messaging.handler.invocation.MethodArgumentResolutionException}
  • *
  • {@link NoSuchMethodException}
  • *
  • {@link ClassCastException}
  • *