Skip to content

Commit b91e989

Browse files
committed
JMS CachingConnectionFactory never caches consumers for temporary queues and topics
1 parent e8fc90c commit b91e989

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

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

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,6 +34,8 @@
3434
import javax.jms.MessageProducer;
3535
import javax.jms.QueueSession;
3636
import javax.jms.Session;
37+
import javax.jms.TemporaryQueue;
38+
import javax.jms.TemporaryTopic;
3739
import javax.jms.Topic;
3840
import javax.jms.TopicSession;
3941

@@ -323,16 +325,18 @@ else if (isCacheConsumers()) {
323325
// let raw JMS invocation throw an exception if Destination (i.e. args[0]) is null
324326
if ((methodName.equals("createConsumer") || methodName.equals("createReceiver") ||
325327
methodName.equals("createSubscriber"))) {
326-
if (args[0] != null) {
327-
return getCachedConsumer((Destination) args[0],
328+
Destination dest = (Destination) args[0];
329+
if (dest != null && !(dest instanceof TemporaryQueue || dest instanceof TemporaryTopic)) {
330+
return getCachedConsumer(dest,
328331
(args.length > 1 ? (String) args[1] : null),
329332
(args.length > 2 && (Boolean) args[2]),
330333
null);
331334
}
332335
}
333336
else if (methodName.equals("createDurableSubscriber")) {
334-
if (args[0] != null) {
335-
return getCachedConsumer((Destination) args[0],
337+
Destination dest = (Destination) args[0];
338+
if (dest != null) {
339+
return getCachedConsumer(dest,
336340
(args.length > 2 ? (String) args[2] : null),
337341
(args.length > 3 && (Boolean) args[3]),
338342
(String) args[1]);

0 commit comments

Comments
 (0)