Fix depreactions

This commit is contained in:
Oleg Zhurakousky
2024-09-27 16:41:56 +02:00
parent 9aabfbe6ea
commit 6f9809eba1
17 changed files with 5 additions and 353 deletions

View File

@@ -86,12 +86,6 @@ public class KafkaConsumerProperties {
}
/**
* When true the offset is committed after each record, otherwise the offsets for the complete set of records
* received from the poll() are committed after all records have been processed.
*/
@Deprecated
private boolean ackEachRecord;
/**
* When true, topic partitions is automatically rebalanced between the members of a consumer group.
@@ -99,14 +93,6 @@ public class KafkaConsumerProperties {
*/
private boolean autoRebalanceEnabled = true;
/**
* Whether to autocommit offsets when a message has been processed.
* If set to false, a header with the key kafka_acknowledgment of the type org.springframework.kafka.support.Acknowledgment header
* is present in the inbound message. Applications may use this header for acknowledging messages.
*/
@Deprecated
private boolean autoCommitOffset = true;
/**
* Controlling the container acknowledgement mode. This is the preferred way to control the ack mode on the
* container instead of the deprecated autoCommitOffset property.
@@ -152,12 +138,6 @@ public class KafkaConsumerProperties {
*/
private KafkaProducerProperties dlqProducerProperties = new KafkaProducerProperties();
/**
* @deprecated No longer used by the binder.
*/
@Deprecated
private int recoveryInterval = 5000;
/**
* List of trusted packages to provide the header mapper.
*/
@@ -230,53 +210,6 @@ public class KafkaConsumerProperties {
*/
private boolean reactiveAtMostOnce;
/**
* @return if each record needs to be acknowledged.
*
* When true the offset is committed after each record, otherwise the offsets for the complete set of records
* received from the poll() are committed after all records have been processed.
*
* @deprecated since 3.1 in favor of using {@link #ackMode}
*/
@Deprecated
public boolean isAckEachRecord() {
return this.ackEachRecord;
}
/**
* @param ackEachRecord
*
* @deprecated in favor of using {@link #ackMode}
*/
@Deprecated
public void setAckEachRecord(boolean ackEachRecord) {
this.ackEachRecord = ackEachRecord;
}
/**
* @return is autocommit offset enabled
*
* Whether to autocommit offsets when a message has been processed.
* If set to false, a header with the key kafka_acknowledgment of the type org.springframework.kafka.support.Acknowledgment header
* is present in the inbound message. Applications may use this header for acknowledging messages.
*
* @deprecated since 3.1 in favor of using {@link #ackMode}
*/
@Deprecated
public boolean isAutoCommitOffset() {
return this.autoCommitOffset;
}
/**
* @param autoCommitOffset
*
* @deprecated in favor of using {@link #ackMode}
*/
@Deprecated
public void setAutoCommitOffset(boolean autoCommitOffset) {
this.autoCommitOffset = autoCommitOffset;
}
/**
* @return Container's ack mode.
*/
@@ -348,26 +281,6 @@ public class KafkaConsumerProperties {
this.autoCommitOnError = autoCommitOnError;
}
/**
* No longer used.
* @return the interval.
* @deprecated No longer used by the binder
*/
@Deprecated
public int getRecoveryInterval() {
return this.recoveryInterval;
}
/**
* No longer used.
* @param recoveryInterval the interval.
* @deprecated No longer needed by the binder
*/
@Deprecated
public void setRecoveryInterval(int recoveryInterval) {
this.recoveryInterval = recoveryInterval;
}
/**
* @return is auto rebalance enabled
*

View File

@@ -321,18 +321,6 @@ public class KafkaMessageChannelBinder extends
this.producerListener = producerListener;
}
/**
* Set a {@link ClientFactoryCustomizer} for the {@link ProducerFactory} and {@link ConsumerFactory} created inside
* the binder.
*
* @param customizer the client factory customizer
* @deprecated in favor of {@link #addClientFactoryCustomizer(ClientFactoryCustomizer)}.
*/
@Deprecated
public void setClientFactoryCustomizer(ClientFactoryCustomizer customizer) {
addClientFactoryCustomizer(customizer);
}
public void addClientFactoryCustomizer(ClientFactoryCustomizer customizer) {
if (customizer != null) {
this.clientFactoryCustomizers.add(customizer);
@@ -686,17 +674,7 @@ public class KafkaMessageChannelBinder extends
messageListenerContainer.setBeanName(destination + ".container");
// end of these won't be needed...
ContainerProperties.AckMode ackMode = extendedConsumerProperties.getExtension().getAckMode();
if (ackMode == null) {
if (extendedConsumerProperties.getExtension().isAckEachRecord()) {
ackMode = ContainerProperties.AckMode.RECORD;
}
else {
if (!extendedConsumerProperties.getExtension().isAutoCommitOffset()) {
messageListenerContainer.getContainerProperties()
.setAckMode(ContainerProperties.AckMode.MANUAL);
}
}
}
if (ackMode != null) {
if ((extendedConsumerProperties.isBatchMode() && ackMode != ContainerProperties.AckMode.RECORD) ||
!extendedConsumerProperties.isBatchMode()) {
@@ -1425,32 +1403,12 @@ public class KafkaMessageChannelBinder extends
return stringWriter.getBuffer().toString();
}
/**
* Set a {@link ConsumerConfigCustomizer} for the {@link ConsumerFactory} created inside the binder.
* @param consumerConfigCustomizer the consumer config customizer
* @deprecated in favor of {@link #addConsumerConfigCustomizer(ConsumerConfigCustomizer)}.
*/
@Deprecated
public void setConsumerConfigCustomizer(ConsumerConfigCustomizer consumerConfigCustomizer) {
addConsumerConfigCustomizer(consumerConfigCustomizer);
}
public void addConsumerConfigCustomizer(ConsumerConfigCustomizer consumerConfigCustomizer) {
if (consumerConfigCustomizer != null) {
this.consumerConfigCustomizers.add(consumerConfigCustomizer);
}
}
/**
* Set a {@link ProducerConfigCustomizer} for the {@link ProducerFactory} created inside the binder.
* @param producerConfigCustomizer the producer config customizer
* @deprecated in favor of {@link #addProducerConfigCustomizer(ProducerConfigCustomizer)}.
*/
@Deprecated
public void setProducerConfigCustomizer(ProducerConfigCustomizer producerConfigCustomizer) {
addProducerConfigCustomizer(producerConfigCustomizer);
}
public void addProducerConfigCustomizer(ProducerConfigCustomizer producerConfigCustomizer) {
if (producerConfigCustomizer != null) {
this.producerConfigCustomizers.add(producerConfigCustomizer);

View File

@@ -1515,7 +1515,6 @@ class KafkaBinderTests extends
consumerProperties.setBackOffMaxInterval(150);
//When auto commit is disabled, then the record is committed after publishing to DLQ using the manual acknowledgement.
// (if DLQ is enabled, which is, in this case).
consumerProperties.getExtension().setAutoCommitOffset(false);
consumerProperties.getExtension().setEnableDlq(true);
DirectChannel moduleInputChannel = createBindableChannel("input",

View File

@@ -136,9 +136,6 @@ class KafkaBinderExtendedPropertiesTest {
customKafkaConsumerProperties.getConfiguration().get("value.serializer"))
.isEqualTo("BarSerializer.class");
assertThat(kafkaConsumerProperties.isAckEachRecord()).isEqualTo(true);
assertThat(customKafkaConsumerProperties.isAckEachRecord()).isEqualTo(false);
RebalanceListener rebalanceListener = context.getBean(RebalanceListener.class);
assertThat(rebalanceListener.latch.await(10, TimeUnit.SECONDS)).isTrue();
assertThat(rebalanceListener.bindings.keySet()).contains("standard-in",

View File

@@ -54,21 +54,6 @@ public class RabbitBinderConfigurationProperties {
this.adminAddresses = adminAddresses;
}
/**
* @param adminAddresses A comma-separated list of RabbitMQ management plugin URLs.
* @deprecated in favor of {@link #setAdminAddresses(String[])}. Will be removed in a
* future release.
*/
@Deprecated
public void setAdminAdresses(String[] adminAddresses) {
setAdminAddresses(adminAddresses);
}
@Deprecated
public String[] getAdminAdresses() {
return this.adminAddresses;
}
public String[] getNodes() {
return nodes;
}

View File

@@ -180,42 +180,6 @@ public class RabbitConsumerProperties extends RabbitCommonProperties {
this.prefetch = prefetch;
}
/**
* @return the header patterns.
* @deprecated - use {@link #getHeaderPatterns()}.
*/
@Deprecated
public String[] getRequestHeaderPatterns() {
return this.headerPatterns;
}
/**
* @param requestHeaderPatterns request header patterns
* @deprecated - use {@link #setHeaderPatterns(String[])}.
*/
@Deprecated
public void setRequestHeaderPatterns(String[] requestHeaderPatterns) {
this.headerPatterns = requestHeaderPatterns;
}
/**
* @return the tx size.
* @deprecated in favor of {@link #getBatchSize()}
*/
@Deprecated
@Min(value = 1, message = "Tx Size should be greater than zero.")
public int getTxSize() {
return getBatchSize();
}
/**
* @param txSize the tx size
* deprecated in favor of {@link #setBatchSize(int)}.
*/
public void setTxSize(int txSize) {
setBatchSize(txSize);
}
@Min(value = 1, message = "Batch Size should be greater than zero.")
public int getBatchSize() {
return batchSize;

View File

@@ -163,24 +163,6 @@ public class RabbitProducerProperties extends RabbitCommonProperties {
*/
private boolean superStream;
/**
* @param requestHeaderPatterns the patterns.
* @deprecated - use {@link #setHeaderPatterns(String[])}.
*/
@Deprecated
public void setRequestHeaderPatterns(String[] requestHeaderPatterns) {
this.headerPatterns = requestHeaderPatterns;
}
/**
* @return the header patterns.
* @deprecated - use {@link #getHeaderPatterns()}.
*/
@Deprecated
public String[] getRequestHeaderPatterns() {
return this.headerPatterns;
}
public void setCompress(boolean compress) {
this.compress = compress;
}

View File

@@ -499,7 +499,7 @@ class RabbitBinderTests extends
properties.getExtension().setPrefix("foo.");
properties.getExtension().setPrefetch(20);
properties.getExtension().setHeaderPatterns(new String[] { "foo" });
properties.getExtension().setTxSize(10);
properties.getExtension().setBatchSize(10);
QuorumConfig quorum = properties.getExtension().getQuorum();
quorum.setEnabled(true);
quorum.setDeliveryLimit(10);

View File

@@ -37,16 +37,6 @@ public class InputDestination extends AbstractDestination {
this.getChannel(0).send(message);
}
/**
* @param message message to send
* @param inputIndex input index
* @deprecated since 3.0.2 in favor of {@link #receive(long, String)} where you should use the actual binding name (e.g., "foo-in-0")
*/
@Deprecated
public void send(Message<?> message, int inputIndex) {
this.getChannel(inputIndex).send(message);
}
/**
* Allows the {@link Message} to be sent to a Binder's destination.<br>
* This needs a bit of clarification. Just like with any binder, 'destination'

View File

@@ -56,24 +56,6 @@ public class PartitionHandler {
private volatile int partitionCount;
/**
* Construct a {@code PartitionHandler}.
* @param evaluationContext evaluation context for binder
* @param properties binder properties
* @param partitionKeyExtractorStrategy PartitionKeyExtractor strategy
* @param partitionSelectorStrategy PartitionSelector strategy
*
* @deprecated since 3.0.2. Please use another constructor which allows you to pass an instance of beanFactory
*/
@Deprecated
public PartitionHandler(EvaluationContext evaluationContext,
ProducerProperties properties,
PartitionKeyExtractorStrategy partitionKeyExtractorStrategy,
PartitionSelectorStrategy partitionSelectorStrategy) {
this(evaluationContext, properties, (ConfigurableListableBeanFactory) extractBeanFactoryFromEvaluationContext(evaluationContext));
}
/**
* Construct a {@code PartitionHandler}.
* @param evaluationContext evaluation context for binder

View File

@@ -44,7 +44,6 @@ import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.integration.support.utils.IntegrationUtils;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* @author Dave Syer
@@ -62,15 +61,6 @@ public class BindingServiceProperties
private static final int DEFAULT_BINDING_RETRY_INTERVAL = 30;
/**
* A semi-colon delimited string representing the names of the sources based on which source bindings will be created.
* This is primarily to support cases where source binding may be required without providing a corresponding Supplier.
* (e.g., for cases where the actual source of data is outside of scope of spring-cloud-stream - HTTP -> Stream)
* @deprecated use {@link #outputBindings}
*/
@Deprecated
private String source;
/**
* A semi-colon delimited string to explicitly define input bindings (specifically for cases when there
* is no implicit trigger to create such bindings such as Function, Supplier or Consumer).
@@ -308,23 +298,6 @@ public class BindingServiceProperties
this.bindingRetryInterval = bindingRetryInterval;
}
/**
* @deprecated in favor of {@link #getOutputBindings()}
*/
@Deprecated
public String getSource() {
return source;
}
/**
* @deprecated in favor of {@link #setOutputBindings()}
*/
@Deprecated
public void setSource(String source) {
this.source = source;
this.outputBindings = source;
}
public void updateProducerProperties(String bindingName,
ProducerProperties producerProperties) {
if (this.bindings.containsKey(bindingName)) {
@@ -354,8 +327,6 @@ public class BindingServiceProperties
}
public void setOutputBindings(String outputBindings) {
Assert.state(!StringUtils.hasText(this.source), "Setting 'source' and 'output-binding' is not allowed "
+ "because 'source' is deprecated in favor of 'output-binding'.");
this.outputBindings = outputBindings;
}

View File

@@ -51,21 +51,10 @@ public abstract class AbstractAvroMessageConverter extends AbstractMessageConver
private Schema.Parser schemaParser = new Schema.Parser();
private AvroSchemaServiceManager avroSchemaServiceManager;
@Deprecated
protected AbstractAvroMessageConverter(MimeType supportedMimeType) {
this(Collections.singletonList(supportedMimeType), new AvroSchemaServiceManagerImpl());
}
protected AbstractAvroMessageConverter(MimeType supportedMimeType, AvroSchemaServiceManager avroSchemaServiceManager) {
this(Collections.singletonList(supportedMimeType), avroSchemaServiceManager);
}
@Deprecated
protected AbstractAvroMessageConverter(Collection<MimeType> supportedMimeTypes) {
this(supportedMimeTypes, new AvroSchemaServiceManagerImpl());
setContentTypeResolver(new OriginalContentTypeResolver());
}
protected AbstractAvroMessageConverter(Collection<MimeType> supportedMimeTypes, AvroSchemaServiceManager manager) {
super(supportedMimeTypes);
setContentTypeResolver(new OriginalContentTypeResolver());

View File

@@ -41,15 +41,6 @@ public class AvroSchemaMessageConverter extends AbstractAvroMessageConverter {
private Schema schema;
/**
* Create a {@link AvroSchemaMessageConverter}. Uses the default {@link MimeType} of
* {@code "application/avro"}.
*/
@Deprecated
public AvroSchemaMessageConverter() {
super(new MimeType("application", "avro"));
}
/**
* Create a {@link AvroSchemaMessageConverter}. Uses the default {@link MimeType} of
* {@code "application/avro"}.
@@ -59,17 +50,6 @@ public class AvroSchemaMessageConverter extends AbstractAvroMessageConverter {
super(new MimeType("application", "avro"), manager);
}
/**
* Create a {@link AvroSchemaMessageConverter}. The converter will be used for the
* provided {@link MimeType}.
* @param supportedMimeType mime type to be supported by
* {@link AvroSchemaMessageConverter}
*/
@Deprecated
public AvroSchemaMessageConverter(MimeType supportedMimeType) {
super(supportedMimeType);
}
/**
* Create a {@link AvroSchemaMessageConverter}. The converter will be used for the
* provided {@link MimeType}.
@@ -81,16 +61,6 @@ public class AvroSchemaMessageConverter extends AbstractAvroMessageConverter {
super(supportedMimeType, manager);
}
/**
* Create a {@link AvroSchemaMessageConverter}. The converter will be used for the
* provided {@link MimeType}s.
* @param supportedMimeTypes the mime types supported by this converter
*/
@Deprecated
public AvroSchemaMessageConverter(Collection<MimeType> supportedMimeTypes) {
super(supportedMimeTypes);
}
/**
* Create a {@link AvroSchemaMessageConverter}. The converter will be used for the
* provided {@link MimeType}s.

View File

@@ -138,25 +138,6 @@ public class AvroSchemaRegistryClientMessageConverter extends AbstractAvroMessag
private boolean ignoreSchemaRegistryServer;
/**
* Creates a new instance, configuring it with {@link SchemaRegistryClient} and
* {@link CacheManager}.
*
* @param schemaRegistryClient the {@link SchemaRegistryClient} used to interact with
* the schema registry server.
* @param cacheManager instance of {@link CacheManager} to cache parsed schemas. If
* caching is not required use {@link NoOpCacheManager}
*/
@Deprecated
public AvroSchemaRegistryClientMessageConverter(
SchemaRegistryClient schemaRegistryClient, CacheManager cacheManager) {
super(Collections.singletonList(DEFAULT_AVRO_MIME_TYPE), defaultAvroSchemaServiceManager);
Assert.notNull(schemaRegistryClient, "cannot be null");
Assert.notNull(cacheManager, "'cacheManager' cannot be null");
this.schemaRegistryClient = schemaRegistryClient;
this.cacheManager = cacheManager;
}
/**
* Creates a new instance, configuring it with {@link SchemaRegistryClient} and
* {@link CacheManager}.

View File

@@ -19,6 +19,8 @@ package org.springframework.cloud.stream.schema.avro;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -153,17 +155,7 @@ class AvroSchemaServiceManagerTests {
@Test
public void avroSchemaMessageConverter() {
AvroSchemaMessageConverter converter = new AvroSchemaMessageConverter();
MimeType mimeType = new MimeType("application", "avro");
assertThat(mimeType).isEqualTo(converter.getSupportedMimeTypes().get(0));
AvroSchemaMessageConverter converter2 = new AvroSchemaMessageConverter(mimeType);
assertThat(mimeType).isEqualTo(converter2.getSupportedMimeTypes().get(0));
AvroSchemaMessageConverter converter3 =
new AvroSchemaMessageConverter(Lists.newArrayList(mimeType));
assertThat(mimeType).isEqualTo(converter3.getSupportedMimeTypes().get(0));
AvroSchemaServiceManager manager = new AvroSchemaServiceManagerImpl();
AvroSchemaMessageConverter converter4 = new AvroSchemaMessageConverter(manager);
assertThat(mimeType).isEqualTo(converter4.getSupportedMimeTypes().get(0));

View File

@@ -132,27 +132,6 @@ public class ServerController {
return new ResponseEntity<>(schema.get(), HttpStatus.OK);
}
/**
* <p>
* Find by {@link Schema#getSubject() subject} and {@link Schema#getFormat() format}.
*
* @param subject the {@link Schema#getSubject() subject}, must not be
* {@literal null}.
* @param format the {@link Schema#getFormat() format}, must not be {@literal null}.
* @return An {@link HttpStatus#OK} response populated with the list of {@link Schema
* Schemas}, in ascending order by {@link Schema#getVersion() version}, that matched
* the supplied {@link Schema#getSubject() subject} and {@link Schema#getFormat()
* format}.
* @deprecated use {@link #findBySubjectAndFormat(String, String)}
* @see <a href=
* "https://github.com/spring-cloud/spring-cloud-stream/issues/1760">GH-1760</a>
*/
@Deprecated
public ResponseEntity<List<Schema>> findBySubjectAndVersion(@PathVariable("subject") String subject,
@PathVariable("format") String format) {
return findBySubjectAndFormatOrderByVersionAsc(subject, format);
}
/**
* Find by {@link Schema#getSubject() subject} and {@link Schema#getFormat() format}.
*

View File

@@ -459,7 +459,7 @@ class SchemaRegistryServerAvroTests {
assertThat(schemas).hasSize(2);
final ResponseEntity<List<Schema>> findBySubjectAndVersionResponseEntity = this.serverController
.findBySubjectAndVersion(subject, format);
.findBySubjectAndFormat(subject, format);
assertThat(findBySubjectAndVersionResponseEntity.getStatusCode().is2xxSuccessful()).isTrue();