qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject [3/4] git commit: fix facade copy when ttl override value exists
Date Wed, 01 Oct 2014 15:24:04 GMT
fix facade copy when ttl override value exists


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/d10da2c0
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/d10da2c0
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/d10da2c0

Branch: refs/heads/master
Commit: d10da2c060891ae2a3470596b6869047ee82bdb6
Parents: d3b311f
Author: Robert Gemmell <robbie@apache.org>
Authored: Wed Oct 1 15:49:47 2014 +0100
Committer: Robert Gemmell <robbie@apache.org>
Committed: Wed Oct 1 15:49:47 2014 +0100

----------------------------------------------------------------------
 .../amqp/message/AmqpJmsMessageFacade.java      | 20 +++++++++++++++-----
 .../amqp/message/AmqpJmsMessageFacadeTest.java  | 14 ++++++++++++++
 2 files changed, 29 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d10da2c0/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
index cc0c025..afc3623 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacade.java
@@ -70,7 +70,7 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade {
     private JmsDestination destination;
     private JmsDestination consumerDestination;
 
-    private Long syntheticTTL;
+    private Long syntheticExpiration;
 
     /**
      * Used to record the value of JMS_AMQP_TTL property
@@ -119,7 +119,7 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade {
         Long ttl = message.getTtl();
         Long absoluteExpiryTime = getAbsoluteExpiryTime();
         if (absoluteExpiryTime == null && ttl != null) {
-            syntheticTTL = System.currentTimeMillis() + ttl;
+            syntheticExpiration = System.currentTimeMillis() + ttl;
         }
     }
 
@@ -249,13 +249,23 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade {
         if (consumerDestination != null) {
             target.consumerDestination = consumerDestination;
         }
+
         if (destination != null) {
             target.setDestination(destination);
         }
+
         if (replyTo != null) {
             target.setReplyTo(replyTo);
         }
 
+        if (syntheticExpiration != null) {
+            target.syntheticExpiration = syntheticExpiration;
+        }
+
+        if (userSpecifiedTTL != null) {
+            target.userSpecifiedTTL = userSpecifiedTTL;
+        }
+
         Message targetMsg = target.getAmqpMessage();
 
         if (message.getHeader() != null) {
@@ -549,8 +559,8 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade {
             return absoluteExpiry;
         }
 
-        if (syntheticTTL != null) {
-            return syntheticTTL;
+        if (syntheticExpiration != null) {
+            return syntheticExpiration;
         }
 
         return 0;
@@ -558,7 +568,7 @@ public class AmqpJmsMessageFacade implements JmsMessageFacade {
 
     @Override
     public void setExpiration(long expiration) {
-        syntheticTTL = null;
+        syntheticExpiration = null;
 
         if (expiration != 0) {
             setAbsoluteExpiryTime(expiration);

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/d10da2c0/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
index df79cbb..b3c8af1 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsMessageFacadeTest.java
@@ -507,4 +507,18 @@ public class AmqpJmsMessageFacadeTest {
         assertEquals("APP-Prop-1-Value", copy.getProperty("APP-Prop-1"));
         assertEquals("APP-Prop-2-Value", copy.getProperty("APP-Prop-2"));
     }
+
+    @Test
+    public void testCopyMessageWithAmqpTtlSet() throws JMSException {
+        AmqpJmsMessageFacade source = createNewMessageFacade();
+
+        long amqpTtl = 17L;
+        source.setAmqpTimeToLive(amqpTtl);
+
+        AmqpJmsMessageFacade copy = source.copy();
+
+        // There should be one since AmqpTtl is used for an extended option
+        assertEquals(1, copy.getPropertyNames().size());
+        assertEquals(amqpTtl, copy.getProperty(AmqpMessageSupport.JMS_AMQP_TTL));
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message