From 72590dbb21048245e0af2ea507e7b0896330e89d Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 8 Jan 2018 00:26:29 +0100 Subject: [PATCH] CachingConnectionFactory does not cache producer for temporary queue/topic Issue: SPR-16353 --- .../jms/connection/CachingConnectionFactory.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java b/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java index bd8f7130014..f8f8930622c 100644 --- a/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java +++ b/spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -325,7 +325,10 @@ public class CachingConnectionFactory extends SingleConnectionFactory { if (isCacheProducers() && (methodName.equals("createProducer") || methodName.equals("createSender") || methodName.equals("createPublisher"))) { // Destination argument being null is ok for a producer - return getCachedProducer((Destination) args[0]); + Destination dest = (Destination) args[0]; + if (!(dest instanceof TemporaryQueue || dest instanceof TemporaryTopic)) { + return getCachedProducer(dest); + } } else if (isCacheConsumers()) { // let raw JMS invocation throw an exception if Destination (i.e. args[0]) is null