From 8d26ba50074da0c85ff8bc4c6f7ac729c0338eb7 Mon Sep 17 00:00:00 2001 From: JaeYeon Kim Date: Fri, 23 May 2025 01:39:20 +0900 Subject: [PATCH] #3915 Delete redundant null check Signed-off-by: JaeYeon Kim --- .../kafka/core/DefaultKafkaProducerFactory.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/spring-kafka/src/main/java/org/springframework/kafka/core/DefaultKafkaProducerFactory.java b/spring-kafka/src/main/java/org/springframework/kafka/core/DefaultKafkaProducerFactory.java index 05bf827480..c0fe33e720 100644 --- a/spring-kafka/src/main/java/org/springframework/kafka/core/DefaultKafkaProducerFactory.java +++ b/spring-kafka/src/main/java/org/springframework/kafka/core/DefaultKafkaProducerFactory.java @@ -116,6 +116,7 @@ * @author Thomas Strauß * @author Adrian Gygax * @author Soby Chacko + * @author Jaeyeon Kim */ public class DefaultKafkaProducerFactory extends KafkaResourceFactory implements ProducerFactory, ApplicationContextAware, @@ -1181,13 +1182,11 @@ public void commitTransaction() throws ProducerFencedException { @Override public void abortTransaction() throws ProducerFencedException { - LOGGER.debug(() -> toString() + " abortTransaction()"); - if (this.producerFailed != null) { - LOGGER.debug(() -> { - String message = this.producerFailed == null ? "" : this.producerFailed.getMessage(); - return "abortTransaction ignored - previous txFailed: " + message - + ": " + this; - }); + Exception producerFailedToUse = this.producerFailed; + LOGGER.debug(() -> this + " abortTransaction()"); + if (producerFailedToUse != null) { + LOGGER.debug(() -> "abortTransaction ignored - previous txFailed: " + producerFailedToUse.getMessage() + + ": " + this); } else { try {