Misc cleanups (#317)
* Replace `String.format` w/ `String.formatted` * Simplify LogAccessor usage * Replace `new LogAccessor(LogFactory.getLog(Class))` calls w/ `new LogAccessor(Class)` * Remove fully qualified refs in javadoc + code
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -57,9 +57,9 @@ public class CheckClasspathForProhibitedDependencies extends DefaultTask {
|
||||
.map((artifact) -> artifact.getModuleVersion().getId()).filter(this::prohibited)
|
||||
.map((id) -> id.getGroup() + ":" + id.getName()).collect(Collectors.toCollection(TreeSet::new));
|
||||
if (!prohibited.isEmpty()) {
|
||||
StringBuilder message = new StringBuilder(String.format("Found prohibited dependencies:%n"));
|
||||
StringBuilder message = new StringBuilder("Found prohibited dependencies:%n".formatted());
|
||||
for (String dependency : prohibited) {
|
||||
message.append(String.format(" %s%n", dependency));
|
||||
message.append(" %s%n".formatted(dependency));
|
||||
}
|
||||
throw new GradleException(message.toString());
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public abstract class UpdateToSnapshotVersionTask extends UpdateProjectVersionTa
|
||||
patchSegment = String.valueOf(Integer.parseInt(patchSegment) + 1);
|
||||
}
|
||||
System.out.println("modifier = " + modifier);
|
||||
return String.format("%s.%s.%s-SNAPSHOT", majorSegment, minorSegment, patchSegment);
|
||||
return "%s.%s.%s-SNAPSHOT".formatted(majorSegment, minorSegment, patchSegment);
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException(
|
||||
|
||||
@@ -37,7 +37,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.pulsar.client.api.DeadLetterPolicy;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
@@ -120,7 +119,7 @@ import org.springframework.util.StringUtils;
|
||||
public class ReactivePulsarListenerAnnotationBeanPostProcessor<V>
|
||||
implements BeanPostProcessor, Ordered, ApplicationContextAware, InitializingBean, SmartInitializingSingleton {
|
||||
|
||||
private final LogAccessor logger = new LogAccessor(LogFactory.getLog(getClass()));
|
||||
private final LogAccessor logger = new LogAccessor(this.getClass());
|
||||
|
||||
/**
|
||||
* The bean name of the default {@link ReactivePulsarListenerContainerFactory}.
|
||||
@@ -508,7 +507,7 @@ public class ReactivePulsarListenerAnnotationBeanPostProcessor<V>
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("@ReactivePulsarListener can't resolve '%s' as a String", resolvedValue));
|
||||
"@ReactivePulsarListener can't resolve '%s' as a String".formatted(resolvedValue));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,12 +535,12 @@ public class ReactivePulsarListenerAnnotationBeanPostProcessor<V>
|
||||
ReflectionUtils.handleReflectionException(ex);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
throw new IllegalStateException(String.format(
|
||||
"@ReactivePulsarListener method '%s' found on bean target class '%s', "
|
||||
+ "but not found in any interface(s) for bean JDK proxy. Either "
|
||||
+ "pull the method up to an interface or switch to subclass (CGLIB) "
|
||||
+ "proxies by setting proxy-target-class/proxyTargetClass " + "attribute to 'true'",
|
||||
method.getName(), method.getDeclaringClass().getSimpleName()), ex);
|
||||
throw new IllegalStateException("@ReactivePulsarListener method '%s' found on bean target class '%s', "
|
||||
+ "but not found in any interface(s) for bean JDK proxy. Either "
|
||||
+ "pull the method up to an interface or switch to subclass (CGLIB) "
|
||||
+ "proxies by setting proxy-target-class/proxyTargetClass "
|
||||
+ "attribute to 'true'".formatted(method.getName(), method.getDeclaringClass().getSimpleName()),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
return method;
|
||||
|
||||
@@ -95,7 +95,7 @@ public class DefaultReactivePulsarSenderFactory<T> implements ReactivePulsarSend
|
||||
@Nullable List<ReactiveMessageSenderBuilderCustomizer<T>> customizers) {
|
||||
|
||||
String resolvedTopic = ReactiveMessageSenderUtils.resolveTopicName(topic, this);
|
||||
this.logger.trace(() -> String.format("Creating reactive message sender for '%s' topic", resolvedTopic));
|
||||
this.logger.trace(() -> "Creating reactive message sender for '%s' topic".formatted(resolvedTopic));
|
||||
ReactiveMessageSenderBuilder<T> sender = this.reactivePulsarClient.messageSender(schema);
|
||||
sender.applySpec(this.reactiveMessageSenderSpec);
|
||||
sender.topic(resolvedTopic);
|
||||
|
||||
@@ -128,12 +128,12 @@ public class ReactivePulsarTemplate<T> implements ReactivePulsarOperations<T> {
|
||||
@Nullable MessageSpecBuilderCustomizer<T> messageSpecBuilderCustomizer,
|
||||
@Nullable ReactiveMessageSenderBuilderCustomizer<T> customizer) {
|
||||
String topicName = resolveTopic(topic, message.getClass());
|
||||
this.logger.trace(() -> String.format("Sending reactive msg to '%s' topic", topicName));
|
||||
this.logger.trace(() -> "Sending reactive msg to '%s' topic".formatted(topicName));
|
||||
ReactiveMessageSender<T> sender = createMessageSender(topicName, message, schema, customizer);
|
||||
// @formatter:off
|
||||
return sender.sendOne(getMessageSpec(messageSpecBuilderCustomizer, message))
|
||||
.doOnError(ex -> this.logger.error(ex, () -> String.format("Failed to send message to '%s' topic", topicName)))
|
||||
.doOnSuccess(msgId -> this.logger.trace(() -> String.format("Sent message to '%s' topic", topicName)));
|
||||
.doOnError(ex -> this.logger.error(ex, () -> "Failed to send message to '%s' topic".formatted(topicName)))
|
||||
.doOnSuccess(msgId -> this.logger.trace(() -> "Sent message to '%s' topic".formatted(topicName)));
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@@ -144,11 +144,9 @@ public class ReactivePulsarTemplate<T> implements ReactivePulsarOperations<T> {
|
||||
if (firstMessage != null && firstSignal.isOnNext()) {
|
||||
String topicName = resolveTopic(topic, firstMessage.getClass());
|
||||
ReactiveMessageSender<T> sender = createMessageSender(topicName, firstMessage, schema, customizer);
|
||||
return messageFlux.map(MessageSpec::of).as(sender::sendMany)
|
||||
.doOnError(ex -> this.logger.error(ex,
|
||||
() -> String.format("Failed to send messages to '%s' topic", topicName)))
|
||||
.doOnNext(msgId -> this.logger
|
||||
.trace(() -> String.format("Sent messages to '%s' topic", topicName)));
|
||||
return messageFlux.map(MessageSpec::of).as(sender::sendMany).doOnError(
|
||||
ex -> this.logger.error(ex, () -> "Failed to send messages to '%s' topic".formatted(topicName)))
|
||||
.doOnNext(msgId -> this.logger.trace(() -> "Sent messages to '%s' topic".formatted(topicName)));
|
||||
}
|
||||
// The flux has errored or is completed
|
||||
return messageFlux.thenMany(Flux.empty());
|
||||
|
||||
@@ -32,8 +32,7 @@ import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for
|
||||
* {@link org.springframework.pulsar.reactive.core.DefaultReactivePulsarConsumerFactory}
|
||||
* Tests for {@link DefaultReactivePulsarConsumerFactory}.
|
||||
*
|
||||
* @author Christophe Bornet
|
||||
* @author Chris Bono
|
||||
|
||||
@@ -30,8 +30,7 @@ import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for
|
||||
* {@link org.springframework.pulsar.reactive.core.DefaultReactivePulsarReaderFactory}
|
||||
* Tests for {@link DefaultReactivePulsarReaderFactory}.
|
||||
*
|
||||
* @author Christophe Bornet
|
||||
*/
|
||||
@@ -43,7 +42,7 @@ class DefaultReactiveMessageReaderFactoryTests {
|
||||
void createReader() {
|
||||
MutableReactiveMessageReaderSpec spec = new MutableReactiveMessageReaderSpec();
|
||||
spec.setReaderName("test-reader");
|
||||
org.springframework.pulsar.reactive.core.DefaultReactivePulsarReaderFactory<String> readerFactory = new org.springframework.pulsar.reactive.core.DefaultReactivePulsarReaderFactory<>(
|
||||
DefaultReactivePulsarReaderFactory<String> readerFactory = new DefaultReactivePulsarReaderFactory<>(
|
||||
AdaptedReactivePulsarClientFactory.create((PulsarClient) null), spec);
|
||||
|
||||
ReactiveMessageReader<String> reader = readerFactory.createReader(schema);
|
||||
@@ -56,7 +55,7 @@ class DefaultReactiveMessageReaderFactoryTests {
|
||||
void createReaderWithCustomizer() {
|
||||
MutableReactiveMessageReaderSpec spec = new MutableReactiveMessageReaderSpec();
|
||||
spec.setReaderName("test-reader");
|
||||
org.springframework.pulsar.reactive.core.DefaultReactivePulsarReaderFactory<String> readerFactory = new DefaultReactivePulsarReaderFactory<>(
|
||||
DefaultReactivePulsarReaderFactory<String> readerFactory = new DefaultReactivePulsarReaderFactory<>(
|
||||
AdaptedReactivePulsarClientFactory.create((PulsarClient) null), spec);
|
||||
|
||||
ReactiveMessageReader<String> reader = readerFactory.createReader(schema,
|
||||
|
||||
@@ -50,7 +50,7 @@ import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* Tests for {@link org.springframework.pulsar.reactive.core.ReactivePulsarTemplate}.
|
||||
* Tests for {@link ReactivePulsarTemplate}.
|
||||
*
|
||||
* @author Christophe Bornet
|
||||
* @author Chris Bono
|
||||
|
||||
@@ -37,7 +37,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.pulsar.client.api.DeadLetterPolicy;
|
||||
import org.apache.pulsar.client.api.RedeliveryBackoff;
|
||||
|
||||
@@ -119,7 +118,7 @@ import org.springframework.util.StringUtils;
|
||||
public class PulsarListenerAnnotationBeanPostProcessor<V>
|
||||
implements BeanPostProcessor, Ordered, ApplicationContextAware, InitializingBean, SmartInitializingSingleton {
|
||||
|
||||
private final LogAccessor logger = new LogAccessor(LogFactory.getLog(getClass()));
|
||||
private final LogAccessor logger = new LogAccessor(this.getClass());
|
||||
|
||||
/**
|
||||
* The bean name of the default
|
||||
@@ -552,7 +551,7 @@ public class PulsarListenerAnnotationBeanPostProcessor<V>
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("@PulsarListener can't resolve '%s' as a String", resolvedValue));
|
||||
"@PulsarListener can't resolve '%s' as a String".formatted(resolvedValue));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,12 +578,12 @@ public class PulsarListenerAnnotationBeanPostProcessor<V>
|
||||
ReflectionUtils.handleReflectionException(ex);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
throw new IllegalStateException(String.format(
|
||||
"@PulsarListener method '%s' found on bean target class '%s', "
|
||||
+ "but not found in any interface(s) for bean JDK proxy. Either "
|
||||
+ "pull the method up to an interface or switch to subclass (CGLIB) "
|
||||
+ "proxies by setting proxy-target-class/proxyTargetClass " + "attribute to 'true'",
|
||||
method.getName(), method.getDeclaringClass().getSimpleName()), ex);
|
||||
throw new IllegalStateException("@PulsarListener method '%s' found on bean target class '%s', "
|
||||
+ "but not found in any interface(s) for bean JDK proxy. Either "
|
||||
+ "pull the method up to an interface or switch to subclass (CGLIB) "
|
||||
+ "proxies by setting proxy-target-class/proxyTargetClass "
|
||||
+ "attribute to 'true'".formatted(method.getName(), method.getDeclaringClass().getSimpleName()),
|
||||
ex);
|
||||
}
|
||||
}
|
||||
return method;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.pulsar.config;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.pulsar.client.api.PulsarClient;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
@@ -32,7 +31,7 @@ import org.springframework.lang.Nullable;
|
||||
*/
|
||||
public class PulsarClientFactoryBean extends AbstractFactoryBean<PulsarClient> {
|
||||
|
||||
private final LogAccessor logger = new LogAccessor(LogFactory.getLog(this.getClass()));
|
||||
private final LogAccessor logger = new LogAccessor(this.getClass());
|
||||
|
||||
private final PulsarClientConfiguration pulsarClientConfiguration;
|
||||
|
||||
|
||||
@@ -84,8 +84,8 @@ public class CachingPulsarProducerFactory<T> extends DefaultPulsarProducerFactor
|
||||
.maximumSize(cacheMaximumSize).initialCapacity(cacheInitialCapacity)
|
||||
.scheduler(Scheduler.systemScheduler()).evictionListener(
|
||||
(RemovalListener<ProducerCacheKey<T>, Producer<T>>) (producerCacheKey, producer, cause) -> {
|
||||
this.logger.debug(() -> String.format("Producer %s evicted from cache due to %s",
|
||||
ProducerUtils.formatProducer(producer), cause));
|
||||
this.logger.debug(() -> "Producer %s evicted from cache due to %s"
|
||||
.formatted(ProducerUtils.formatProducer(producer), cause));
|
||||
closeProducer(producer);
|
||||
})
|
||||
.build();
|
||||
@@ -106,9 +106,8 @@ public class CachingPulsarProducerFactory<T> extends DefaultPulsarProducerFactor
|
||||
try {
|
||||
Producer<T> producer = super.doCreateProducer(schema, topic, encryptionKeys, customizers);
|
||||
return new ProducerWithCloseCallback<>(producer,
|
||||
(p) -> this.logger
|
||||
.trace(() -> String.format("Client closed producer %s but will skip actual closing",
|
||||
ProducerUtils.formatProducer(producer))));
|
||||
(p) -> this.logger.trace(() -> "Client closed producer %s but will skip actual closing"
|
||||
.formatted(ProducerUtils.formatProducer(producer))));
|
||||
}
|
||||
catch (PulsarClientException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
@@ -129,8 +128,8 @@ public class CachingPulsarProducerFactory<T> extends DefaultPulsarProducerFactor
|
||||
actualProducer = wrappedProducer.getActualProducer();
|
||||
}
|
||||
if (actualProducer == null) {
|
||||
this.logger.warn(() -> String.format("Unable to get actual producer for %s - will skip closing it",
|
||||
ProducerUtils.formatProducer(producer)));
|
||||
this.logger.warn(() -> "Unable to get actual producer for %s - will skip closing it"
|
||||
.formatted(ProducerUtils.formatProducer(producer)));
|
||||
return;
|
||||
}
|
||||
ProducerUtils.closeProducerAsync(actualProducer, this.logger);
|
||||
|
||||
@@ -99,7 +99,7 @@ public class DefaultPulsarProducerFactory<T> implements PulsarProducerFactory<T>
|
||||
@Nullable Collection<String> encryptionKeys, @Nullable List<ProducerBuilderCustomizer<T>> customizers)
|
||||
throws PulsarClientException {
|
||||
String resolvedTopic = ProducerUtils.resolveTopicName(topic, this);
|
||||
this.logger.trace(() -> String.format("Creating producer for '%s' topic", resolvedTopic));
|
||||
this.logger.trace(() -> "Creating producer for '%s' topic".formatted(resolvedTopic));
|
||||
ProducerBuilder<T> producerBuilder = this.pulsarClient.newProducer(schema);
|
||||
|
||||
Map<String, Object> config = new HashMap<>(this.producerConfig);
|
||||
|
||||
@@ -35,7 +35,7 @@ final class ProducerUtils {
|
||||
}
|
||||
|
||||
static <T> String formatProducer(Producer<T> producer) {
|
||||
return String.format("(%s:%s)", producer.getProducerName(), producer.getTopic());
|
||||
return "(%s:%s)".formatted(producer.getProducerName(), producer.getTopic());
|
||||
}
|
||||
|
||||
static <T> String resolveTopicName(@Nullable String userSpecifiedTopic, PulsarProducerFactory<T> producerFactory) {
|
||||
@@ -49,7 +49,7 @@ final class ProducerUtils {
|
||||
|
||||
static <T> void closeProducerAsync(Producer<T> producer, LogAccessor logger) {
|
||||
producer.closeAsync().exceptionally(e -> {
|
||||
logger.warn(e, () -> String.format("Failed to close producer %s", ProducerUtils.formatProducer(producer)));
|
||||
logger.warn(e, () -> "Failed to close producer %s".formatted(ProducerUtils.formatProducer(producer)));
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.pulsar.client.admin.PulsarAdmin;
|
||||
import org.apache.pulsar.client.admin.PulsarAdminBuilder;
|
||||
import org.apache.pulsar.client.admin.PulsarAdminException;
|
||||
@@ -52,7 +51,7 @@ import org.springframework.util.StringUtils;
|
||||
public class PulsarAdministration
|
||||
implements ApplicationContextAware, SmartInitializingSingleton, PulsarAdministrationOperations {
|
||||
|
||||
private final LogAccessor logger = new LogAccessor(LogFactory.getLog(this.getClass()));
|
||||
private final LogAccessor logger = new LogAccessor(this.getClass());
|
||||
|
||||
private final PulsarAdminBuilder adminBuilder;
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ public class PulsarTemplate<T> implements PulsarOperations<T>, BeanNameAware {
|
||||
String defaultTopic = Objects.toString(this.producerFactory.getProducerConfig().get("topicName"), null);
|
||||
String topicName = this.topicResolver.resolveTopic(topic, message, () -> defaultTopic).orElseThrow(
|
||||
() -> new IllegalArgumentException("Topic must be specified when no default topic is configured"));
|
||||
this.logger.trace(() -> String.format("Sending msg to '%s' topic", topicName));
|
||||
this.logger.trace(() -> "Sending msg to '%s' topic".formatted(topicName));
|
||||
|
||||
PulsarMessageSenderContext senderContext = PulsarMessageSenderContext.newContext(topicName, this.beanName);
|
||||
Observation observation = newObservation(senderContext);
|
||||
@@ -201,11 +201,11 @@ public class PulsarTemplate<T> implements PulsarOperations<T>, BeanNameAware {
|
||||
|
||||
return messageBuilder.sendAsync().whenComplete((msgId, ex) -> {
|
||||
if (ex == null) {
|
||||
this.logger.trace(() -> String.format("Sent msg to '%s' topic", topicName));
|
||||
this.logger.trace(() -> "Sent msg to '%s' topic".formatted(topicName));
|
||||
observation.stop();
|
||||
}
|
||||
else {
|
||||
this.logger.error(ex, () -> String.format("Failed to send msg to '%s' topic", topicName));
|
||||
this.logger.error(ex, () -> "Failed to send msg to '%s' topic".formatted(topicName));
|
||||
observation.error(ex);
|
||||
observation.stop();
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ public class PulsarFunctionAdministration implements SmartLifecycle {
|
||||
private String buildLogMsg(PulsarFunctionOperations<?> function, boolean isUpdate, boolean isUrlArchive) {
|
||||
// <verb> '<name>' <type> (using (url|local) archive: <archive>
|
||||
// Ex: Updating 'Uppercase' function (using url archive: sink://foo.bar)
|
||||
return String.format("%s %s (using %s archive: %s)", isUpdate ? "Updating" : "Creating", functionDesc(function),
|
||||
return "%s %s (using %s archive: %s)".formatted(isUpdate ? "Updating" : "Creating", functionDesc(function),
|
||||
isUrlArchive ? "url" : "local", function.archive());
|
||||
}
|
||||
|
||||
@@ -289,15 +289,15 @@ public class PulsarFunctionAdministration implements SmartLifecycle {
|
||||
private Optional<Exception> enforceStopPolicyOnFunction(PulsarFunctionOperations<?> function, PulsarAdmin admin) {
|
||||
return switch (function.stopPolicy()) {
|
||||
case NONE -> {
|
||||
this.logger.info(() -> String.format("No stop policy for %s - leaving alone", functionDesc(function)));
|
||||
this.logger.info(() -> "No stop policy for %s - leaving alone".formatted(functionDesc(function)));
|
||||
yield Optional.empty();
|
||||
}
|
||||
case STOP -> {
|
||||
this.logger.info(() -> String.format("Stopping %s", functionDesc(function)));
|
||||
this.logger.info(() -> "Stopping %s".formatted(functionDesc(function)));
|
||||
yield safeInvoke(() -> function.stop(admin));
|
||||
}
|
||||
case DELETE -> {
|
||||
this.logger.info(() -> String.format("Deleting %s", functionDesc(function)));
|
||||
this.logger.info(() -> "Deleting %s".formatted(functionDesc(function)));
|
||||
yield safeInvoke(() -> function.delete(admin));
|
||||
}
|
||||
};
|
||||
@@ -314,7 +314,7 @@ public class PulsarFunctionAdministration implements SmartLifecycle {
|
||||
}
|
||||
|
||||
private String functionDesc(PulsarFunctionOperations<?> function) {
|
||||
return String.format("'%s' %s", function.name(), function.type().toString().toLowerCase());
|
||||
return "'%s' %s".formatted(function.name(), function.type().toString().toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,6 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.pulsar.client.api.BatchReceivePolicy;
|
||||
import org.apache.pulsar.client.api.Consumer;
|
||||
import org.apache.pulsar.client.api.DeadLetterPolicy;
|
||||
@@ -512,9 +511,11 @@ public class DefaultPulsarMessageListenerContainer<T> extends AbstractPulsarMess
|
||||
this.nackableMessages.add(message.getMessageId());
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException(String.format(
|
||||
"Exception occurred and message %s was not auto-nacked; switch to AckMode BATCH or RECORD to enable auto-nacks",
|
||||
message.getMessageId()), e);
|
||||
throw new IllegalStateException(
|
||||
|
||||
"Exception occurred and message %s was not auto-nacked; switch to AckMode BATCH or RECORD to enable auto-nacks"
|
||||
.formatted(message.getMessageId()),
|
||||
e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -672,7 +673,7 @@ public class DefaultPulsarMessageListenerContainer<T> extends AbstractPulsarMess
|
||||
|
||||
private static abstract class AbstractAcknowledgement implements Acknowledgement {
|
||||
|
||||
private static final LogAccessor logger = new LogAccessor(LogFactory.getLog(AbstractAcknowledgement.class));
|
||||
private static final LogAccessor logger = new LogAccessor(AbstractAcknowledgement.class);
|
||||
|
||||
protected final Consumer<?> consumer;
|
||||
|
||||
@@ -691,7 +692,7 @@ public class DefaultPulsarMessageListenerContainer<T> extends AbstractPulsarMess
|
||||
}
|
||||
catch (PulsarClientException pce) {
|
||||
AbstractAcknowledgement.logger.warn(pce,
|
||||
() -> String.format("Acknowledgment failed for message: [%s]", messageId));
|
||||
() -> "Acknowledgment failed for message: [%s]".formatted(messageId));
|
||||
consumer.negativeAcknowledge(messageId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.pulsar.listener;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.pulsar.client.api.Consumer;
|
||||
import org.apache.pulsar.client.api.Message;
|
||||
import org.apache.pulsar.client.api.PulsarClientException;
|
||||
@@ -35,7 +34,7 @@ import org.springframework.pulsar.core.PulsarOperations;
|
||||
*/
|
||||
public class PulsarDeadLetterPublishingRecoverer<T> implements PulsarMessageRecovererFactory<T> {
|
||||
|
||||
protected final LogAccessor logger = new LogAccessor(LogFactory.getLog(this.getClass()));
|
||||
protected final LogAccessor logger = new LogAccessor(this.getClass());
|
||||
|
||||
/**
|
||||
* TODO: Move this to a common constants class.
|
||||
|
||||
Reference in New Issue
Block a user