mirror of https://github.com/apache/activemq.git
Changing ActiveMQTextMessage to clear out the text field on marshal to a ByteSequence to prevent the data from being stored in memory twice.
This commit is contained in:
parent
de86f473f7
commit
84ec047d2f
|
@ -47,6 +47,7 @@ public class ActiveMQTextMessage extends ActiveMQMessage implements TextMessage
|
||||||
|
|
||||||
protected String text;
|
protected String text;
|
||||||
|
|
||||||
|
@Override
|
||||||
public Message copy() {
|
public Message copy() {
|
||||||
ActiveMQTextMessage copy = new ActiveMQTextMessage();
|
ActiveMQTextMessage copy = new ActiveMQTextMessage();
|
||||||
copy(copy);
|
copy(copy);
|
||||||
|
@ -58,20 +59,24 @@ public class ActiveMQTextMessage extends ActiveMQMessage implements TextMessage
|
||||||
copy.text = text;
|
copy.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public byte getDataStructureType() {
|
public byte getDataStructureType() {
|
||||||
return DATA_STRUCTURE_TYPE;
|
return DATA_STRUCTURE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getJMSXMimeType() {
|
public String getJMSXMimeType() {
|
||||||
return "jms/text-message";
|
return "jms/text-message";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setText(String text) throws MessageNotWriteableException {
|
public void setText(String text) throws MessageNotWriteableException {
|
||||||
checkReadOnlyBody();
|
checkReadOnlyBody();
|
||||||
this.text = text;
|
this.text = text;
|
||||||
setContent(null);
|
setContent(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getText() throws JMSException {
|
public String getText() throws JMSException {
|
||||||
if (text == null && getContent() != null) {
|
if (text == null && getContent() != null) {
|
||||||
text = decodeContent();
|
text = decodeContent();
|
||||||
|
@ -111,9 +116,10 @@ public class ActiveMQTextMessage extends ActiveMQMessage implements TextMessage
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void beforeMarshall(WireFormat wireFormat) throws IOException {
|
public void beforeMarshall(WireFormat wireFormat) throws IOException {
|
||||||
super.beforeMarshall(wireFormat);
|
super.beforeMarshall(wireFormat);
|
||||||
storeContent();
|
storeContentAndClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,6 +152,7 @@ public class ActiveMQTextMessage extends ActiveMQMessage implements TextMessage
|
||||||
|
|
||||||
// see https://issues.apache.org/activemq/browse/AMQ-2103
|
// see https://issues.apache.org/activemq/browse/AMQ-2103
|
||||||
// and https://issues.apache.org/activemq/browse/AMQ-2966
|
// and https://issues.apache.org/activemq/browse/AMQ-2966
|
||||||
|
@Override
|
||||||
public void clearMarshalledState() throws JMSException {
|
public void clearMarshalledState() throws JMSException {
|
||||||
super.clearMarshalledState();
|
super.clearMarshalledState();
|
||||||
this.text = null;
|
this.text = null;
|
||||||
|
@ -162,11 +169,13 @@ public class ActiveMQTextMessage extends ActiveMQMessage implements TextMessage
|
||||||
* @throws JMSException if the JMS provider fails to clear the message body
|
* @throws JMSException if the JMS provider fails to clear the message body
|
||||||
* due to some internal error.
|
* due to some internal error.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void clearBody() throws JMSException {
|
public void clearBody() throws JMSException {
|
||||||
super.clearBody();
|
super.clearBody();
|
||||||
this.text = null;
|
this.text = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
if (size == 0 && content == null && text != null) {
|
if (size == 0 && content == null && text != null) {
|
||||||
size = getMinimumMessageSize();
|
size = getMinimumMessageSize();
|
||||||
|
@ -178,6 +187,7 @@ public class ActiveMQTextMessage extends ActiveMQMessage implements TextMessage
|
||||||
return super.getSize();
|
return super.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
try {
|
try {
|
||||||
String text = this.text;
|
String text = this.text;
|
||||||
|
|
Loading…
Reference in New Issue