Author: clebert.suconic(a)jboss.com
Date: 2011-06-09 15:28:20 -0400 (Thu, 09 Jun 2011)
New Revision: 10789
Modified:
branches/Branch_2_2_EAP/src/main/org/hornetq/core/message/impl/MessageImpl.java
branches/Branch_2_2_EAP/src/main/org/hornetq/jms/client/HornetQMessage.java
branches/Branch_2_2_EAP/src/main/org/hornetq/utils/TypedProperties.java
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/client/MessageTest.java
Log:
HORNETQ-719 - Fix of nullValues
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/message/impl/MessageImpl.java
===================================================================
---
branches/Branch_2_2_EAP/src/main/org/hornetq/core/message/impl/MessageImpl.java 2011-06-09
19:11:40 UTC (rev 10788)
+++
branches/Branch_2_2_EAP/src/main/org/hornetq/core/message/impl/MessageImpl.java 2011-06-09
19:28:20 UTC (rev 10789)
@@ -571,9 +571,7 @@
{
if (value == null)
{
- // This is ok - when we try to read the same key it will return null too
-
- properties.removeProperty(key);
+ properties.putNullValue(key);
}
else if (value instanceof Boolean)
{
@@ -684,7 +682,7 @@
public void putStringProperty(final String key, final String value)
{
- properties.putSimpleStringProperty(new SimpleString(key), new
SimpleString(value));
+ properties.putSimpleStringProperty(new SimpleString(key),
SimpleString.toSimpleString(value));
bufferValid = false;
}
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/jms/client/HornetQMessage.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/jms/client/HornetQMessage.java 2011-06-09
19:11:40 UTC (rev 10788)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/jms/client/HornetQMessage.java 2011-06-09
19:28:20 UTC (rev 10789)
@@ -792,19 +792,13 @@
{
checkProperty(name, value);
- if (value == null)
- {
- // This is ok - when we try to read the same key it will return null too
- return;
- }
-
if (HornetQMessage.JMSXGROUPID.equals(name))
{
- message.putStringProperty(org.hornetq.api.core.Message.HDR_GROUP_ID, new
SimpleString(value));
+ message.putStringProperty(org.hornetq.api.core.Message.HDR_GROUP_ID,
SimpleString.toSimpleString(value));
}
else
{
- message.putStringProperty(new SimpleString(name), new SimpleString(value));
+ message.putStringProperty(new SimpleString(name),
SimpleString.toSimpleString(value));
}
}
Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/utils/TypedProperties.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/utils/TypedProperties.java 2011-06-09
19:11:40 UTC (rev 10788)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/utils/TypedProperties.java 2011-06-09
19:28:20 UTC (rev 10789)
@@ -138,6 +138,12 @@
checkCreateProperties();
doPutValue(key, value == null ? new NullValue() : new StringValue(value));
}
+
+ public void putNullValue(final SimpleString key)
+ {
+ checkCreateProperties();
+ doPutValue(key, new NullValue());
+ }
public void putCharProperty(final SimpleString key, final char value)
{
Modified:
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/client/MessageTest.java
===================================================================
---
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/client/MessageTest.java 2011-06-09
19:11:40 UTC (rev 10788)
+++
branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/jms/client/MessageTest.java 2011-06-09
19:28:20 UTC (rev 10789)
@@ -228,12 +228,23 @@
conn.start();
Message msg = sess.createMessage();
+
+ msg.setStringProperty("Test", "SomeValue");
+
+ assertEquals("SomeValue", msg.getStringProperty("Test"));
+
+ msg.setStringProperty("Test", null);
+
+ assertEquals(null, msg.getStringProperty("Test"));
msg.setObjectProperty(MessageTest.propName1, null);
+
msg.setStringProperty(MessageTest.propName2, null);
+
+ msg.getStringProperty(MessageTest.propName1);
+
+ msg.setStringProperty("Test", null);
- checkProperties(msg);
-
Message received = sendAndConsumeMessage(msg, prod, cons);
Assert.assertNotNull(received);