Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 46017d9a2 -> 7d19676c1


[CXF-7008] Regression: CXF-5788 - JMS replyToDestination doesn't work

(cherry picked from commit 0f51e22bc7e13630aeac1996fba4d06e97dea37c)


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/7d19676c
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/7d19676c
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/7d19676c

Branch: refs/heads/3.1.x-fixes
Commit: 7d19676c18dd98b82be79bce79d9c82c302a7e11
Parents: 46017d9
Author: Tadayoshi Sato <sato.tadayo...@gmail.com>
Authored: Fri Aug 12 16:06:48 2016 +0900
Committer: Freeman Fang <freeman.f...@gmail.com>
Committed: Fri Aug 12 17:06:04 2016 +0800

----------------------------------------------------------------------
 .../apache/cxf/transport/jms/JMSConduit.java    |  2 +-
 .../cxf/transport/jms/JMSConfiguration.java     | 22 ++++++++++---
 .../cxf/systest/jms/JMSClientServerTest.java    | 34 ++++++++++++++++++++
 3 files changed, 53 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/7d19676c/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
----------------------------------------------------------------------
diff --git 
a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java 
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
index 1a8afc9..9088ba6 100644
--- 
a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
+++ 
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConduit.java
@@ -209,7 +209,7 @@ public class JMSConduit extends AbstractConduit implements 
JMSExchangeSender, Me
             String jmsMessageID = sendMessage(request, outMessage, 
replyToDestination, correlationId, closer,
                                               session);
             boolean useSyncReceive = ((correlationId == null || userCID != 
null) && !jmsConfig.isPubSubDomain())
-                || !replyToDestination.equals(staticReplyDestination);
+                || (!replyToDestination.equals(staticReplyDestination) && 
headers.getJMSReplyTo() != null);
             if (correlationId == null) {
                 correlationId = jmsMessageID;
                 correlationMap.put(correlationId, exchange);

http://git-wip-us.apache.org/repos/asf/cxf/blob/7d19676c/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
----------------------------------------------------------------------
diff --git 
a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
 
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
index 5dc0e31..46a0d95 100644
--- 
a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
+++ 
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
@@ -75,6 +75,7 @@ public class JMSConfiguration {
      * Destination name to send out as replyTo address in the message 
      */
     private String replyToDestination;
+    private volatile Destination replyToDestinationDest;
     private String messageType = JMSConstants.TEXT_MESSAGE_TYPE;
     private boolean pubSubDomain;
     private boolean replyPubSubDomain;
@@ -418,14 +419,27 @@ public class JMSConfiguration {
         }
         return resolver.resolveDestinationName(session, 
replyToDestinationName, pubSubDomain);
     }
-    
+
     public Destination getReplyToDestination(Session session, String 
userDestination) throws JMSException {
-        if (userDestination == null) {
+        if (userDestination != null) {
+            return destinationResolver.resolveDestinationName(session, 
userDestination, replyPubSubDomain);
+        }
+        if (replyToDestination == null) {
             return getReplyDestination(session);
         }
-        return destinationResolver.resolveDestinationName(session, 
userDestination, replyPubSubDomain);
+        Destination result = replyToDestinationDest;
+        if (result == null) {
+            synchronized (this) {
+                result = replyToDestinationDest;
+                if (result == null) {
+                    result = 
destinationResolver.resolveDestinationName(session, replyToDestination, 
replyPubSubDomain);
+                    replyToDestinationDest = result;
+                }
+            }
+        }
+        return result;
     }
-    
+
     public Destination getReplyDestination(Session session) throws 
JMSException {
         Destination result = replyDestinationDest;
         if (result == null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/7d19676c/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
----------------------------------------------------------------------
diff --git 
a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
 
b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
index 376e8a2..4efa891 100644
--- 
a/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
+++ 
b/systests/transport-jms/src/test/java/org/apache/cxf/systest/jms/JMSClientServerTest.java
@@ -33,6 +33,7 @@ import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Endpoint;
 import javax.xml.ws.Response;
 import javax.xml.ws.soap.AddressingFeature;
+import javax.xml.ws.soap.SOAPFaultException;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.cxf.Bus;
@@ -52,8 +53,11 @@ import org.apache.cxf.hello_world_jms.HelloWorldService;
 import org.apache.cxf.hello_world_jms.NoSuchCodeLitFault;
 import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
+import org.apache.cxf.transport.jms.JMSConfigFeature;
+import org.apache.cxf.transport.jms.JMSConfiguration;
 import org.apache.cxf.transport.jms.JMSConstants;
 import org.apache.cxf.transport.jms.JMSMessageHeadersType;
 import org.apache.cxf.transport.jms.JMSPropertyType;
@@ -609,4 +613,34 @@ public class JMSClientServerTest extends 
AbstractBusClientServerTestBase {
         ((Closeable)greeter).close();
     }
 
+    @Test(expected = SOAPFaultException.class)
+    public void testReplyAndReplyToDestinations() throws Exception {
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setWsdlLocation("classpath:/wsdl/jms_test.wsdl");
+        factory.setServiceName(new 
QName("http://cxf.apache.org/hello_world_jms";, "HelloWorldService"));
+        factory.setEndpointName(new 
QName("http://cxf.apache.org/hello_world_jms";, "HelloWorldPort"));
+        factory.setAddress("jms://");
+        JMSConfigFeature feature = new JMSConfigFeature();
+        JMSConfiguration config = new JMSConfiguration();
+        config.setConnectionFactory(new 
ActiveMQConnectionFactory(broker.getBrokerURL()));
+        config.setRequestURI("test.jmstransport.text");
+        config.setTargetDestination("test.jmstransport.text");
+        // replyDestination and replyToDestination intentionally differ in 
this test scenario
+        // replyDestination = Destination name to listen on for reply messages
+        config.setReplyDestination("test.jmstransport.text.reply");
+        // replyToDestination = Destination name to send out as replyTo 
address in the message
+        config.setReplyToDestination("test.jmstransport.text.replyTo");
+        config.setReceiveTimeout(1000L);
+        feature.setJmsConfig(config);
+        factory.getFeatures().add(feature);
+        HelloWorldPortType greeter = factory.create(HelloWorldPortType.class);
+
+        try {
+            greeter.greetMe("FooBar");
+            // Timeout exception should be thrown
+        } finally {
+            ((java.io.Closeable)greeter).close();
+        }
+    }
+
 }

Reply via email to