summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java2
-rw-r--r--java/common/src/main/java/org/apache/qpid/framing/FieldTable.java2
-rw-r--r--java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java13
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java28
4 files changed, 43 insertions, 2 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java b/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java
index cac465e533..ae1f354863 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/JMSHeaderAdapter.java
@@ -400,7 +400,7 @@ public final class JMSHeaderAdapter
}
catch (AMQPInvalidClassException aice)
{
- MessageFormatException mfe = new MessageFormatException("Only primatives are allowed object is:" + object.getClass());
+ MessageFormatException mfe = new MessageFormatException("Only Primitives objects allowed Object is:" + (object == null ? "null" : object.getClass()));
mfe.setLinkedException(aice);
mfe.initCause(aice);
throw mfe;
diff --git a/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java b/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
index bd566adf8f..4237ab9bd6 100644
--- a/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
+++ b/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
@@ -675,7 +675,7 @@ public class FieldTable
return setBytes(string, (byte[]) object);
}
- throw new AMQPInvalidClassException("Only Primatives objects allowed Object is:" + object.getClass());
+ throw new AMQPInvalidClassException("Only Primitives objects allowed Object is:" + (object == null ? "null" : object.getClass()));
}
public boolean isNullStringValue(String name)
diff --git a/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java b/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
index 007da7423e..66ca43c145 100644
--- a/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
+++ b/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
@@ -25,6 +25,7 @@ import junit.framework.TestCase;
import org.apache.mina.common.ByteBuffer;
+import org.apache.qpid.AMQInvalidArgumentException;
import org.apache.qpid.AMQPInvalidClassException;
import org.slf4j.Logger;
@@ -520,6 +521,18 @@ public class PropertyFieldTableTest extends TestCase
table.setObject("object-short", Short.MAX_VALUE);
table.setObject("object-string", "Hello");
+ try
+ {
+ table.setObject("Null-object", null);
+ fail("null values are not allowed");
+ }
+ catch (AMQPInvalidClassException aice)
+ {
+ assertEquals("Null values are not allowed to be set",
+ "Only Primitives objects allowed Object is:null", aice.getMessage());
+ }
+
+
Assert.assertEquals((Boolean) true, table.getBoolean("bool"));
Assert.assertEquals((Byte) Byte.MAX_VALUE, table.getByte("byte"));
assertBytesEqual(bytes, table.getBytes("bytes"));
diff --git a/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java b/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java
index c582a049a2..15d1ff63cf 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java
@@ -20,6 +20,7 @@
*/
package org.apache.qpid.test.unit.message;
+import org.apache.qpid.AMQPInvalidClassException;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
@@ -33,6 +34,7 @@ import org.slf4j.LoggerFactory;
import javax.jms.Destination;
import javax.jms.Message;
import javax.jms.MessageConsumer;
+import javax.jms.MessageFormatException;
import javax.jms.MessageProducer;
import javax.jms.ObjectMessage;
import javax.jms.Queue;
@@ -52,6 +54,7 @@ public class JMSPropertiesTest extends QpidBrokerTestCase
public static final String JMS_CORR_ID = "QPIDID_01";
public static final int JMS_DELIV_MODE = 1;
public static final String JMS_TYPE = "test.jms.type";
+ protected static final String NULL_OBJECT_PROPERTY = "NullObject";
protected void setUp() throws Exception
{
@@ -89,6 +92,28 @@ public class JMSPropertiesTest extends QpidBrokerTestCase
int JMSXGroupSeq_VALUE = 1;
sentMsg.setIntProperty("JMSXGroupSeq", JMSXGroupSeq_VALUE);
+ try
+ {
+ sentMsg.setObjectProperty(NULL_OBJECT_PROPERTY, null);
+ fail("Null Object Property value set");
+ }
+ catch (MessageFormatException mfe)
+ {
+ // Check the cause
+ Throwable cause = mfe.getCause();
+ assertNotNull(cause);
+ assertEquals("Incorrect cause ", AMQPInvalidClassException.class, cause.getClass());
+ assertEquals("Null values are not allowed to be set",
+ "Only Primitives objects allowed Object is:null", cause.getMessage());
+
+ // Also check the linked exception
+ cause = mfe.getLinkedException();
+ assertNotNull(cause);
+ assertEquals("Incorrect cause ", AMQPInvalidClassException.class, cause.getClass());
+ assertEquals("Null values are not allowed to be set",
+ "Only Primitives objects allowed Object is:null", cause.getMessage());
+ }
+
// send it
producer.send(sentMsg);
@@ -131,6 +156,9 @@ public class JMSPropertiesTest extends QpidBrokerTestCase
assertTrue("JMSXGroupID not available.",JMSXGroupID_Available);
assertTrue("JMSXGroupSeq not available.",JMSXGroupSeq_Available);
+ // Check that the NULL_OBJECT_PROPERTY was not set or transmitted.
+ assertFalse(NULL_OBJECT_PROPERTY + " was not set.", rm.propertyExists(NULL_OBJECT_PROPERTY));
+
con.close();
}