Add Nullability support into Java DSL
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020 the original author or authors.
|
||||
* Copyright 2020-2023 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.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.integration.kafka.dsl;
|
||||
|
||||
import org.springframework.integration.dsl.MessageChannelSpec;
|
||||
import org.springframework.integration.kafka.channel.AbstractKafkaChannel;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -34,10 +35,11 @@ import org.springframework.integration.kafka.channel.AbstractKafkaChannel;
|
||||
public abstract class AbstractKafkaChannelSpec<S extends AbstractKafkaChannelSpec<S, C>, C extends AbstractKafkaChannel>
|
||||
extends MessageChannelSpec<S, C> {
|
||||
|
||||
@Nullable
|
||||
protected String groupId; // NOSONAR
|
||||
|
||||
@Override
|
||||
public S id(String idToSet) { // NOSONAR - increase visibility
|
||||
public S id(@Nullable String idToSet) { // NOSONAR - increase visibility
|
||||
return super.id(idToSet);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2018-2023 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,6 +48,7 @@ public class KafkaInboundChannelAdapterSpec<K, V>
|
||||
*/
|
||||
KafkaInboundChannelAdapterSpec(ConsumerFactory<K, V> consumerFactory,
|
||||
ConsumerProperties consumerProperties, boolean allowMultiFetch) {
|
||||
|
||||
this.target = new KafkaMessageSource<>(consumerFactory, consumerProperties, allowMultiFetch);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.kafka.dsl;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
@@ -26,7 +27,6 @@ import org.apache.kafka.common.TopicPartition;
|
||||
import org.springframework.integration.dsl.ComponentsRegistration;
|
||||
import org.springframework.integration.dsl.MessagingGatewaySpec;
|
||||
import org.springframework.integration.kafka.inbound.KafkaInboundGateway;
|
||||
import org.springframework.integration.support.ObjectStringMapBuilder;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.kafka.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.kafka.listener.ConsumerSeekAware;
|
||||
@@ -164,10 +164,10 @@ public class KafkaInboundGatewaySpec<K, V, R, S extends KafkaInboundGatewaySpec<
|
||||
|
||||
@Override
|
||||
public Map<Object, String> getComponentsToRegister() {
|
||||
return new ObjectStringMapBuilder()
|
||||
.put(this.containerSpec.getObject(), this.containerSpec.getId())
|
||||
.put(this.templateSpec.getObject(), this.templateSpec.getId())
|
||||
.get();
|
||||
Map<Object, String> components = new HashMap<>();
|
||||
components.put(this.containerSpec.getObject(), this.containerSpec.getId());
|
||||
components.put(this.templateSpec.getObject(), this.templateSpec.getId());
|
||||
return components;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class KafkaMessageDrivenChannelAdapterSpec<K, V, S extends KafkaMessageDr
|
||||
}
|
||||
|
||||
/**
|
||||
* When using a type-aware message converter (such as {@code StringJsonMessageConverter},
|
||||
* When using a type-aware message converter (such as {@code StringJsonMessageConverter}),
|
||||
* set the payload type the converter should create. Defaults to {@link Object}.
|
||||
* @param payloadType the type.
|
||||
* @return the spec
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2022 the original author or authors.
|
||||
* Copyright 2018-2023 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,6 +28,7 @@ import org.springframework.kafka.listener.CommonErrorHandler;
|
||||
import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
|
||||
import org.springframework.kafka.listener.ContainerProperties;
|
||||
import org.springframework.kafka.support.TopicPartitionOffset;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A helper class in the Builder pattern style to delegate options to the
|
||||
@@ -65,7 +66,7 @@ public class KafkaMessageListenerContainerSpec<K, V>
|
||||
}
|
||||
|
||||
@Override
|
||||
public KafkaMessageListenerContainerSpec<K, V> id(String id) { // NOSONAR - increase visibility
|
||||
public KafkaMessageListenerContainerSpec<K, V> id(@Nullable String id) { // NOSONAR - increase visibility
|
||||
return super.id(id);
|
||||
}
|
||||
|
||||
@@ -205,8 +206,8 @@ public class KafkaMessageListenerContainerSpec<K, V>
|
||||
/**
|
||||
* Set whether to call consumer.commitSync() or commitAsync() when the
|
||||
* container is responsible for commits. Default true. See
|
||||
* https://github.com/spring-projects/spring-kafka/issues/62 At the time of
|
||||
* writing, async commits are not entirely reliable.
|
||||
* <a href="https://github.com/spring-projects/spring-kafka/issues/62"/>.
|
||||
* At the time of writing, async commits are not entirely reliable.
|
||||
* @param syncCommits true to use commitSync().
|
||||
* @return the spec.
|
||||
* @see ContainerProperties#setSyncCommits(boolean)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2018-2023 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.
|
||||
@@ -21,6 +21,7 @@ import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.kafka.core.ProducerFactory;
|
||||
import org.springframework.kafka.support.ProducerListener;
|
||||
import org.springframework.kafka.support.converter.RecordMessageConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* An {@link IntegrationComponentSpec} implementation for the {@link KafkaTemplate}.
|
||||
@@ -49,7 +50,7 @@ public class KafkaTemplateSpec<K, V>
|
||||
}
|
||||
|
||||
@Override
|
||||
public KafkaTemplateSpec<K, V> id(String id) { // NOSONAR - visibility
|
||||
public KafkaTemplateSpec<K, V> id(@Nullable String id) { // NOSONAR - visibility
|
||||
return super.id(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
/**
|
||||
* Provides Spring Integration Java DSL Components support for Apache Kafka.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.integration.kafka.dsl;
|
||||
|
||||
Reference in New Issue
Block a user