Skip to content

Commit feac8d2

Browse files
committed
Fix Shutdown Race Causing Test Delays
Don't poll the consumer if the container has already stopped. This causes excessive test run times. Local build time reduced from 7 minutes to less than 5.
1 parent 2f048be commit feac8d2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

spring-kafka/src/main/java/org/springframework/kafka/listener/KafkaMessageListenerContainer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,9 @@ protected void pollAndInvoke() {
10571057
}
10581058
pauseConsumerIfNecessary();
10591059
this.lastPoll = System.currentTimeMillis();
1060+
if (!isRunning()) {
1061+
return;
1062+
}
10601063
this.polling.set(true);
10611064
ConsumerRecords<K, V> records = doPoll();
10621065
if (!this.polling.compareAndSet(true, false) && records != null) {

0 commit comments

Comments
 (0)