diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2015-02-21 13:59:32 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2015-02-21 13:59:32 +0000 |
| commit | 27942ce9550fe965c566c58127c1db339459c956 (patch) | |
| tree | 31446b293a544aaca873d8358aa896cd3914f537 | |
| parent | 09e4929f78d29253d1f1baa5c8d1bb4714b9f6b9 (diff) | |
| download | qpid-python-27942ce9550fe965c566c58127c1db339459c956.tar.gz | |
QPID-6404 : Be lenient in receiving invalid messages, send AmqpValue(null) for the empty message
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1661364 13f79535-47bb-0310-9956-ffa450edef68
4 files changed, 20 insertions, 17 deletions
diff --git a/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/AmqpMessageImpl.java b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/AmqpMessageImpl.java index 9d0ebc1474..0afbb5c56f 100644 --- a/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/AmqpMessageImpl.java +++ b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/AmqpMessageImpl.java @@ -26,10 +26,9 @@ import java.util.List; import java.util.ListIterator; import org.apache.qpid.amqp_1_0.jms.AmqpMessage; -import org.apache.qpid.amqp_1_0.type.Binary; import org.apache.qpid.amqp_1_0.type.Section; +import org.apache.qpid.amqp_1_0.type.messaging.AmqpValue; import org.apache.qpid.amqp_1_0.type.messaging.ApplicationProperties; -import org.apache.qpid.amqp_1_0.type.messaging.Data; import org.apache.qpid.amqp_1_0.type.messaging.DeliveryAnnotations; import org.apache.qpid.amqp_1_0.type.messaging.Footer; import org.apache.qpid.amqp_1_0.type.messaging.Header; @@ -39,7 +38,7 @@ import org.apache.qpid.amqp_1_0.type.messaging.Properties; public class AmqpMessageImpl extends MessageImpl implements AmqpMessage { private static final List<Section> EMPTY_MESSAGE = - Collections.<Section>singletonList(new Data(new Binary(new byte[0]))); + Collections.<Section>singletonList(new AmqpValue(null)); private List<Section> _sections; protected AmqpMessageImpl(Header header, diff --git a/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageFactory.java b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageFactory.java index d120e4eadf..ef48e2a8a5 100644 --- a/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageFactory.java +++ b/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageFactory.java @@ -226,6 +226,13 @@ class MessageFactory messageAnnotations, properties,appProperties,body,footer, _session); } } + else if(body.size() == 0) + { + message = new AmqpMessageImpl(header, + deliveryAnnotations, + messageAnnotations, properties,appProperties, + Collections.<Section>singletonList(new AmqpValue(null)),footer, _session); + } else { message = new AmqpMessageImpl(header, diff --git a/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Message.java b/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Message.java index 212342cd96..48dbf13f67 100644 --- a/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Message.java +++ b/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Message.java @@ -117,7 +117,12 @@ public class Message public Message(Collection<Section> sections) { - _payload.addAll(validateOrReorder(sections)); + this(sections, false); + } + + public Message(Collection<Section> sections, boolean validate) + { + _payload.addAll(validate ? validateOrReorder(sections) : sections); } public Message(Section section) @@ -214,7 +219,8 @@ public class Message while(it.hasNext()) { Collection<Class<? extends Section>> validSections = VALID_NEXT_SECTIONS.get(previousSection); - Class<? extends Section> sectionClass = it.next().getClass(); + Section next = it.next(); + Class<? extends Section> sectionClass = next.getClass(); if(validSections == null || !validSections.contains(sectionClass)) { return false; diff --git a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueConstructor.java b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueConstructor.java index 2000880361..30de72604b 100644 --- a/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueConstructor.java +++ b/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueConstructor.java @@ -25,8 +25,8 @@ package org.apache.qpid.amqp_1_0.type.messaging.codec; import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructor; import org.apache.qpid.amqp_1_0.codec.DescribedTypeConstructorRegistry; -import org.apache.qpid.amqp_1_0.type.*; -import org.apache.qpid.amqp_1_0.type.messaging.*; +import org.apache.qpid.amqp_1_0.type.Symbol; +import org.apache.qpid.amqp_1_0.type.UnsignedLong; import org.apache.qpid.amqp_1_0.type.messaging.AmqpValue; public class AmqpValueConstructor extends DescribedTypeConstructor<AmqpValue> @@ -49,16 +49,7 @@ public class AmqpValueConstructor extends DescribedTypeConstructor<AmqpValue> public AmqpValue construct(Object underlying) { - - if(underlying instanceof Object) - { - return new AmqpValue((Object)underlying); - } - else - { - // TODO - error - return null; - } + return new AmqpValue(underlying); } |
