Skip to content

Commit 3ba42d5

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 18edc93 commit 3ba42d5

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)