Skip to content

Commit 8744982

Browse files
committed
Clear remaining invoker resources when releasing shared Connection
Closes gh-35932 (cherry picked from commit 3ccb078)
1 parent 2144813 commit 8744982

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
@@ -1431,6 +1438,7 @@ private void decreaseActiveInvokerCount() {
14311438
if (activeInvokerCount == 0) {
14321439
if (!isRunning()) {
14331440
// Proactively release shared Connection when stopped.
1441+
clearResourcesInScheduledInvokers();
14341442
releaseSharedConnection();
14351443
}
14361444
if (stopCallback != null) {

0 commit comments

Comments
 (0)