From 6c0e67c6674cce8384a3d08a7119c2651ceb06ba Mon Sep 17 00:00:00 2001 From: kjy1994 Date: Thu, 20 Mar 2025 00:17:37 +0900 Subject: [PATCH] #3810 Move the logging statement after the conditional statement. Signed-off-by: kjy1994 --- .../springframework/kafka/test/utils/KafkaTestUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-kafka-test/src/main/java/org/springframework/kafka/test/utils/KafkaTestUtils.java b/spring-kafka-test/src/main/java/org/springframework/kafka/test/utils/KafkaTestUtils.java index b7c7af65ab..315d18cb09 100644 --- a/spring-kafka-test/src/main/java/org/springframework/kafka/test/utils/KafkaTestUtils.java +++ b/spring-kafka-test/src/main/java/org/springframework/kafka/test/utils/KafkaTestUtils.java @@ -368,14 +368,14 @@ public static ConsumerRecords getRecords(Consumer consumer, D do { long t1 = System.currentTimeMillis(); ConsumerRecords received = consumer.poll(Duration.ofMillis(remaining)); + if (received == null) { + throw new IllegalStateException("null received from consumer.poll()"); + } logger.debug(() -> "Received: " + received.count() + ", " + received.partitions().stream() .flatMap(p -> received.records(p).stream()) // map to same format as send metadata toString() .map(r -> r.topic() + "-" + r.partition() + "@" + r.offset()).toList()); - if (received == null) { - throw new IllegalStateException("null received from consumer.poll()"); - } if (minRecords < 0) { return received; }