Moving the bytes copy to the parent Message class to solve this this
issue for all message types as that is the root cause
This commit is contained in:
Christopher L. Shannon (cshannon) 2016-04-11 12:31:57 +00:00
parent 837da7e582
commit e69c2cbad6
2 changed files with 9 additions and 4 deletions

View File

@ -890,8 +890,6 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
Inflater inflater = new Inflater(); Inflater inflater = new Inflater();
ByteArrayOutputStream decompressed = new ByteArrayOutputStream(); ByteArrayOutputStream decompressed = new ByteArrayOutputStream();
try { try {
//copy to prevent a race condition - AMQ-6142
dataSequence = new ByteSequence(dataSequence.getData(), dataSequence.getOffset(), dataSequence.getLength());
length = ByteSequenceData.readIntBig(dataSequence); length = ByteSequenceData.readIntBig(dataSequence);
dataSequence.offset = 0; dataSequence.offset = 0;
byte[] data = Arrays.copyOfRange(dataSequence.getData(), 4, dataSequence.getLength()); byte[] data = Arrays.copyOfRange(dataSequence.getData(), 4, dataSequence.getLength());

View File

@ -143,8 +143,8 @@ public abstract class Message extends BaseCommand implements MarshallAware, Mess
copy.properties = properties; copy.properties = properties;
} }
copy.content = content; copy.content = copyByteSequence(content);
copy.marshalledProperties = marshalledProperties; copy.marshalledProperties = copyByteSequence(marshalledProperties);
copy.dataStructure = dataStructure; copy.dataStructure = dataStructure;
copy.readOnlyProperties = readOnlyProperties; copy.readOnlyProperties = readOnlyProperties;
copy.readOnlyBody = readOnlyBody; copy.readOnlyBody = readOnlyBody;
@ -165,6 +165,13 @@ public abstract class Message extends BaseCommand implements MarshallAware, Mess
// copy.referenceCount = referenceCount; // copy.referenceCount = referenceCount;
} }
private ByteSequence copyByteSequence(ByteSequence content) {
if (content != null) {
return new ByteSequence(content.getData(), content.getOffset(), content.getLength());
}
return null;
}
public Object getProperty(String name) throws IOException { public Object getProperty(String name) throws IOException {
if (properties == null) { if (properties == null) {
if (marshalledProperties == null) { if (marshalledProperties == null) {