Minor code cleanup/deprecation removal etc.

This commit is contained in:
Soby Chacko
2023-01-10 11:09:25 -05:00
parent b1ebc457fd
commit 33e58a0baa
7 changed files with 11 additions and 12 deletions

View File

@@ -272,7 +272,7 @@ public class KafkaBinderConfigurationProperties {
private String toConnectionString(String[] hosts, String defaultPort) {
String[] fullyFormattedHosts = new String[hosts.length];
for (int i = 0; i < hosts.length; i++) {
if (hosts[i].contains(":") || StringUtils.isEmpty(defaultPort)) {
if (hosts[i].contains(":") || !StringUtils.hasText(defaultPort)) {
fullyFormattedHosts[i] = hosts[i];
}
else {

View File

@@ -206,7 +206,7 @@ public abstract class AbstractKafkaStreamsBinderProcessor implements Application
}
String applicationId = functionConfig.getApplicationId();
if (!StringUtils.isEmpty(applicationId)) {
if (StringUtils.hasText(applicationId)) {
streamConfiguration.put(StreamsConfig.APPLICATION_ID_CONFIG, applicationId);
}
}
@@ -614,7 +614,7 @@ public abstract class AbstractKafkaStreamsBinderProcessor implements Application
private <K, V> Processor<K, V, Void, Void> eventTypeProcessor(KafkaStreamsConsumerProperties kafkaStreamsConsumerProperties,
AtomicBoolean matched, AtomicReference<String> topicObject, AtomicReference<Headers> headersObject) {
return new Processor<K, V, Void, Void>() {
return new Processor<>() {
org.apache.kafka.streams.processor.api.ProcessorContext<?, ?> context;

View File

@@ -195,11 +195,11 @@ public class KafkaStreamsBinderSupportAutoConfiguration {
//Making sure that the application indeed set a property.
String kafkaStreamsBinderBroker = environment.getProperty("spring.cloud.stream.kafka.streams.binder.brokers");
if (StringUtils.isEmpty(kafkaStreamsBinderBroker)) {
if (!StringUtils.hasText(kafkaStreamsBinderBroker)) {
//Kafka Streams binder specific property for brokers is not set by the application.
//See if there is one configured at the kafka binder level.
String kafkaBinderBroker = environment.getProperty("spring.cloud.stream.kafka.binder.brokers");
if (!StringUtils.isEmpty(kafkaBinderBroker)) {
if (StringUtils.hasText(kafkaBinderBroker)) {
kafkaConnectionString = kafkaBinderBroker;
configProperties.setBrokers(kafkaConnectionString);
}

View File

@@ -128,12 +128,12 @@ final class KafkaStreamsBinderUtils {
(cr, e) -> new TopicPartition(dlqDestinationResolvers.values().iterator().next().apply(cr, e),
partitionFunction.apply(group, cr, e));
DeadLetterPublishingRecoverer kafkaStreamsBinderDlqRecoverer = !dlqDestinationResolvers.isEmpty() || !StringUtils
.isEmpty(extendedConsumerProperties.getExtension().getDlqName())
DeadLetterPublishingRecoverer kafkaStreamsBinderDlqRecoverer = !dlqDestinationResolvers.isEmpty() || StringUtils
.hasText(extendedConsumerProperties.getExtension().getDlqName())
? new DeadLetterPublishingRecoverer(kafkaTemplate, destinationResolver)
: null;
for (String inputTopic : inputTopics) {
if (StringUtils.isEmpty(
if (!StringUtils.hasText(
extendedConsumerProperties.getExtension().getDlqName()) && dlqDestinationResolvers.isEmpty()) {
destinationResolver = (cr, e) -> new TopicPartition("error." + inputTopic + "." + group,
partitionFunction.apply(group, cr, e));

View File

@@ -97,7 +97,7 @@ public class KafkaStreamsMessageConversionDelegate {
Message<?> message = v instanceof Message<?> ? (Message<?>) v
: MessageBuilder.withPayload(v).build();
Map<String, Object> headers = new HashMap<>(message.getHeaders());
if (!StringUtils.isEmpty(contentType)) {
if (StringUtils.hasText(contentType)) {
headers.put(MessageHeaders.CONTENT_TYPE, contentType);
}
MessageHeaders messageHeaders = new MessageHeaders(headers);

View File

@@ -49,7 +49,6 @@ public class KafkaStreamsTopologyEndpoint {
@ReadOperation
public List<String> kafkaStreamsTopologies() {
final List<StreamsBuilderFactoryBean> streamsBuilderFactoryBeans = this.kafkaStreamsRegistry.streamsBuilderFactoryBeans();
final StringBuilder topologyDescription = new StringBuilder();
final List<String> descs = new ArrayList<>();
streamsBuilderFactoryBeans.stream()
.forEach(streamsBuilderFactoryBean ->
@@ -59,7 +58,7 @@ public class KafkaStreamsTopologyEndpoint {
@ReadOperation
public String kafkaStreamsTopology(@Selector String applicationId) {
if (!StringUtils.isEmpty(applicationId)) {
if (StringUtils.hasText(applicationId)) {
final StreamsBuilderFactoryBean streamsBuilderFactoryBean = this.kafkaStreamsRegistry.streamsBuilderFactoryBean(applicationId);
if (streamsBuilderFactoryBean != null) {
return streamsBuilderFactoryBean.getTopology().describe().toString();

View File

@@ -167,7 +167,7 @@ public class RabbitExchangeQueueProvisioner
producerProperties.getExtension(), false));
declareQueue(queue.getName(), queue);
String prefix = producerProperties.getExtension().getPrefix();
String destination = StringUtils.isEmpty(prefix) ? exchangeName
String destination = !StringUtils.hasText(prefix) ? exchangeName
: exchangeName.substring(prefix.length());
String[] routingKeys = bindingRoutingKeys(producerProperties.getExtension());
if (ObjectUtils.isEmpty(routingKeys)) {