Skip to content

Commit d8a2672

Browse files
committed
CachingConnectionFactory makes its Session caching inactive during reset
Issue: SPR-16450 (cherry picked from commit b6ecfcf)
1 parent b125b5e commit d8a2672

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ public boolean isCacheConsumers() {
186186
@Override
187187
public void resetConnection() {
188188
this.active = false;
189+
189190
synchronized (this.cachedSessions) {
190191
for (LinkedList<Session> sessionList : this.cachedSessions.values()) {
191192
synchronized (sessionList) {
@@ -201,17 +202,22 @@ public void resetConnection() {
201202
}
202203
this.cachedSessions.clear();
203204
}
204-
this.active = true;
205205

206206
// Now proceed with actual closing of the shared Connection...
207207
super.resetConnection();
208+
209+
this.active = true;
208210
}
209211

210212
/**
211213
* Checks for a cached Session for the given mode.
212214
*/
213215
@Override
214216
protected Session getSession(Connection con, Integer mode) throws JMSException {
217+
if (!this.active) {
218+
return null;
219+
}
220+
215221
LinkedList<Session> sessionList;
216222
synchronized (this.cachedSessions) {
217223
sessionList = this.cachedSessions.get(mode);

0 commit comments

Comments
 (0)