AMQ-7291 - allow setting properties after clearProperties for BytesMessage, closes #420

This commit is contained in:
gtully 2020-02-19 13:01:25 +00:00
parent f3b2efcbcb
commit 503416a001
2 changed files with 24 additions and 6 deletions

View File

@ -912,12 +912,6 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
@Override
public void setObjectProperty(String name, Object value) throws JMSException {
initializeWriting();
super.setObjectProperty(name, value);
}
@Override
public String toString() {
return super.toString() + " ActiveMQBytesMessage{ " + "bytesOut = " + bytesOut + ", dataOut = " + dataOut + ", dataIn = " + dataIn + " }";

View File

@ -269,6 +269,30 @@ public class ActiveMQBytesMessageTest extends TestCase {
}
}
public void testClearProperties() throws Exception {
ActiveMQBytesMessage bytesMessage = new ActiveMQBytesMessage();
bytesMessage.setIntProperty("one", 1);
// simulate send
bytesMessage.onSend();
assertEquals(1, bytesMessage.getIntProperty("one"));
assertTrue(bytesMessage.isReadOnlyProperties());
try {
bytesMessage.setIntProperty("two", 2);
fail("should have thrown b/c readonly");
} catch (MessageNotWriteableException expected) {
}
// allow writing new properties
bytesMessage.clearProperties();
assertFalse(bytesMessage.propertyExists("one"));
assertFalse(bytesMessage.isReadOnlyProperties());
bytesMessage.setIntProperty("two", 2);
assertEquals(2, bytesMessage.getIntProperty("two"));
}
public void testReset() throws JMSException {
ActiveMQBytesMessage message = new ActiveMQBytesMessage();
try {