mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 16:39:29 +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 receiveTimeout = getReceiveTimeout();
|
||||||
long waitStartTime = System.currentTimeMillis();
|
long waitStartTime = System.currentTimeMillis();
|
||||||
int waitCount = 0;
|
int waitCount = 0;
|
||||||
|
boolean interrupted = false;
|
||||||
while (this.activeInvokerCount > 0) {
|
while (this.activeInvokerCount > 0) {
|
||||||
if (waitCount > 0 && !isAcceptMessagesWhileStopping() &&
|
if (waitCount > 0 && !isAcceptMessagesWhileStopping() &&
|
||||||
System.currentTimeMillis() - waitStartTime >= receiveTimeout) {
|
System.currentTimeMillis() - waitStartTime >= receiveTimeout) {
|
||||||
// Unexpectedly some invokers are still active after the receive timeout period
|
// Unexpectedly some invokers are still active after the receive timeout period
|
||||||
// -> interrupt remaining receive attempts since we'd reject the messages anyway
|
// -> 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) {
|
for (AsyncMessageListenerInvoker scheduledInvoker : this.scheduledInvokers) {
|
||||||
scheduledInvoker.interruptIfNecessary();
|
scheduledInvoker.interruptIfNecessary();
|
||||||
}
|
}
|
||||||
|
interrupted = true;
|
||||||
}
|
}
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Still waiting for shutdown of " + this.activeInvokerCount +
|
logger.debug("Still waiting for shutdown of " + this.activeInvokerCount +
|
||||||
|
|||||||
Reference in New Issue
Block a user