Add checkstyle rule on empty-line-separater

* Update checkstyle.xml
* Fix checkstyle violations
* Fix test class checkstyle
* Add field also.
This commit is contained in:
Kim, Joo Hyuk
2024-03-26 00:11:06 +09:00
committed by GitHub
parent cb45e560e8
commit e2daa2da8c
75 changed files with 161 additions and 105 deletions

View File

@@ -204,7 +204,6 @@ public class EmbeddedKafkaKraftBroker implements EmbeddedKafkaBroker {
}
}
private void start() {
if (this.cluster != null) {
return;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2024 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.
@@ -90,7 +90,6 @@ public final class KafkaConditions {
return new ConsumerRecordPartitionCondition(partition);
}
public static class ConsumerRecordKeyCondition<K> extends Condition<ConsumerRecord<K, ?>> {
private final K key;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019-2023 the original author or authors.
* Copyright 2019-2024 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.
@@ -211,7 +211,6 @@ public class EmbeddedKafkaCondition implements ExecutionCondition, AfterAllCallb
return parent.getStore(Namespace.create(getClass(), parent));
}
public static EmbeddedKafkaBroker getBroker() {
return BROKERS.get();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2023 the original author or authors.
* Copyright 2017-2024 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.
@@ -48,7 +48,6 @@ public class EmbeddedKafkaContextCustomizerTests {
AnnotationUtils.findAnnotation(SecondTestWithEmbeddedKafka.class, EmbeddedKafka.class);
}
@Test
void testHashCode() {
assertThat(new EmbeddedKafkaContextCustomizer(annotationFromFirstClass).hashCode()).isNotEqualTo(0);
@@ -56,7 +55,6 @@ public class EmbeddedKafkaContextCustomizerTests {
.isEqualTo(new EmbeddedKafkaContextCustomizer(annotationFromSecondClass).hashCode());
}
@Test
void testEquals() {
assertThat(new EmbeddedKafkaContextCustomizer(annotationFromFirstClass))
@@ -93,7 +91,6 @@ public class EmbeddedKafkaContextCustomizerTests {
.matches("127.0.0.1:[0-9]+,127.0.0.1:[0-9]+");
}
@EmbeddedKafka(kraft = false)
private static final class TestWithEmbeddedKafka {

View File

@@ -1190,7 +1190,6 @@ public class KafkaListenerAnnotationBeanPostProcessor<K, V>
private record BytesToStringConverter(Charset charset) implements Converter<byte[], String> {
@Override
public String convert(byte[] source) {
return new String(source, this.charset);

View File

@@ -37,7 +37,6 @@ import org.springframework.core.log.LogAccessor;
import org.springframework.kafka.retrytopic.RetryTopicConfiguration;
import org.springframework.lang.Nullable;
/**
*
* Attempts to provide an instance of

View File

@@ -361,7 +361,6 @@ public class KafkaListenerEndpointRegistry implements ListenerContainerRegistry,
return listenerContainer;
}
@Override
public void destroy() {
for (MessageListenerContainer listenerContainer : getListenerContainers()) {
@@ -419,7 +418,6 @@ public class KafkaListenerEndpointRegistry implements ListenerContainerRegistry,
return this.running;
}
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if (event.getApplicationContext().equals(this.applicationContext)) {
@@ -439,7 +437,6 @@ public class KafkaListenerEndpointRegistry implements ListenerContainerRegistry,
}
}
private static final class AggregatingCallback implements Runnable {
private final AtomicInteger count;

View File

@@ -61,7 +61,6 @@ public class MultiMethodKafkaListenerEndpoint<K, V> extends MethodKafkaListenerE
setBean(bean);
}
/**
* Get a method list.
* @return the method list.

View File

@@ -252,7 +252,6 @@ public class DefaultKafkaConsumerFactory<K, V> extends KafkaResourceFactory
this.valueDeserializerSupplier = valueDeserializerSupplier(valueDeserializerSupplier);
}
/**
* Set to false (default true) to prevent programmatically provided deserializers (via
* constructor or setters) from being configured using the producer configuration,

View File

@@ -68,8 +68,6 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* The {@link ProducerFactory} implementation for a {@code singleton} shared {@link Producer} instance.
* <p>
@@ -567,7 +565,6 @@ public class DefaultKafkaProducerFactory<K, V> extends KafkaResourceFactory
return newFactory;
}
/**
* Ensures that the returned properties map contains a transaction id prefix.
* The {@link org.springframework.kafka.core.DefaultKafkaProducerFactory}

View File

@@ -308,7 +308,6 @@ public class KafkaTemplate<K, V> implements KafkaOperations<K, V>, ApplicationCo
((MessagingMessageConverter) this.messageConverter).setMessagingConverter(messageConverter);
}
@Override
public boolean isTransactional() {
return this.transactional;
@@ -590,7 +589,6 @@ public class KafkaTemplate<K, V> implements KafkaOperations<K, V>, ApplicationCo
return observeSend((ProducerRecord<K, V>) producerRecord);
}
@Override
public List<PartitionInfo> partitionsFor(String topic) {
Producer<K, V> producer = getTheProducer();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020-2022 the original author or authors.
* Copyright 2020-2024 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.
@@ -65,7 +65,6 @@ public class MicrometerProducerListener<K, V> implements ProducerFactory.Listene
this.tags = tags;
}
@Override
public synchronized void producerAdded(String id, Producer<K, V> producer) {
if (!this.metrics.containsKey(id)) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2023 the original author or authors.
* Copyright 2015-2024 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.
@@ -19,7 +19,6 @@ package org.springframework.kafka.event;
import org.springframework.context.ApplicationEvent;
import org.springframework.util.Assert;
/**
* Base class for events.
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 the original author or authors.
* Copyright 2015-2024 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.
@@ -40,7 +40,6 @@ import org.springframework.lang.Nullable;
@FunctionalInterface
public interface BatchMessageListener<K, V> extends GenericMessageListener<List<ConsumerRecord<K, V>>> {
/**
* Listener receives the original {@link ConsumerRecords} object instead of a
* list of {@link ConsumerRecord}.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 the original author or authors.
* Copyright 2021-2024 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.
@@ -83,7 +83,6 @@ public class CommonContainerStoppingErrorHandler extends KafkaExceptionLogLevelA
stopContainer(container, thrownException);
}
@Override
public void handleRemaining(Exception thrownException, List<ConsumerRecord<?, ?>> records, Consumer<?, ?> consumer,
MessageListenerContainer container) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 the original author or authors.
* Copyright 2021-2024 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,6 @@ public class CommonLoggingErrorHandler implements CommonErrorHandler {
this.ackAfterHandle = ackAfterHandle;
}
@Override
public boolean handleOne(Exception thrownException, ConsumerRecord<?, ?> record, Consumer<?, ?> consumer,
MessageListenerContainer container) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2023 the original author or authors.
* Copyright 2017-2024 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,7 +34,6 @@ import org.apache.kafka.common.TopicPartition;
*/
public interface ConsumerAwareRebalanceListener extends ConsumerRebalanceListener {
/**
* The same as {@link #onPartitionsRevoked(Collection)} with the additional consumer
* parameter. It is invoked by the container before any pending offsets are committed.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2021 the original author or authors.
* Copyright 2021-2024 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.
@@ -32,7 +32,6 @@ import org.springframework.lang.Nullable;
@FunctionalInterface
public interface ConsumerAwareRecordRecoverer extends ConsumerRecordRecoverer {
@Override
default void accept(ConsumerRecord<?, ?> record, Exception exception) {
accept(record, null, exception);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2023 the original author or authors.
* Copyright 2018-2024 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.
@@ -1364,6 +1364,7 @@ public class DeadLetterPublishingRecoverer extends ExceptionClassifier implement
this.exceptionCauseFqcn = exceptionCauseFqcn;
return this;
}
/**
* Sets the name of the header that will be used to store the keyExceptionMessage
* of the original record.

View File

@@ -137,7 +137,6 @@ import org.springframework.util.StringUtils;
import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationRegistry;
/**
* Single-threaded Message listener container using the Java {@link Consumer} supporting
* auto-partition assignment or user-configured assignment.
@@ -593,7 +592,6 @@ public class KafkaMessageListenerContainer<K, V> // NOSONAR line count
+ "]";
}
private final class ListenerConsumer implements SchedulingAwareRunnable, ConsumerSeekCallback {
private static final String COMMITTING = "Committing: ";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 the original author or authors.
* Copyright 2016-2024 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.
@@ -35,7 +35,6 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.util.Assert;
/**
* A {@link org.springframework.kafka.listener.MessageListener MessageListener}
* adapter that invokes a configurable {@link HandlerAdapter}; used when the factory is

View File

@@ -47,7 +47,6 @@ import org.springframework.messaging.handler.invocation.InvocableHandlerMethod;
import org.springframework.util.Assert;
import org.springframework.validation.Validator;
/**
* Delegates to an {@link InvocableHandlerMethod} based on the message payload type.
* Matches a single, non-annotated parameter or one that is annotated with

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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,6 @@ import org.springframework.kafka.support.converter.ProjectingMessageConverter;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
/**
* A {@link org.springframework.kafka.listener.MessageListener MessageListener}
* adapter that invokes a configurable {@link HandlerAdapter}; used when the factory is

View File

@@ -39,7 +39,6 @@ import org.springframework.kafka.retrytopic.DestinationTopic.Type;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
*
* Default implementation of the {@link DestinationTopicResolver} interface.

View File

@@ -148,6 +148,7 @@ public class DestinationTopic {
@Nullable
private final Boolean autoStartDltHandler;
/**
* Create an instance with the provided properties with the DLT container starting
* automatically (if the container factory is so configured).

View File

@@ -91,7 +91,9 @@ public class RetryTopicConfiguration {
static class TopicCreation {
private final boolean shouldCreateTopics;
private final int numPartitions;
private final short replicationFactor;
TopicCreation(@Nullable Boolean shouldCreate, @Nullable Integer numPartitions, @Nullable Short replicationFactor) {

View File

@@ -72,7 +72,6 @@ public class RetryTopicConfigurationBuilder {
private RetryTopicConfiguration.TopicCreation topicCreationConfiguration = new RetryTopicConfiguration.TopicCreation();
private ConcurrentKafkaListenerContainerFactory<?, ?> listenerContainerFactory;
@Nullable
@@ -401,7 +400,6 @@ public class RetryTopicConfigurationBuilder {
return this;
}
/**
* Configure a {@link FixedBackOffPolicy}.
* @param interval the interval.

View File

@@ -43,7 +43,6 @@ import org.springframework.kafka.support.TopicForRetryable;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
/**
*
* <p>Configures main, retry and DLT topics based on a main endpoint and provided

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020-2022 the original author or authors.
* Copyright 2020-2024 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.
@@ -64,7 +64,6 @@ public class KafkaStreamsMicrometerListener implements StreamsBuilderFactoryBean
this.tags = tags;
}
@Override
public synchronized void streamsAdded(String id, KafkaStreams kafkaStreams) {
if (!this.metrics.containsKey(id)) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 the original author or authors.
* Copyright 2018-2024 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.
@@ -271,7 +271,6 @@ public abstract class AbstractKafkaHeaderMapper implements KafkaHeaderMapper {
return null;
}
/**
* A matcher for headers.
* @since 2.3

View File

@@ -439,7 +439,6 @@ public class DefaultKafkaHeaderMapper extends AbstractKafkaHeaderMapper {
this.untrustedType = untrustedType;
}
public void setHeaderValue(byte[] headerValue) { // NOSONAR
this.headerValue = headerValue; // NOSONAR array reference
}

View File

@@ -63,7 +63,6 @@ public final class KafkaUtils {
*/
public static final String VALUE_DESERIALIZER_EXCEPTION_HEADER = DESERIALIZER_EXCEPTION_HEADER_PREFIX + "Value";
private static Function<ProducerRecord<?, ?>, String> prFormatter = ProducerRecord::toString;
private static Function<ConsumerRecord<?, ?>, String> crFormatter =

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2021 the original author or authors.
* Copyright 2018-2024 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,6 @@ import java.util.stream.Collectors;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* Utility class that suffixes strings.
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2022 the original author or authors.
* Copyright 2016-2024 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.
@@ -238,7 +238,6 @@ public class BatchMessagingMessageConverter implements BatchMessageConverter {
return record.value() == null ? KafkaNull.INSTANCE : record.value();
}
/**
* Convert the record value.
* @param record the record.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 the original author or authors.
* Copyright 2016-2024 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.
@@ -136,7 +136,6 @@ public class MessagingMessageConverter implements RecordMessageConverter {
this.rawRecordHeader = rawRecordHeader;
}
protected org.springframework.messaging.converter.MessageConverter getMessagingConverter() {
return this.messagingConverter;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2022 the original author or authors.
* Copyright 2022-2024 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,6 @@ public enum KafkaListenerObservation implements ObservationDocumentation {
*/
LISTENER_OBSERVATION {
@Override
public Class<? extends ObservationConvention<? extends Context>> getDefaultConvention() {
return DefaultKafkaListenerObservationConvention.class;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 the original author or authors.
* Copyright 2019-2024 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.
@@ -187,7 +187,6 @@ public class DelegatingSerializer implements Serializer<Object> {
throw new UnsupportedOperationException();
}
@Override
public byte[] serialize(String topic, Headers headers, Object data) {
if (data == null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2023 the original author or authors.
* Copyright 2015-2024 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.
@@ -178,7 +178,6 @@ public class JsonDeserializer<T> implements Deserializer<T> {
this(targetType, true);
}
/**
* Construct an instance with the provided target type, and a default {@link ObjectMapper}.
* @param targetType the target java type to use if no type info headers are present.

View File

@@ -241,7 +241,6 @@ public final class SerializationUtils {
return super.resolveClass(desc);
}
};
return (DeserializationException) ois.readObject();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 the original author or authors.
* Copyright 2016-2024 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.
@@ -43,7 +43,6 @@ public class ToStringSerializer<T> implements Serializer<T> {
*/
public static final String ADD_TYPE_INFO_HEADERS = "spring.message.add.type.headers";
/**
* Header for the type of key.
*/

View File

@@ -1440,6 +1440,7 @@ public class EnableKafkaIntegrationTests {
public SeekToOffsetFromComputeFunction seekToOffsetFromComputeFunction() {
return new SeekToOffsetFromComputeFunction();
}
@Bean
public IfaceListener<String> ifaceListener() {
return new IfaceListenerImpl();
@@ -2351,6 +2352,7 @@ public class EnableKafkaIntegrationTests {
public static class SeekToOffsetFromComputeFunction extends AbstractConsumerSeekAware {
CountDownLatch latch1 = new CountDownLatch(10);
CountDownLatch latch2 = new CountDownLatch(1);
@KafkaListener(id = "seekToComputeFn", topics = "seekToComputeFn")
@@ -2651,7 +2653,6 @@ public class EnableKafkaIntegrationTests {
private String bar;
public Foo() {
}

View File

@@ -71,7 +71,6 @@ public class KafkaListenerEndpointRegistryTests {
.withMessage("'idMatcher' cannot be null");
}
@DisplayName("getListenerContainersMatching with BiPredicate throws on null biPredicate")
@Test
void getListenerContainersMatchingBiPredicateThrowsOnNullBiPredicate() {

View File

@@ -119,7 +119,6 @@ public class DefaultKafkaConsumerFactoryTests {
DefaultKafkaConsumerFactory<String, String> target =
new DefaultKafkaConsumerFactory<String, String>(originalConfig) {
@Override
protected Consumer<String, String> createRawConsumer(Map<String, Object> configProps) {
configPassedToKafkaConsumer.putAll(configProps);

View File

@@ -706,7 +706,6 @@ public class DefaultKafkaProducerFactoryTests {
assertThat(configPassedToKafkaConsumer.get(ProducerConfig.TRANSACTIONAL_ID_CONFIG)).isEqualTo("tx.1");
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
void configUpdates() {

View File

@@ -50,7 +50,6 @@ class DefaultTransactionIdSuffixStrategyTests {
assertThat(suffix).isNotNull();
}
@Test
void acquireSuffixWithCacheExhausted() {
String txIdPrefix = "txIdPrefix";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 the original author or authors.
* Copyright 2016-2024 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.
@@ -132,7 +132,6 @@ public class KafkaTemplateTests {
private static final ProducerPostProcessor<String, String> noopProducerPostProcessor = processor -> processor;
@BeforeAll
public static void setUp() {
embeddedKafka = EmbeddedKafkaCondition.getBroker();
@@ -349,6 +348,7 @@ public class KafkaTemplateTests {
}
}
PL pl1 = new PL();
PL pl2 = new PL();
CompositeProducerListener<Integer, String> cpl = new CompositeProducerListener<>(new PL[]{ pl1, pl2 });
@@ -638,5 +638,4 @@ public class KafkaTemplateTests {
.withMessage("Offset supplied in TopicPartitionOffset is invalid: " + tpoWithNullOffset);
}
}

View File

@@ -1413,7 +1413,6 @@ public class ConcurrentMessageListenerContainerMockTests {
this.latch.countDown();
}
@Override
public void onIdleContainer(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback) {
if (latch.getCount() > 0) {

View File

@@ -652,7 +652,6 @@ public class ConcurrentMessageListenerContainerTests {
}
@Test
public void testAckOnErrorRecord() throws Exception {
logger.info("Start ack on error");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 the original author or authors.
* Copyright 2021-2024 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.
@@ -46,7 +46,6 @@ public class ConsumerAwareRebalanceListenerTests {
assertThat(called.get()).isTrue();
}
@Test
void nonConsumerAwareTestRevoked() {
AtomicBoolean called = new AtomicBoolean();
@@ -61,7 +60,6 @@ public class ConsumerAwareRebalanceListenerTests {
assertThat(called.get()).isTrue();
}
@Test
void nonConsumerAwareTestLost() {
AtomicBoolean called = new AtomicBoolean();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020-2023 the original author or authors.
* Copyright 2020-2024 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.
@@ -46,6 +46,7 @@ public class ConsumerSeekAwareTests {
void beginningEndAndBulkSeekToTimestamp() throws Exception {
class CSA extends AbstractConsumerSeekAware {
}
AbstractConsumerSeekAware csa = new CSA();
var exec1 = Executors.newSingleThreadExecutor();
var exec2 = Executors.newSingleThreadExecutor();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2021 the original author or authors.
* Copyright 2021-2024 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.
@@ -100,7 +100,6 @@ public class ContainerGroupSequencerTests {
final List<Long> receivedAt = Collections.synchronizedList(new ArrayList<>());
@KafkaListener(id = "one", topics = "ContainerGroupSequencerTests", containerGroup = "g1", concurrency = "2")
public void listen1(String in) {
LOGGER.debug(in);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2023 the original author or authors.
* Copyright 2018-2024 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.
@@ -130,6 +130,7 @@ public class ErrorHandlingDeserializerTests {
}
}
ErrorHandlingDeserializer<String> ehd = new ErrorHandlingDeserializer<>(new MyDes());
Headers headers = new RecordHeaders();
ehd.deserialize("foo", headers, new byte[1]);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2023 the original author or authors.
* Copyright 2017-2024 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.
@@ -53,15 +53,24 @@ import org.springframework.util.backoff.FixedBackOff;
class ErrorHandlingUtilsTest {
private final Exception thrownException = new RuntimeException("initial cause");
private final Consumer<?, ?> consumer = mock(Consumer.class);
private final MessageListenerContainer container = mock(MessageListenerContainer.class);
private final Runnable listener = mock(Runnable.class);
private final BackOff backOff = new FixedBackOff(1000, 3);
private final CommonErrorHandler seeker = mock(CommonErrorHandler.class);
@SuppressWarnings("unchecked")
private final BiConsumer<ConsumerRecords<?, ?>, Exception> recoverer = mock(BiConsumer.class);
private final LogAccessor logger = new LogAccessor(LogFactory.getLog(ErrorHandlingUtilsTest.class));
private final List<RetryListener> retryListeners = new ArrayList<>();
private final BinaryExceptionClassifier classifier = BinaryExceptionClassifier.defaultClassifier();
private final ConsumerRecords<?, ?> consumerRecords = recordsOf(

View File

@@ -1448,7 +1448,6 @@ public class KafkaMessageListenerContainerTests {
throw new IllegalStateException();
}
});
final CountDownLatch commitLatch = new CountDownLatch(1);
@@ -1520,6 +1519,7 @@ public class KafkaMessageListenerContainerTests {
}
}
Listener messageListener = new Listener();
containerProps.setMessageListener(messageListener);
containerProps.setSyncCommits(true);
@@ -1599,6 +1599,7 @@ public class KafkaMessageListenerContainerTests {
}
}
Listener messageListener = new Listener();
containerProps.setMessageListener(messageListener);
containerProps.setSyncCommits(true);
@@ -2607,6 +2608,7 @@ public class KafkaMessageListenerContainerTests {
}
}
Listener messageListener = new Listener();
containerProps.setMessageListener(messageListener);
containerProps.setMissingTopicsFatal(false);
@@ -2935,6 +2937,7 @@ public class KafkaMessageListenerContainerTests {
}
}
containerProps.setMessageListener(new Listener());
containerProps.setMissingTopicsFatal(false);
KafkaMessageListenerContainer<Integer, String> container =

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2022 the original author or authors.
* Copyright 2017-2024 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,6 +77,7 @@ public class ManualNackPauseResumeTests {
@SuppressWarnings("rawtypes")
@Autowired
private Consumer consumer;
@Autowired
private Config config;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2022 the original author or authors.
* Copyright 2017-2024 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,6 +77,7 @@ public class ManualNackRecordTests {
@SuppressWarnings("rawtypes")
@Autowired
private Consumer consumer;
@Autowired
private Config config;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2022 the original author or authors.
* Copyright 2022-2024 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.
@@ -76,6 +76,7 @@ public class ManualNackRecordZeroSleepTests {
@SuppressWarnings("rawtypes")
@Autowired
private Consumer consumer;
@Autowired
private Config config;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2023-2023 the original author or authors.
* Copyright 2023-2024 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.
@@ -153,7 +153,6 @@ public class PauseContainerWhileErrorHandlerIsRetryingTests {
}
}
@KafkaListener(id = "id", groupId = "grp", topics = "foo")
public void process(List<String> batch, Acknowledgment acknowledgment) {
batch.forEach((msg) -> {

View File

@@ -1086,7 +1086,6 @@ public class TransactionalContainerTests {
assertThatIllegalStateException().isThrownBy(container::start);
}
@Test
void testArbpWithoutRecovery() throws InterruptedException {
// init producer

View File

@@ -62,6 +62,7 @@ public class MessagingMessageListenerAdapterTests {
}
}
MyAdapter adapter = new MyAdapter();
adapter.setFallbackType(String.class);
RecordMessageConverter converter = mock(RecordMessageConverter.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2023 the original author or authors.
* Copyright 2018-2024 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.
@@ -303,7 +303,9 @@ public class DestinationTopicTests {
}
class PropsHolder {
final String topicName;
final DestinationTopic.Properties props;
PropsHolder(String topicName, DestinationTopic.Properties props) {

View File

@@ -203,13 +203,17 @@ class ExistingRetryTopicClassLevelIntegrationTests {
static class CountDownLatchContainer {
CountDownLatch countDownLatch1 = new CountDownLatch(12);
CountDownLatch countDownLatch2 = new CountDownLatch(12);
}
static class CountByPartitionContainer {
Map<String, Integer> mainTopicMessageCountByPartition = new HashMap<>();
Map<String, Integer> retryTopicMessageCountByPartition = new HashMap<>();
}
@Configuration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2021-2023 the original author or authors.
* Copyright 2021-2024 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.
@@ -200,13 +200,17 @@ public class ExistingRetryTopicIntegrationTests {
static class CountDownLatchContainer {
CountDownLatch countDownLatch1 = new CountDownLatch(40);
CountDownLatch countDownLatch2 = new CountDownLatch(40);
}
static class CountByPartitionContainer {
Map<String, Integer> mainTopicMessageCountByPartition = new HashMap<>();
Map<String, Integer> retryTopicMessageCountByPartition = new HashMap<>();
}
@Configuration

View File

@@ -139,7 +139,6 @@ class ListenerContainerFactoryConfigurerTests {
@Mock
private KafkaListenerEndpoint endpoint;
@Test
void shouldSetupErrorHandling() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 the original author or authors.
* Copyright 2018-2024 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.
@@ -56,7 +56,9 @@ class ListenerContainerFactoryResolverTests {
private ConcurrentKafkaListenerContainerFactory<?, ?> factoryFromDefaultBeanName;
private final static String factoryName = "testListenerContainerFactory";
private final static String otherFactoryName = "otherTestListenerContainerFactory";
private final static String defaultFactoryBeanName = "defaultTestListenerContainerFactory";
@Test

View File

@@ -75,9 +75,13 @@ import org.springframework.util.backoff.FixedBackOff;
class RetryTopicClassLevelExceptionRoutingIntegrationTests {
final static String BLOCKING_AND_TOPIC_RETRY = "blocking-and-topic-retry";
final static String ONLY_RETRY_VIA_BLOCKING = "only-retry-blocking-topic";
final static String ONLY_RETRY_VIA_TOPIC = "only-retry-topic";
final static String USER_FATAL_EXCEPTION_TOPIC = "user-fatal-topic";
final static String FRAMEWORK_FATAL_EXCEPTION_TOPIC = "framework-fatal-topic";
@Autowired
@@ -238,7 +242,6 @@ class RetryTopicClassLevelExceptionRoutingIntegrationTests {
@Autowired
CountDownLatchContainer container;
@KafkaHandler
public void listenWithAnnotation(String message, @Header(KafkaHeaders.RECEIVED_TOPIC) String receivedTopic) {
container.fatalFrameworkLatch.countDown();
@@ -257,20 +260,33 @@ class RetryTopicClassLevelExceptionRoutingIntegrationTests {
static class CountDownLatchContainer {
CountDownLatch blockingAndTopicsLatch = new CountDownLatch(12);
CountDownLatch onlyRetryViaBlockingLatch = new CountDownLatch(4);
CountDownLatch onlyRetryViaTopicLatch = new CountDownLatch(3);
CountDownLatch fatalUserLatch = new CountDownLatch(1);
CountDownLatch fatalFrameworkLatch = new CountDownLatch(1);
CountDownLatch annotatedDltOnlyBlockingLatch = new CountDownLatch(1);
CountDownLatch annotatedDltUserFatalLatch = new CountDownLatch(1);
CountDownLatch annotatedDltFrameworkFatalLatch = new CountDownLatch(1);
CountDownLatch dltProcessorLatch = new CountDownLatch(1);
CountDownLatch dltProcessorWithErrorLatch = new CountDownLatch(1);
AtomicInteger blockingAndTopicsListenerInvocations = new AtomicInteger();
AtomicInteger onlyRetryViaTopicListenerInvocations = new AtomicInteger();
AtomicInteger onlyRetryViaBlockingListenerInvocations = new AtomicInteger();
AtomicInteger userFatalListenerInvocations = new AtomicInteger();
AtomicInteger fatalFrameworkListenerInvocations = new AtomicInteger();
}

View File

@@ -480,7 +480,6 @@ class RetryTopicClassLevelIntegrationTests {
@Autowired
CountDownLatchContainer container;
@KafkaHandler
public void listenWithAnnotation2(String message, @Header(KafkaHeaders.RECEIVED_TOPIC) String receivedTopic) {
container.countDownIfNotKnown(receivedTopic, container.countDownLatchNoRetry);
@@ -557,22 +556,39 @@ class RetryTopicClassLevelIntegrationTests {
static class CountDownLatchContainer {
CountDownLatch countDownLatch1 = new CountDownLatch(5);
CountDownLatch countDownLatch2 = new CountDownLatch(3);
CountDownLatch countDownLatch3 = new CountDownLatch(3);
CountDownLatch countDownLatch4 = new CountDownLatch(4);
CountDownLatch countDownLatch51 = new CountDownLatch(4);
CountDownLatch countDownLatch52 = new CountDownLatch(4);
CountDownLatch countDownLatch6 = new CountDownLatch(4);
CountDownLatch countDownLatchNoRetry = new CountDownLatch(1);
CountDownLatch countDownLatchDltOne = new CountDownLatch(1);
CountDownLatch countDownLatchDltTwo = new CountDownLatch(1);
CountDownLatch countDownLatchDltThree = new CountDownLatch(1);
CountDownLatch countDownLatchDltFour = new CountDownLatch(1);
CountDownLatch countDownLatchReuseOne = new CountDownLatch(2);
CountDownLatch countDownLatchReuseTwo = new CountDownLatch(5);
CountDownLatch countDownLatchReuseThree = new CountDownLatch(5);
CountDownLatch customDltCountdownLatch = new CountDownLatch(1);
CountDownLatch customErrorHandlerCountdownLatch = new CountDownLatch(6);
CountDownLatch customMessageConverterCountdownLatch = new CountDownLatch(6);
final List<String> knownTopics = new ArrayList<>();

View File

@@ -357,6 +357,7 @@ class RetryTopicConfigurerTests {
}
static class NoOpsClass {
void noOpsMethod() { };
void noOpsMethod() { }
}
}

View File

@@ -77,9 +77,13 @@ public class RetryTopicExceptionRoutingIntegrationTests {
private static final Logger logger = LoggerFactory.getLogger(RetryTopicExceptionRoutingIntegrationTests.class);
public final static String BLOCKING_AND_TOPIC_RETRY = "blocking-and-topic-retry";
public final static String ONLY_RETRY_VIA_BLOCKING = "only-retry-blocking-topic";
public final static String ONLY_RETRY_VIA_TOPIC = "only-retry-topic";
public final static String USER_FATAL_EXCEPTION_TOPIC = "user-fatal-topic";
public final static String FRAMEWORK_FATAL_EXCEPTION_TOPIC = "framework-fatal-topic";
@Autowired
@@ -270,20 +274,33 @@ public class RetryTopicExceptionRoutingIntegrationTests {
static class CountDownLatchContainer {
CountDownLatch blockingAndTopicsLatch = new CountDownLatch(12);
CountDownLatch onlyRetryViaBlockingLatch = new CountDownLatch(4);
CountDownLatch onlyRetryViaTopicLatch = new CountDownLatch(3);
CountDownLatch fatalUserLatch = new CountDownLatch(1);
CountDownLatch fatalFrameworkLatch = new CountDownLatch(1);
CountDownLatch annotatedDltOnlyBlockingLatch = new CountDownLatch(1);
CountDownLatch annotatedDltUserFatalLatch = new CountDownLatch(1);
CountDownLatch annotatedDltFrameworkFatalLatch = new CountDownLatch(1);
CountDownLatch dltProcessorLatch = new CountDownLatch(1);
CountDownLatch dltProcessorWithErrorLatch = new CountDownLatch(1);
AtomicInteger blockingAndTopicsListenerInvocations = new AtomicInteger();
AtomicInteger onlyRetryViaTopicListenerInvocations = new AtomicInteger();
AtomicInteger onlyRetryViaBlockingListenerInvocations = new AtomicInteger();
AtomicInteger userFatalListenerInvocations = new AtomicInteger();
AtomicInteger fatalFrameworkListenerInvocations = new AtomicInteger();
}

View File

@@ -571,22 +571,39 @@ public class RetryTopicIntegrationTests {
static class CountDownLatchContainer {
CountDownLatch countDownLatch1 = new CountDownLatch(5);
CountDownLatch countDownLatch2 = new CountDownLatch(3);
CountDownLatch countDownLatch3 = new CountDownLatch(3);
CountDownLatch countDownLatch4 = new CountDownLatch(4);
CountDownLatch countDownLatch51 = new CountDownLatch(4);
CountDownLatch countDownLatch52 = new CountDownLatch(4);
CountDownLatch countDownLatch6 = new CountDownLatch(4);
CountDownLatch countDownLatchNoRetry = new CountDownLatch(1);
CountDownLatch countDownLatchDltOne = new CountDownLatch(1);
CountDownLatch countDownLatchDltTwo = new CountDownLatch(1);
CountDownLatch countDownLatchDltThree = new CountDownLatch(1);
CountDownLatch countDownLatchDltFour = new CountDownLatch(1);
CountDownLatch countDownLatchReuseOne = new CountDownLatch(2);
CountDownLatch countDownLatchReuseTwo = new CountDownLatch(5);
CountDownLatch countDownLatchReuseThree = new CountDownLatch(5);
CountDownLatch customDltCountdownLatch = new CountDownLatch(1);
CountDownLatch customErrorHandlerCountdownLatch = new CountDownLatch(6);
CountDownLatch customMessageConverterCountdownLatch = new CountDownLatch(6);
final List<String> knownTopics = new ArrayList<>();

View File

@@ -246,20 +246,29 @@ public class RetryTopicSameContainerFactoryIntegrationTests {
static class CountDownLatchContainer {
CountDownLatch countDownLatchFirstRetryable = new CountDownLatch(4);
CountDownLatch countDownLatchSecondRetryable = new CountDownLatch(3);
CountDownLatch countDownLatchDltOne = new CountDownLatch(1);
CountDownLatch countDownLatchDltSecond = new CountDownLatch(1);
CountDownLatch countDownLatchBasic = new CountDownLatch(1);
CountDownLatch customizerLatch = new CountDownLatch(10);
CountDownLatch countDownLatchClassLevelFirstRetryable = new CountDownLatch(4);
CountDownLatch countDownLatchClassLevelSecondRetryable = new CountDownLatch(3);
CountDownLatch countDownLatchClassLevelDltOne = new CountDownLatch(1);
CountDownLatch countDownLatchClassLevelDltSecond = new CountDownLatch(1);
CountDownLatch countDownLatchClassLevelBasic = new CountDownLatch(1);
CountDownLatch customizerClassLevelLatch = new CountDownLatch(10);
}
@EnableKafka

View File

@@ -200,7 +200,6 @@ class KafkaStreamsInteractiveQueryServiceTests {
serializer);
}
@Configuration
@EnableKafka
@EnableKafkaStreams

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2022-2023 the original author or authors.
* Copyright 2022-2024 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.
@@ -115,7 +115,6 @@ public class ObservationIntegrationTests extends SampleTestRunner {
};
}
@Configuration
@EnableKafka
public static class Config {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2021 the original author or authors.
* Copyright 2016-2024 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.
@@ -516,7 +516,7 @@ public class JsonSerializationTests {
Child(int number) {
super(number);
}
}
}

View File

@@ -191,6 +191,12 @@
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<!-- Add the EmptyLineSeparator module -->
<module name="EmptyLineSeparator">
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, STATIC_INIT, INSTANCE_INIT, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
<property name="allowNoEmptyLineBetweenFields" value="false"/>
<property name="allowMultipleEmptyLines" value="false"/>
</module>
</module>
</module>