From cff92363f89df3d09b5f2eef56449540d18c00f5 Mon Sep 17 00:00:00 2001 From: Kim JaeYeon <48614095+ghgh415263@users.noreply.github.com> Date: Fri, 23 May 2025 01:54:22 +0900 Subject: [PATCH] GH-3916: Delete redundant null check Fixes: https://github.com/spring-projects/spring-kafka/pull/3916 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 05bf8274..c0fe33e7 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 @@ import org.springframework.util.StringUtils; * @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 class DefaultKafkaProducerFactory extends KafkaResourceFactory @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 {