Skip to content

Commit d9a42c9

Browse files
committed
Fix KafkaOutAdapterParserTests race condition
The `Future` for `Producer.send()` can be fulfilled before we return it (`isDone()`), so `KafkaTemplate` short-circuits with a `KafkaException`. * Modify `KafkaOutboundAdapterParserTests.testSyncMode()` to assert against `KafkaException` which may be thrown earlier then previously expected `KafkaProducerException` **Cherry-pick to `5.5.x`**
1 parent 1c461a3 commit d9a42c9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

spring-integration-kafka/src/test/java/org/springframework/integration/kafka/config/xml/KafkaOutboundAdapterParserTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import org.springframework.integration.MessageTimeoutException;
4141
import org.springframework.integration.kafka.outbound.KafkaProducerMessageHandler;
4242
import org.springframework.integration.test.util.TestUtils;
43-
import org.springframework.kafka.core.KafkaProducerException;
43+
import org.springframework.kafka.KafkaException;
4444
import org.springframework.kafka.core.KafkaTemplate;
4545
import org.springframework.kafka.core.ProducerFactory;
4646
import org.springframework.messaging.MessageHandlingException;
@@ -136,7 +136,7 @@ public void close(Duration timeout) {
136136

137137
assertThatExceptionOfType(MessageHandlingException.class)
138138
.isThrownBy(() -> handler.handleMessage(new GenericMessage<>("foo")))
139-
.withCauseInstanceOf(KafkaProducerException.class)
139+
.withCauseInstanceOf(KafkaException.class)
140140
.withRootCauseInstanceOf(RuntimeException.class)
141141
.withStackTraceContaining("Async Producer Mock exception");
142142

0 commit comments

Comments
 (0)