Skip to content

Commit 5747b50

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 003432a commit 5747b50

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
@@ -1096,6 +1096,9 @@ protected void pollAndInvoke() {
10961096
}
10971097
pauseConsumerIfNecessary();
10981098
this.lastPoll = System.currentTimeMillis();
1099+
if (!isRunning()) {
1100+
return;
1101+
}
10991102
this.polling.set(true);
11001103
ConsumerRecords<K, V> records = doPoll();
11011104
if (!this.polling.compareAndSet(true, false) && records != null) {

0 commit comments

Comments
 (0)