Author: rgodfrey
Date: Sat Feb 21 13:59:32 2015
New Revision: 1661364
URL: http://svn.apache.org/r1661364
Log:
QPID-6404 : Be lenient in receiving invalid messages, send AmqpValue(null) for
the empty message
Modified:
qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/AmqpMessageImpl.java
qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageFactory.java
qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Message.java
qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueConstructor.java
Modified:
qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/AmqpMessageImpl.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/AmqpMessageImpl.java?rev=1661364&r1=1661363&r2=1661364&view=diff
==============================================================================
---
qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/AmqpMessageImpl.java
(original)
+++
qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/AmqpMessageImpl.java
Sat Feb 21 13:59:32 2015
@@ -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.mes
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,
Modified:
qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageFactory.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageFactory.java?rev=1661364&r1=1661363&r2=1661364&view=diff
==============================================================================
---
qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageFactory.java
(original)
+++
qpid/trunk/qpid/java/amqp-1-0-client-jms/src/main/java/org/apache/qpid/amqp_1_0/jms/impl/MessageFactory.java
Sat Feb 21 13:59:32 2015
@@ -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,
Modified:
qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Message.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Message.java?rev=1661364&r1=1661363&r2=1661364&view=diff
==============================================================================
---
qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Message.java
(original)
+++
qpid/trunk/qpid/java/amqp-1-0-client/src/main/java/org/apache/qpid/amqp_1_0/client/Message.java
Sat Feb 21 13:59:32 2015
@@ -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;
Modified:
qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueConstructor.java
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueConstructor.java?rev=1661364&r1=1661363&r2=1661364&view=diff
==============================================================================
---
qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueConstructor.java
(original)
+++
qpid/trunk/qpid/java/amqp-1-0-common/src/main/java/org/apache/qpid/amqp_1_0/type/messaging/codec/AmqpValueConstructor.java
Sat Feb 21 13:59:32 2015
@@ -25,8 +25,8 @@ package org.apache.qpid.amqp_1_0.type.me
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 extend
public AmqpValue construct(Object underlying)
{
-
- if(underlying instanceof Object)
- {
- return new AmqpValue((Object)underlying);
- }
- else
- {
- // TODO - error
- return null;
- }
+ return new AmqpValue(underlying);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]