mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 08:24:13 +00:00
Avoid endless re-interruption loop on shutdown
Closes gh-36506
This commit is contained in:
+6
@@ -737,14 +737,20 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
|
||||
long receiveTimeout = getReceiveTimeout();
|
||||
long waitStartTime = System.currentTimeMillis();
|
||||
int waitCount = 0;
|
||||
boolean interrupted = false;
|
||||
while (this.activeInvokerCount > 0) {
|
||||
if (waitCount > 0 && !isAcceptMessagesWhileStopping() &&
|
||||
System.currentTimeMillis() - waitStartTime >= receiveTimeout) {
|
||||
// Unexpectedly some invokers are still active after the receive timeout period
|
||||
// -> interrupt remaining receive attempts since we'd reject the messages anyway
|
||||
if (interrupted) {
|
||||
// Already interrupted -> not worth waiting any longer...
|
||||
break;
|
||||
}
|
||||
for (AsyncMessageListenerInvoker scheduledInvoker : this.scheduledInvokers) {
|
||||
scheduledInvoker.interruptIfNecessary();
|
||||
}
|
||||
interrupted = true;
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Still waiting for shutdown of " + this.activeInvokerCount +
|
||||
|
||||
Reference in New Issue
Block a user