Skip to content

Commit 3ccb078

Browse files
committed
Clear remaining invoker resources when releasing shared Connection
Closes gh-35932
1 parent 15c16d2 commit 3ccb078

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -757,10 +757,8 @@ protected void doShutdown() throws JMSException {
757757
}
758758
waitCount++;
759759
}
760-
// Clear remaining scheduled invokers, possibly left over as paused tasks
761-
for (AsyncMessageListenerInvoker scheduledInvoker : this.scheduledInvokers) {
762-
scheduledInvoker.clearResources();
763-
}
760+
// Clear remaining scheduled invokers, possibly left over as paused tasks.
761+
clearResourcesInScheduledInvokers();
764762
this.scheduledInvokers.clear();
765763
}
766764
catch (InterruptedException ex) {
@@ -910,6 +908,15 @@ private void scheduleNewInvoker() {
910908
}
911909
}
912910

911+
/**
912+
* Clear resources in scheduled invokers, even in case of paused tasks.
913+
*/
914+
private void clearResourcesInScheduledInvokers() {
915+
for (AsyncMessageListenerInvoker scheduledInvoker : this.scheduledInvokers) {
916+
scheduledInvoker.clearResources();
917+
}
918+
}
919+
913920
/**
914921
* Use a shared JMS Connection depending on the "cacheLevel" setting.
915922
* @see #setCacheLevel
@@ -1427,6 +1434,7 @@ private void decreaseActiveInvokerCount() {
14271434
if (activeInvokerCount == 0) {
14281435
if (!isRunning()) {
14291436
// Proactively release shared Connection when stopped.
1437+
clearResourcesInScheduledInvokers();
14301438
releaseSharedConnection();
14311439
}
14321440
if (stopCallback != null) {

0 commit comments

Comments
 (0)