From b486ad3975502c152695c49cee89dcd79cc2c251 Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Fri, 27 Sep 2013 13:54:30 +0000 Subject: QPID-5184 : Setting message expiration to 0 should lead to the header property being unset - not being set as the empty string git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1526904 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/framing/BasicContentHeaderProperties.java | 108 +++++++++++++++++---- .../framing/BasicContentHeaderPropertiesTest.java | 3 + 2 files changed, 94 insertions(+), 17 deletions(-) (limited to 'java/common/src') diff --git a/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java b/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java index eb528159c0..366c8231a1 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java +++ b/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java @@ -388,7 +388,15 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setContentType(AMQShortString contentType) { - _propertyFlags |= (CONTENT_TYPE_MASK); + + if(contentType == null) + { + _propertyFlags &= (~CONTENT_TYPE_MASK); + } + else + { + _propertyFlags |= CONTENT_TYPE_MASK; + } _contentType = contentType; _encodedForm = null; } @@ -411,14 +419,19 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setEncoding(String encoding) { - _propertyFlags |= ENCODING_MASK; - _encoding = (encoding == null) ? null : AMQShortString.valueOf(encoding); - _encodedForm = null; + setEncoding(encoding == null ? null : AMQShortString.valueOf(encoding)); } public void setEncoding(AMQShortString encoding) { - _propertyFlags |= ENCODING_MASK; + if(encoding == null) + { + _propertyFlags &= (~ENCODING_MASK); + } + else + { + _propertyFlags |= ENCODING_MASK; + } _encoding = encoding; _encodedForm = null; } @@ -435,7 +448,14 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setHeaders(FieldTable headers) { - _propertyFlags |= HEADERS_MASK; + if(headers == null) + { + _propertyFlags &= (~HEADERS_MASK); + } + else + { + _propertyFlags |= HEADERS_MASK; + } _headers = headers; _encodedForm = null; } @@ -481,7 +501,14 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setCorrelationId(AMQShortString correlationId) { - _propertyFlags |= CORRELATION_ID_MASK; + if(correlationId == null) + { + _propertyFlags &= (~CORRELATION_ID_MASK); + } + else + { + _propertyFlags |= CORRELATION_ID_MASK; + } _correlationId = correlationId; _encodedForm = null; } @@ -503,7 +530,14 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setReplyTo(AMQShortString replyTo) { - _propertyFlags |= REPLY_TO_MASK; + if(replyTo == null) + { + _propertyFlags &= (~REPLY_TO_MASK); + } + else + { + _propertyFlags |= REPLY_TO_MASK; + } _replyTo = replyTo; _encodedForm = null; } @@ -515,7 +549,14 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setExpiration(long expiration) { - _propertyFlags |= EXPIRATION_MASK; + if(expiration == 0l) + { + _propertyFlags &= (~EXPIRATION_MASK); + } + else + { + _propertyFlags |= EXPIRATION_MASK; + } _expiration = expiration; _encodedForm = null; } @@ -532,14 +573,19 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setMessageId(String messageId) { - _propertyFlags |= MESSAGE_ID_MASK; - _messageId = (messageId == null) ? null : new AMQShortString(messageId); - _encodedForm = null; + setMessageId(messageId == null ? null : new AMQShortString(messageId)); } public void setMessageId(AMQShortString messageId) { - _propertyFlags |= MESSAGE_ID_MASK; + if(messageId == null) + { + _propertyFlags &= (~MESSAGE_ID_MASK); + } + else + { + _propertyFlags |= MESSAGE_ID_MASK; + } _messageId = messageId; _encodedForm = null; } @@ -573,7 +619,14 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setType(AMQShortString type) { - _propertyFlags |= TYPE_MASK; + if(type == null) + { + _propertyFlags &= (~TYPE_MASK); + } + else + { + _propertyFlags |= TYPE_MASK; + } _type = type; _encodedForm = null; } @@ -595,7 +648,14 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setUserId(AMQShortString userId) { - _propertyFlags |= USER_ID_MASK; + if(userId == null) + { + _propertyFlags &= (~USER_ID_MASK); + } + else + { + _propertyFlags |= USER_ID_MASK; + } _userId = userId; _encodedForm = null; } @@ -617,7 +677,14 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setAppId(AMQShortString appId) { - _propertyFlags |= APPLICATION_ID_MASK; + if(appId == null) + { + _propertyFlags &= (~APPLICATION_ID_MASK); + } + else + { + _propertyFlags |= APPLICATION_ID_MASK; + } _appId = appId; _encodedForm = null; } @@ -639,7 +706,14 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti public void setClusterId(AMQShortString clusterId) { - _propertyFlags |= CLUSTER_ID_MASK; + if(clusterId == null) + { + _propertyFlags &= (~CLUSTER_ID_MASK); + } + else + { + _propertyFlags |= CLUSTER_ID_MASK; + } _clusterId = clusterId; _encodedForm = null; } diff --git a/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java b/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java index 1a2c5283b0..4902e8ad64 100644 --- a/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java +++ b/java/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java @@ -144,6 +144,9 @@ public class BasicContentHeaderPropertiesTest extends TestCase long expiration = 999999999; _testProperties.setExpiration(expiration); assertEquals(expiration, _testProperties.getExpiration()); + expiration = 0l; + _testProperties.setExpiration(expiration); + assertEquals(expiration, _testProperties.getExpiration()); } public void testSetGetMessageId() -- cgit v1.2.1