From 8abfa8f59d3e1b3d255917204e6c73b0d2ec48c8 Mon Sep 17 00:00:00 2001
From: "Christopher L. Shannon" <cshannon@apache.org>
Date: Fri, 31 Jan 2025 19:56:17 -0500
Subject: [PATCH] AMQ-6596 - Validate size of buffers during unmarshalling

Verify that size buffers for arrays and bytesequences will not exceed
the overall frame size

(cherry picked from commit 3037ce8b3b6a1efd67d273ad0bb6590c0434fad1)

(cherry picked from commit ff6dc101695b83d507be507b380e00c866e76bf6)
---
 activemq-client/pom.xml                       |   5 +
 .../activemq/openwire/OpenWireFormat.java     | 118 +++++---
 .../activemq/openwire/OpenWireUtil.java       |  51 +++-
 .../openwire/v1/BaseDataStreamMarshaller.java |  12 +-
 .../openwire/v1/MessageMarshaller.java        |   8 +-
 .../openwire/v1/PartialCommandMarshaller.java |   4 +-
 .../openwire/v1/WireFormatInfoMarshaller.java |   4 +-
 .../v1/XATransactionIdMarshaller.java         |   8 +-
 .../v10/BaseDataStreamMarshaller.java         |  12 +-
 .../v10/ConnectionControlMarshaller.java      |   4 +-
 .../openwire/v10/MessageMarshaller.java       |   8 +-
 .../v10/PartialCommandMarshaller.java         |   4 +-
 .../v10/WireFormatInfoMarshaller.java         |   4 +-
 .../v10/XATransactionIdMarshaller.java        |   8 +-
 .../v11/BaseDataStreamMarshaller.java         |  12 +-
 .../v11/ConnectionControlMarshaller.java      |   4 +-
 .../openwire/v11/MessageMarshaller.java       |   8 +-
 .../v11/PartialCommandMarshaller.java         |   4 +-
 .../v11/WireFormatInfoMarshaller.java         |   4 +-
 .../v11/XATransactionIdMarshaller.java        |   8 +-
 .../v12/BaseDataStreamMarshaller.java         |  12 +-
 .../v12/ConnectionControlMarshaller.java      |   4 +-
 .../openwire/v12/MessageMarshaller.java       |   8 +-
 .../v12/PartialCommandMarshaller.java         |   4 +-
 .../v12/WireFormatInfoMarshaller.java         |   4 +-
 .../v12/XATransactionIdMarshaller.java        |   8 +-
 .../openwire/v9/BaseDataStreamMarshaller.java |  12 +-
 .../v9/ConnectionControlMarshaller.java       |   4 +-
 .../openwire/v9/MessageMarshaller.java        |   8 +-
 .../openwire/v9/PartialCommandMarshaller.java |   4 +-
 .../openwire/v9/WireFormatInfoMarshaller.java |   4 +-
 .../v9/XATransactionIdMarshaller.java         |   8 +-
 .../apache/activemq/util/ByteSequence.java    |  12 +
 .../activemq/util/IOExceptionSupport.java     |   8 +-
 .../activemq/openwire/OpenWireUtilTest.java   | 119 ++++++++
 .../openwire/OpenWireValidationTest.java      | 257 ++++++++++++++++--
 activemq-openwire-legacy/pom.xml              |   5 +
 .../openwire/v2/BaseDataStreamMarshaller.java |  12 +-
 .../openwire/v2/MessageMarshaller.java        |   8 +-
 .../openwire/v2/PartialCommandMarshaller.java |   4 +-
 .../openwire/v2/WireFormatInfoMarshaller.java |   4 +-
 .../v2/XATransactionIdMarshaller.java         |   8 +-
 .../openwire/v3/BaseDataStreamMarshaller.java |  12 +-
 .../openwire/v3/MessageMarshaller.java        |   8 +-
 .../openwire/v3/PartialCommandMarshaller.java |   4 +-
 .../openwire/v3/WireFormatInfoMarshaller.java |   4 +-
 .../v3/XATransactionIdMarshaller.java         |   8 +-
 .../openwire/v4/BaseDataStreamMarshaller.java |  12 +-
 .../openwire/v4/MessageMarshaller.java        |   8 +-
 .../openwire/v4/PartialCommandMarshaller.java |   4 +-
 .../openwire/v4/WireFormatInfoMarshaller.java |   4 +-
 .../v4/XATransactionIdMarshaller.java         |   8 +-
 .../openwire/v5/BaseDataStreamMarshaller.java |  12 +-
 .../openwire/v5/MessageMarshaller.java        |   8 +-
 .../openwire/v5/PartialCommandMarshaller.java |   4 +-
 .../openwire/v5/WireFormatInfoMarshaller.java |   4 +-
 .../v5/XATransactionIdMarshaller.java         |   8 +-
 .../openwire/v6/BaseDataStreamMarshaller.java |  12 +-
 .../openwire/v6/MessageMarshaller.java        |   8 +-
 .../openwire/v6/PartialCommandMarshaller.java |   4 +-
 .../openwire/v6/WireFormatInfoMarshaller.java |   4 +-
 .../v6/XATransactionIdMarshaller.java         |   8 +-
 .../openwire/v7/BaseDataStreamMarshaller.java |  12 +-
 .../openwire/v7/MessageMarshaller.java        |   8 +-
 .../openwire/v7/PartialCommandMarshaller.java |   4 +-
 .../openwire/v7/WireFormatInfoMarshaller.java |   4 +-
 .../v7/XATransactionIdMarshaller.java         |   8 +-
 .../openwire/v8/BaseDataStreamMarshaller.java |  12 +-
 .../v8/ConnectionControlMarshaller.java       |   4 +-
 .../openwire/v8/MessageMarshaller.java        |   8 +-
 .../openwire/v8/PartialCommandMarshaller.java |   4 +-
 .../openwire/v8/WireFormatInfoMarshaller.java |   4 +-
 .../v8/XATransactionIdMarshaller.java         |   8 +-
 .../OpenWireLegacyValidationTest.java         |  46 +++-
 pom.xml                                       |   6 +
 75 files changed, 822 insertions(+), 257 deletions(-)
 create mode 100644 activemq-client/src/test/java/org/apache/activemq/openwire/OpenWireUtilTest.java

--- a/activemq-client/pom.xml
+++ b/activemq-client/pom.xml
@@ -89,6 +89,11 @@
         <artifactId>geronimo-annotation_1.3_spec</artifactId>
         <version>1.0</version>
     </dependency>
+    <dependency>
+      <groupId>org.javassist</groupId>
+      <artifactId>javassist</artifactId>
+      <scope>test</scope>
+    </dependency>
 
   </dependencies>
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/OpenWireFormat.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/OpenWireFormat.java
@@ -48,7 +48,7 @@
     private static final int MARSHAL_CACHE_SIZE = Short.MAX_VALUE / 2;
     private static final int MARSHAL_CACHE_FREE_SPACE = 100;
 
-    private DataStreamMarshaller dataMarshallers[];
+    private DataStreamMarshaller[] dataMarshallers;
     private int version;
     private boolean stackTraceEnabled;
     private boolean tcpNoDelayEnabled;
@@ -61,13 +61,22 @@
     // The following fields are used for value caching
     private short nextMarshallCacheIndex;
     private short nextMarshallCacheEvictionIndex;
-    private Map<DataStructure, Short> marshallCacheMap = new HashMap<DataStructure, Short>();
+    private Map<DataStructure, Short> marshallCacheMap = new HashMap<>();
     private DataStructure marshallCache[] = null;
     private DataStructure unmarshallCache[] = null;
-    private DataByteArrayOutputStream bytesOut = new DataByteArrayOutputStream();
-    private DataByteArrayInputStream bytesIn = new DataByteArrayInputStream();
+    private final DataByteArrayOutputStream bytesOut = new DataByteArrayOutputStream();
+    private final DataByteArrayInputStream bytesIn = new DataByteArrayInputStream();
     private WireFormatInfo preferedWireFormatInfo;
 
+    // Used to track the currentFrameSize for validation during unmarshalling
+    // Ideally we would pass the MarshallingContext directly to the marshalling methods,
+    // however this would require modifying the DataStreamMarshaller interface which would result
+    // in hundreds of existing methods having to be updated so this allows avoiding that and
+    // tracking the state without breaking the existing API.
+    // Note that while this is currently only used during unmarshalling, but if necessary could
+    // be extended in the future to be used during marshalling as well.
+    private final ThreadLocal<MarshallingContext> marshallingContext = new ThreadLocal<>();
+
     public OpenWireFormat() {
         this(DEFAULT_STORE_VERSION);
     }
@@ -191,26 +200,23 @@
     @Override
     public synchronized Object unmarshal(ByteSequence sequence) throws IOException {
         bytesIn.restart(sequence);
-        // DataInputStream dis = new DataInputStream(new
-        // ByteArrayInputStream(sequence));
 
-        if (!sizePrefixDisabled) {
-            int size = bytesIn.readInt();
-            if (sequence.getLength() - 4 != size) {
-                // throw new IOException("Packet size does not match marshaled
-                // size");
-            }
+        try {
+            final var context = new MarshallingContext();
+            marshallingContext.set(context);
 
-            if (maxFrameSizeEnabled && size > maxFrameSize) {
-                throw IOExceptionSupport.createFrameSizeException(size, maxFrameSize);
+            if (!sizePrefixDisabled) {
+                int size = bytesIn.readInt();
+                if (maxFrameSizeEnabled && size > maxFrameSize) {
+                    throw IOExceptionSupport.createFrameSizeException(size, maxFrameSize);
+                }
+                context.setFrameSize(size);
             }
+            return doUnmarshal(bytesIn);
+        } finally {
+            // After we unmarshal we can clear the context
+            marshallingContext.remove();
         }
-
-        Object command = doUnmarshal(bytesIn);
-        // if( !cacheEnabled && ((DataStructure)command).isMarshallAware() ) {
-        // ((MarshallAware) command).setCachedMarshalledForm(this, sequence);
-        // }
-        return command;
     }
 
     @Override
@@ -275,19 +281,22 @@
 
     @Override
     public Object unmarshal(DataInput dis) throws IOException {
-        DataInput dataIn = dis;
-        if (!sizePrefixDisabled) {
-            int size = dis.readInt();
-            if (maxFrameSizeEnabled && size > maxFrameSize) {
-                throw IOExceptionSupport.createFrameSizeException(size, maxFrameSize);
-            }
-            // int size = dis.readInt();
-            // byte[] data = new byte[size];
-            // dis.readFully(data);
-            // bytesIn.restart(data);
-            // dataIn = bytesIn;
+        try {
+            final var context = new MarshallingContext();
+            marshallingContext.set(context);
+
+          if (!sizePrefixDisabled) {
+                int size = dis.readInt();
+                if (maxFrameSizeEnabled && size > maxFrameSize) {
+                    throw IOExceptionSupport.createFrameSizeException(size, maxFrameSize);
+                }
+                context.setFrameSize(size);
+            }
+            return doUnmarshal(dis);
+        } finally {
+            // After we unmarshal we can clear
+            marshallingContext.remove();
         }
-        return doUnmarshal(dataIn);
     }
 
     /**
@@ -363,7 +372,7 @@
         this.version = version;
     }
 
-    public Object doUnmarshal(DataInput dis) throws IOException {
+    private Object doUnmarshal(DataInput dis) throws IOException {
         byte dataType = dis.readByte();
         if (dataType != NULL_TYPE) {
             DataStreamMarshaller dsm = dataMarshallers[dataType & 0xFF];
@@ -698,4 +707,47 @@
         }
         return version2;
     }
+
+    MarshallingContext getMarshallingContext() {
+        return marshallingContext.get();
+    }
+
+    // Used to track the estimated allocated buffer sizes to validate
+    // against the current frame being processed
+    static class MarshallingContext {
+        // Use primitives to minimize memory footprint
+        private int frameSize = -1;
+        private int estimatedAllocated = 0;
+
+        void setFrameSize(int frameSize) throws IOException {
+            this.frameSize = frameSize;
+            if (frameSize < 0) {
+                throw error("Frame size " + frameSize + " can't be negative.");
+            }
+        }
+
+        void increment(int size) throws IOException {
+            if (size < 0) {
+                throw error("Size " + size + " can't be negative.");
+            }
+            try {
+                estimatedAllocated = Math.addExact(estimatedAllocated, size);
+            } catch (ArithmeticException e) {
+                throw error("Buffer overflow when incrementing size value: " + size);
+            }
+        }
+
+        public int getFrameSize() {
+            return frameSize;
+        }
+
+        public int getEstimatedAllocated() {
+            return estimatedAllocated;
+        }
+
+        private static IOException error(String errorMessage) {
+            return new IOException(new IllegalArgumentException(errorMessage));
+        }
+    }
+
 }
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/OpenWireUtil.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/OpenWireUtil.java
@@ -16,9 +16,56 @@
  */
 package org.apache.activemq.openwire;
 
+import java.io.IOException;
+import org.apache.activemq.util.IOExceptionSupport;
+
 public class OpenWireUtil {
 
     /**
+     * Verify that the buffer size that will be allocated will not push the total allocated
+     * size of this frame above the expected frame size. This is an estimate as the current
+     * size is only tracked when calls to this method are made and is primarily intended
+     * to prevent large arrays from being created due to an invalid size.
+     *
+     * Also verify the size against configured max frame size.
+     * This check is a sanity check in case of corrupt packets contain invalid size values.
+     *
+     * @param wireFormat configured OpenWireFormat
+     * @param size buffer size to verify
+     * @throws IOException If size is larger than currentFrameSize or maxFrameSize
+     */
+    public static void validateBufferSize(OpenWireFormat wireFormat, int size) throws IOException {
+        validateLessThanFrameSize(wireFormat, size);
+
+        // if currentFrameSize is set and was checked above then this check should not be needed,
+        // but it doesn't hurt to verify again in case the max frame size check was missed
+        // somehow
+        if (wireFormat.isMaxFrameSizeEnabled() && size > wireFormat.getMaxFrameSize()) {
+            throw IOExceptionSupport.createFrameSizeException(size,  wireFormat.getMaxFrameSize());
+        }
+    }
+
+    // Verify total tracked sizes will not exceed the overall size of the frame
+    private static void validateLessThanFrameSize(OpenWireFormat wireFormat, int size)
+        throws IOException {
+        final var context = wireFormat.getMarshallingContext();
+        // No information on current frame size so just return
+        if (context == null || context.getFrameSize() < 0) {
+            return;
+        }
+
+        // Increment existing estimated buffer size with new size
+        context.increment(size);
+
+        // We should never be trying to allocate a buffer that is going to push the total
+        // size greater than the entire frame itself
+        if (context.getEstimatedAllocated() > context.getFrameSize()) {
+            throw IOExceptionSupport.createFrameSizeBufferException(
+                context.getEstimatedAllocated(), context.getFrameSize());
+        }
+    }
+
+    /**
      * Verify that the provided class extends {@link Throwable} and throw an
      * {@link IllegalArgumentException} if it does not.
      *
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v1/BaseDataStreamMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v1/BaseDataStreamMarshaller.java
@@ -411,10 +411,11 @@
         }
     }
 
-    protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected byte[] tightUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         byte rc[] = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -438,10 +439,11 @@
         }
     }
 
-    protected ByteSequence tightUnmarshalByteSequence(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected ByteSequence tightUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         ByteSequence rc = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             return new ByteSequence(t, 0, size);
@@ -618,10 +620,11 @@
         }
     }
 
-    protected byte[] looseUnmarshalByteArray(DataInput dataIn) throws IOException {
+    protected byte[] looseUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         byte rc[] = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -637,10 +640,11 @@
         }
     }
 
-    protected ByteSequence looseUnmarshalByteSequence(DataInput dataIn) throws IOException {
+    protected ByteSequence looseUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         ByteSequence rc = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             rc = new ByteSequence(t, 0, size);
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v1/MessageMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v1/MessageMarshaller.java
@@ -65,8 +65,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination)tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));
         info.setType(tightUnmarshalString(dataIn, bs));
-        info.setContent(tightUnmarshalByteSequence(dataIn, bs));
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setContent(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
         info.setDataStructure((org.apache.activemq.command.DataStructure)tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
         info.setCompressed(bs.readBoolean());
@@ -196,8 +196,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
         info.setType(looseUnmarshalString(dataIn));
-        info.setContent(looseUnmarshalByteSequence(dataIn));
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setContent(looseUnmarshalByteSequence(wireFormat, dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
         info.setDataStructure((org.apache.activemq.command.DataStructure)looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId)looseUnmarsalCachedObject(wireFormat, dataIn));
         info.setCompressed(dataIn.readBoolean());
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v1/PartialCommandMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v1/PartialCommandMarshaller.java
@@ -68,7 +68,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(tightUnmarshalByteArray(dataIn, bs));
+        info.setData(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -114,7 +114,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(looseUnmarshalByteArray(dataIn));
+        info.setData(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v1/WireFormatInfoMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v1/WireFormatInfoMarshaller.java
@@ -72,7 +72,7 @@
         
         info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
 
         info.afterUnmarshall(wireFormat);
 
@@ -130,7 +130,7 @@
         
         info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
 
         info.afterUnmarshall(wireFormat);
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v1/XATransactionIdMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v1/XATransactionIdMarshaller.java
@@ -68,8 +68,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs));
-        info.setBranchQualifier(tightUnmarshalByteArray(dataIn, bs));
+        info.setGlobalTransactionId(tightUnmarshalByteArray(wireFormat, dataIn, bs));
+        info.setBranchQualifier(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -117,8 +117,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(looseUnmarshalByteArray(dataIn));
-        info.setBranchQualifier(looseUnmarshalByteArray(dataIn));
+        info.setGlobalTransactionId(looseUnmarshalByteArray(wireFormat, dataIn));
+        info.setBranchQualifier(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v10/BaseDataStreamMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v10/BaseDataStreamMarshaller.java
@@ -410,10 +410,11 @@
         }
     }
 
-    protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected byte[] tightUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         byte rc[] = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -437,10 +438,11 @@
         }
     }
 
-    protected ByteSequence tightUnmarshalByteSequence(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected ByteSequence tightUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         ByteSequence rc = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             return new ByteSequence(t, 0, size);
@@ -617,10 +619,11 @@
         }
     }
 
-    protected byte[] looseUnmarshalByteArray(DataInput dataIn) throws IOException {
+    protected byte[] looseUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         byte rc[] = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -636,10 +639,11 @@
         }
     }
 
-    protected ByteSequence looseUnmarshalByteSequence(DataInput dataIn) throws IOException {
+    protected ByteSequence looseUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         ByteSequence rc = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             rc = new ByteSequence(t, 0, size);
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v10/ConnectionControlMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v10/ConnectionControlMarshaller.java
@@ -74,7 +74,7 @@
         info.setConnectedBrokers(tightUnmarshalString(dataIn, bs));
         info.setReconnectTo(tightUnmarshalString(dataIn, bs));
         info.setRebalanceConnection(bs.readBoolean());
-        info.setToken(tightUnmarshalByteArray(dataIn, bs));
+        info.setToken(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -142,7 +142,7 @@
         info.setConnectedBrokers(looseUnmarshalString(dataIn));
         info.setReconnectTo(looseUnmarshalString(dataIn));
         info.setRebalanceConnection(dataIn.readBoolean());
-        info.setToken(looseUnmarshalByteArray(dataIn));
+        info.setToken(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v10/MessageMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v10/MessageMarshaller.java
@@ -69,8 +69,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));
         info.setType(tightUnmarshalString(dataIn, bs));
-        info.setContent(tightUnmarshalByteSequence(dataIn, bs));
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setContent(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
         info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
         info.setCompressed(bs.readBoolean());
@@ -228,8 +228,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
         info.setType(looseUnmarshalString(dataIn));
-        info.setContent(looseUnmarshalByteSequence(dataIn));
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setContent(looseUnmarshalByteSequence(wireFormat, dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
         info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));
         info.setCompressed(dataIn.readBoolean());
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v10/PartialCommandMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v10/PartialCommandMarshaller.java
@@ -67,7 +67,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(tightUnmarshalByteArray(dataIn, bs));
+        info.setData(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -113,7 +113,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(looseUnmarshalByteArray(dataIn));
+        info.setData(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v10/WireFormatInfoMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v10/WireFormatInfoMarshaller.java
@@ -71,7 +71,7 @@
         
         info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
 
         info.afterUnmarshall(wireFormat);
 
@@ -129,7 +129,7 @@
         
         info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
 
         info.afterUnmarshall(wireFormat);
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v10/XATransactionIdMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v10/XATransactionIdMarshaller.java
@@ -67,8 +67,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs));
-        info.setBranchQualifier(tightUnmarshalByteArray(dataIn, bs));
+        info.setGlobalTransactionId(tightUnmarshalByteArray(wireFormat, dataIn, bs));
+        info.setBranchQualifier(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -116,8 +116,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(looseUnmarshalByteArray(dataIn));
-        info.setBranchQualifier(looseUnmarshalByteArray(dataIn));
+        info.setGlobalTransactionId(looseUnmarshalByteArray(wireFormat, dataIn));
+        info.setBranchQualifier(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/BaseDataStreamMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/BaseDataStreamMarshaller.java
@@ -409,10 +409,11 @@
         }
     }
 
-    protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected byte[] tightUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         byte rc[] = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -436,10 +437,11 @@
         }
     }
 
-    protected ByteSequence tightUnmarshalByteSequence(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected ByteSequence tightUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         ByteSequence rc = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             return new ByteSequence(t, 0, size);
@@ -616,10 +618,11 @@
         }
     }
 
-    protected byte[] looseUnmarshalByteArray(DataInput dataIn) throws IOException {
+    protected byte[] looseUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         byte rc[] = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -635,10 +638,11 @@
         }
     }
 
-    protected ByteSequence looseUnmarshalByteSequence(DataInput dataIn) throws IOException {
+    protected ByteSequence looseUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         ByteSequence rc = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             rc = new ByteSequence(t, 0, size);
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionControlMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/ConnectionControlMarshaller.java
@@ -74,7 +74,7 @@
         info.setConnectedBrokers(tightUnmarshalString(dataIn, bs));
         info.setReconnectTo(tightUnmarshalString(dataIn, bs));
         info.setRebalanceConnection(bs.readBoolean());
-        info.setToken(tightUnmarshalByteArray(dataIn, bs));
+        info.setToken(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -142,7 +142,7 @@
         info.setConnectedBrokers(looseUnmarshalString(dataIn));
         info.setReconnectTo(looseUnmarshalString(dataIn));
         info.setRebalanceConnection(dataIn.readBoolean());
-        info.setToken(looseUnmarshalByteArray(dataIn));
+        info.setToken(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/MessageMarshaller.java
@@ -69,8 +69,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));
         info.setType(tightUnmarshalString(dataIn, bs));
-        info.setContent(tightUnmarshalByteSequence(dataIn, bs));
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setContent(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
         info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
         info.setCompressed(bs.readBoolean());
@@ -228,8 +228,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
         info.setType(looseUnmarshalString(dataIn));
-        info.setContent(looseUnmarshalByteSequence(dataIn));
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setContent(looseUnmarshalByteSequence(wireFormat, dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
         info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));
         info.setCompressed(dataIn.readBoolean());
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/PartialCommandMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/PartialCommandMarshaller.java
@@ -67,7 +67,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(tightUnmarshalByteArray(dataIn, bs));
+        info.setData(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -113,7 +113,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(looseUnmarshalByteArray(dataIn));
+        info.setData(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/WireFormatInfoMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/WireFormatInfoMarshaller.java
@@ -71,7 +71,7 @@
         
         info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
 
         info.afterUnmarshall(wireFormat);
 
@@ -129,7 +129,7 @@
         
         info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
 
         info.afterUnmarshall(wireFormat);
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v11/XATransactionIdMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v11/XATransactionIdMarshaller.java
@@ -67,8 +67,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs));
-        info.setBranchQualifier(tightUnmarshalByteArray(dataIn, bs));
+        info.setGlobalTransactionId(tightUnmarshalByteArray(wireFormat, dataIn, bs));
+        info.setBranchQualifier(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -116,8 +116,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(looseUnmarshalByteArray(dataIn));
-        info.setBranchQualifier(looseUnmarshalByteArray(dataIn));
+        info.setGlobalTransactionId(looseUnmarshalByteArray(wireFormat, dataIn));
+        info.setBranchQualifier(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v12/BaseDataStreamMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v12/BaseDataStreamMarshaller.java
@@ -409,10 +409,11 @@
         }
     }
 
-    protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected byte[] tightUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         byte rc[] = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -436,10 +437,11 @@
         }
     }
 
-    protected ByteSequence tightUnmarshalByteSequence(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected ByteSequence tightUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         ByteSequence rc = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             return new ByteSequence(t, 0, size);
@@ -616,10 +618,11 @@
         }
     }
 
-    protected byte[] looseUnmarshalByteArray(DataInput dataIn) throws IOException {
+    protected byte[] looseUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         byte rc[] = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -635,10 +638,11 @@
         }
     }
 
-    protected ByteSequence looseUnmarshalByteSequence(DataInput dataIn) throws IOException {
+    protected ByteSequence looseUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         ByteSequence rc = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             rc = new ByteSequence(t, 0, size);
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v12/ConnectionControlMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v12/ConnectionControlMarshaller.java
@@ -74,7 +74,7 @@
         info.setConnectedBrokers(tightUnmarshalString(dataIn, bs));
         info.setReconnectTo(tightUnmarshalString(dataIn, bs));
         info.setRebalanceConnection(bs.readBoolean());
-        info.setToken(tightUnmarshalByteArray(dataIn, bs));
+        info.setToken(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -142,7 +142,7 @@
         info.setConnectedBrokers(looseUnmarshalString(dataIn));
         info.setReconnectTo(looseUnmarshalString(dataIn));
         info.setRebalanceConnection(dataIn.readBoolean());
-        info.setToken(looseUnmarshalByteArray(dataIn));
+        info.setToken(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v12/MessageMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v12/MessageMarshaller.java
@@ -69,8 +69,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));
         info.setType(tightUnmarshalString(dataIn, bs));
-        info.setContent(tightUnmarshalByteSequence(dataIn, bs));
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setContent(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
         info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
         info.setCompressed(bs.readBoolean());
@@ -228,8 +228,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
         info.setType(looseUnmarshalString(dataIn));
-        info.setContent(looseUnmarshalByteSequence(dataIn));
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setContent(looseUnmarshalByteSequence(wireFormat, dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
         info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));
         info.setCompressed(dataIn.readBoolean());
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v12/PartialCommandMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v12/PartialCommandMarshaller.java
@@ -67,7 +67,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(tightUnmarshalByteArray(dataIn, bs));
+        info.setData(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -113,7 +113,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(looseUnmarshalByteArray(dataIn));
+        info.setData(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v12/WireFormatInfoMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v12/WireFormatInfoMarshaller.java
@@ -71,7 +71,7 @@
         
         info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
 
         info.afterUnmarshall(wireFormat);
 
@@ -129,7 +129,7 @@
         
         info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
 
         info.afterUnmarshall(wireFormat);
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v12/XATransactionIdMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v12/XATransactionIdMarshaller.java
@@ -67,8 +67,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs));
-        info.setBranchQualifier(tightUnmarshalByteArray(dataIn, bs));
+        info.setGlobalTransactionId(tightUnmarshalByteArray(wireFormat, dataIn, bs));
+        info.setBranchQualifier(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -116,8 +116,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(looseUnmarshalByteArray(dataIn));
-        info.setBranchQualifier(looseUnmarshalByteArray(dataIn));
+        info.setGlobalTransactionId(looseUnmarshalByteArray(wireFormat, dataIn));
+        info.setBranchQualifier(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v9/BaseDataStreamMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v9/BaseDataStreamMarshaller.java
@@ -409,10 +409,11 @@
         }
     }
 
-    protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected byte[] tightUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         byte rc[] = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -436,10 +437,11 @@
         }
     }
 
-    protected ByteSequence tightUnmarshalByteSequence(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected ByteSequence tightUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         ByteSequence rc = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             return new ByteSequence(t, 0, size);
@@ -616,10 +618,11 @@
         }
     }
 
-    protected byte[] looseUnmarshalByteArray(DataInput dataIn) throws IOException {
+    protected byte[] looseUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         byte rc[] = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -635,10 +638,11 @@
         }
     }
 
-    protected ByteSequence looseUnmarshalByteSequence(DataInput dataIn) throws IOException {
+    protected ByteSequence looseUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         ByteSequence rc = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             rc = new ByteSequence(t, 0, size);
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v9/ConnectionControlMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v9/ConnectionControlMarshaller.java
@@ -1 +1 @@
-/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v9;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for ConnectionControlMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class ConnectionControlMarshaller extends BaseCommandMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return ConnectionControl.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new ConnectionControl();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        ConnectionControl info = (ConnectionControl)o;        info.setClose(bs.readBoolean());        info.setExit(bs.readBoolean());        info.setFaultTolerant(bs.readBoolean());        info.setResume(bs.readBoolean());        info.setSuspend(bs.readBoolean());        info.setConnectedBrokers(tightUnmarshalString(dataIn, bs));        info.setReconnectTo(tightUnmarshalString(dataIn, bs));        info.setRebalanceConnection(bs.readBoolean());        info.setToken(tightUnmarshalByteArray(dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        ConnectionControl info = (ConnectionControl)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        bs.writeBoolean(info.isClose());        bs.writeBoolean(info.isExit());        bs.writeBoolean(info.isFaultTolerant());        bs.writeBoolean(info.isResume());        bs.writeBoolean(info.isSuspend());        rc += tightMarshalString1(info.getConnectedBrokers(), bs);        rc += tightMarshalString1(info.getReconnectTo(), bs);        bs.writeBoolean(info.isRebalanceConnection());        rc += tightMarshalByteArray1(info.getToken(), bs);        return rc + 0;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        ConnectionControl info = (ConnectionControl)o;        bs.readBoolean();        bs.readBoolean();        bs.readBoolean();        bs.readBoolean();        bs.readBoolean();        tightMarshalString2(info.getConnectedBrokers(), dataOut, bs);        tightMarshalString2(info.getReconnectTo(), dataOut, bs);        bs.readBoolean();        tightMarshalByteArray2(info.getToken(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        ConnectionControl info = (ConnectionControl)o;        info.setClose(dataIn.readBoolean());        info.setExit(dataIn.readBoolean());        info.setFaultTolerant(dataIn.readBoolean());        info.setResume(dataIn.readBoolean());        info.setSuspend(dataIn.readBoolean());        info.setConnectedBrokers(looseUnmarshalString(dataIn));        info.setReconnectTo(looseUnmarshalString(dataIn));        info.setRebalanceConnection(dataIn.readBoolean());        info.setToken(looseUnmarshalByteArray(dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        ConnectionControl info = (ConnectionControl)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeBoolean(info.isClose());        dataOut.writeBoolean(info.isExit());        dataOut.writeBoolean(info.isFaultTolerant());        dataOut.writeBoolean(info.isResume());        dataOut.writeBoolean(info.isSuspend());        looseMarshalString(info.getConnectedBrokers(), dataOut);        looseMarshalString(info.getReconnectTo(), dataOut);        dataOut.writeBoolean(info.isRebalanceConnection());        looseMarshalByteArray(wireFormat, info.getToken(), dataOut);    }}
\ No newline at end of file
+/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v9;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for ConnectionControlMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class ConnectionControlMarshaller extends BaseCommandMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return ConnectionControl.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new ConnectionControl();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        ConnectionControl info = (ConnectionControl)o;        info.setClose(bs.readBoolean());        info.setExit(bs.readBoolean());        info.setFaultTolerant(bs.readBoolean());        info.setResume(bs.readBoolean());        info.setSuspend(bs.readBoolean());        info.setConnectedBrokers(tightUnmarshalString(dataIn, bs));        info.setReconnectTo(tightUnmarshalString(dataIn, bs));        info.setRebalanceConnection(bs.readBoolean());        info.setToken(tightUnmarshalByteArray(wireFormat, dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        ConnectionControl info = (ConnectionControl)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        bs.writeBoolean(info.isClose());        bs.writeBoolean(info.isExit());        bs.writeBoolean(info.isFaultTolerant());        bs.writeBoolean(info.isResume());        bs.writeBoolean(info.isSuspend());        rc += tightMarshalString1(info.getConnectedBrokers(), bs);        rc += tightMarshalString1(info.getReconnectTo(), bs);        bs.writeBoolean(info.isRebalanceConnection());        rc += tightMarshalByteArray1(info.getToken(), bs);        return rc + 0;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        ConnectionControl info = (ConnectionControl)o;        bs.readBoolean();        bs.readBoolean();        bs.readBoolean();        bs.readBoolean();        bs.readBoolean();        tightMarshalString2(info.getConnectedBrokers(), dataOut, bs);        tightMarshalString2(info.getReconnectTo(), dataOut, bs);        bs.readBoolean();        tightMarshalByteArray2(info.getToken(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        ConnectionControl info = (ConnectionControl)o;        info.setClose(dataIn.readBoolean());        info.setExit(dataIn.readBoolean());        info.setFaultTolerant(dataIn.readBoolean());        info.setResume(dataIn.readBoolean());        info.setSuspend(dataIn.readBoolean());        info.setConnectedBrokers(looseUnmarshalString(dataIn));        info.setReconnectTo(looseUnmarshalString(dataIn));        info.setRebalanceConnection(dataIn.readBoolean());        info.setToken(looseUnmarshalByteArray(wireFormat, dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        ConnectionControl info = (ConnectionControl)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeBoolean(info.isClose());        dataOut.writeBoolean(info.isExit());        dataOut.writeBoolean(info.isFaultTolerant());        dataOut.writeBoolean(info.isResume());        dataOut.writeBoolean(info.isSuspend());        looseMarshalString(info.getConnectedBrokers(), dataOut);        looseMarshalString(info.getReconnectTo(), dataOut);        dataOut.writeBoolean(info.isRebalanceConnection());        looseMarshalByteArray(wireFormat, info.getToken(), dataOut);    }}
\ No newline at end of file
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v9/MessageMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v9/MessageMarshaller.java
@@ -1 +1 @@
-/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v9;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for MessageMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public abstract class MessageMarshaller extends BaseCommandMarshaller {    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        Message info = (Message)o;        info.beforeUnmarshall(wireFormat);                info.setProducerId((org.apache.activemq.command.ProducerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setMessageId((org.apache.activemq.command.MessageId) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setGroupID(tightUnmarshalString(dataIn, bs));        info.setGroupSequence(dataIn.readInt());        info.setCorrelationId(tightUnmarshalString(dataIn, bs));        info.setPersistent(bs.readBoolean());        info.setExpiration(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setPriority(dataIn.readByte());        info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setType(tightUnmarshalString(dataIn, bs));        info.setContent(tightUnmarshalByteSequence(dataIn, bs));        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));        info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setCompressed(bs.readBoolean());        info.setRedeliveryCounter(dataIn.readInt());        if (bs.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);            }            info.setBrokerPath(value);        }        else {            info.setBrokerPath(null);        }        info.setArrival(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setUserID(tightUnmarshalString(dataIn, bs));        info.setRecievedByDFBridge(bs.readBoolean());        info.setDroppable(bs.readBoolean());        if (bs.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);            }            info.setCluster(value);        }        else {            info.setCluster(null);        }        info.setBrokerInTime(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setBrokerOutTime(tightUnmarshalLong(wireFormat, dataIn, bs));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        Message info = (Message)o;        info.beforeMarshall(wireFormat);        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalDestination(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalTransactionId(), bs);        rc += tightMarshalString1(info.getGroupID(), bs);        rc += tightMarshalString1(info.getCorrelationId(), bs);        bs.writeBoolean(info.isPersistent());        rc+=tightMarshalLong1(wireFormat, info.getExpiration(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getReplyTo(), bs);        rc+=tightMarshalLong1(wireFormat, info.getTimestamp(), bs);        rc += tightMarshalString1(info.getType(), bs);        rc += tightMarshalByteSequence1(info.getContent(), bs);        rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDataStructure(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTargetConsumerId(), bs);        bs.writeBoolean(info.isCompressed());        rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);        rc+=tightMarshalLong1(wireFormat, info.getArrival(), bs);        rc += tightMarshalString1(info.getUserID(), bs);        bs.writeBoolean(info.isRecievedByDFBridge());        bs.writeBoolean(info.isDroppable());        rc += tightMarshalObjectArray1(wireFormat, info.getCluster(), bs);        rc+=tightMarshalLong1(wireFormat, info.getBrokerInTime(), bs);        rc+=tightMarshalLong1(wireFormat, info.getBrokerOutTime(), bs);        return rc + 9;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        Message info = (Message)o;        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut, bs);        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut, bs);        tightMarshalString2(info.getGroupID(), dataOut, bs);        dataOut.writeInt(info.getGroupSequence());        tightMarshalString2(info.getCorrelationId(), dataOut, bs);        bs.readBoolean();        tightMarshalLong2(wireFormat, info.getExpiration(), dataOut, bs);        dataOut.writeByte(info.getPriority());        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getReplyTo(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getTimestamp(), dataOut, bs);        tightMarshalString2(info.getType(), dataOut, bs);        tightMarshalByteSequence2(info.getContent(), dataOut, bs);        tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDataStructure(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut, bs);        bs.readBoolean();        dataOut.writeInt(info.getRedeliveryCounter());        tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getArrival(), dataOut, bs);        tightMarshalString2(info.getUserID(), dataOut, bs);        bs.readBoolean();        bs.readBoolean();        tightMarshalObjectArray2(wireFormat, info.getCluster(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getBrokerInTime(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getBrokerOutTime(), dataOut, bs);        info.afterMarshall(wireFormat);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        Message info = (Message)o;        info.beforeUnmarshall(wireFormat);                info.setProducerId((org.apache.activemq.command.ProducerId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setGroupID(looseUnmarshalString(dataIn));        info.setGroupSequence(dataIn.readInt());        info.setCorrelationId(looseUnmarshalString(dataIn));        info.setPersistent(dataIn.readBoolean());        info.setExpiration(looseUnmarshalLong(wireFormat, dataIn));        info.setPriority(dataIn.readByte());        info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));        info.setType(looseUnmarshalString(dataIn));        info.setContent(looseUnmarshalByteSequence(dataIn));        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));        info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setCompressed(dataIn.readBoolean());        info.setRedeliveryCounter(dataIn.readInt());        if (dataIn.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);            }            info.setBrokerPath(value);        }        else {            info.setBrokerPath(null);        }        info.setArrival(looseUnmarshalLong(wireFormat, dataIn));        info.setUserID(looseUnmarshalString(dataIn));        info.setRecievedByDFBridge(dataIn.readBoolean());        info.setDroppable(dataIn.readBoolean());        if (dataIn.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);            }            info.setCluster(value);        }        else {            info.setCluster(null);        }        info.setBrokerInTime(looseUnmarshalLong(wireFormat, dataIn));        info.setBrokerOutTime(looseUnmarshalLong(wireFormat, dataIn));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        Message info = (Message)o;        info.beforeMarshall(wireFormat);        super.looseMarshal(wireFormat, o, dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut);        looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut);        looseMarshalString(info.getGroupID(), dataOut);        dataOut.writeInt(info.getGroupSequence());        looseMarshalString(info.getCorrelationId(), dataOut);        dataOut.writeBoolean(info.isPersistent());        looseMarshalLong(wireFormat, info.getExpiration(), dataOut);        dataOut.writeByte(info.getPriority());        looseMarshalNestedObject(wireFormat, (DataStructure)info.getReplyTo(), dataOut);        looseMarshalLong(wireFormat, info.getTimestamp(), dataOut);        looseMarshalString(info.getType(), dataOut);        looseMarshalByteSequence(wireFormat, info.getContent(), dataOut);        looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);        looseMarshalNestedObject(wireFormat, (DataStructure)info.getDataStructure(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut);        dataOut.writeBoolean(info.isCompressed());        dataOut.writeInt(info.getRedeliveryCounter());        looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);        looseMarshalLong(wireFormat, info.getArrival(), dataOut);        looseMarshalString(info.getUserID(), dataOut);        dataOut.writeBoolean(info.isRecievedByDFBridge());        dataOut.writeBoolean(info.isDroppable());        looseMarshalObjectArray(wireFormat, info.getCluster(), dataOut);        looseMarshalLong(wireFormat, info.getBrokerInTime(), dataOut);        looseMarshalLong(wireFormat, info.getBrokerOutTime(), dataOut);    }}
\ No newline at end of file
+/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v9;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for MessageMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public abstract class MessageMarshaller extends BaseCommandMarshaller {    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        Message info = (Message)o;        info.beforeUnmarshall(wireFormat);                info.setProducerId((org.apache.activemq.command.ProducerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setMessageId((org.apache.activemq.command.MessageId) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setGroupID(tightUnmarshalString(dataIn, bs));        info.setGroupSequence(dataIn.readInt());        info.setCorrelationId(tightUnmarshalString(dataIn, bs));        info.setPersistent(bs.readBoolean());        info.setExpiration(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setPriority(dataIn.readByte());        info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setType(tightUnmarshalString(dataIn, bs));        info.setContent(tightUnmarshalByteSequence(wireFormat, dataIn, bs));        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));        info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setCompressed(bs.readBoolean());        info.setRedeliveryCounter(dataIn.readInt());        if (bs.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);            }            info.setBrokerPath(value);        }        else {            info.setBrokerPath(null);        }        info.setArrival(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setUserID(tightUnmarshalString(dataIn, bs));        info.setRecievedByDFBridge(bs.readBoolean());        info.setDroppable(bs.readBoolean());        if (bs.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);            }            info.setCluster(value);        }        else {            info.setCluster(null);        }        info.setBrokerInTime(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setBrokerOutTime(tightUnmarshalLong(wireFormat, dataIn, bs));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        Message info = (Message)o;        info.beforeMarshall(wireFormat);        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalDestination(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalTransactionId(), bs);        rc += tightMarshalString1(info.getGroupID(), bs);        rc += tightMarshalString1(info.getCorrelationId(), bs);        bs.writeBoolean(info.isPersistent());        rc+=tightMarshalLong1(wireFormat, info.getExpiration(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getReplyTo(), bs);        rc+=tightMarshalLong1(wireFormat, info.getTimestamp(), bs);        rc += tightMarshalString1(info.getType(), bs);        rc += tightMarshalByteSequence1(info.getContent(), bs);        rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDataStructure(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTargetConsumerId(), bs);        bs.writeBoolean(info.isCompressed());        rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);        rc+=tightMarshalLong1(wireFormat, info.getArrival(), bs);        rc += tightMarshalString1(info.getUserID(), bs);        bs.writeBoolean(info.isRecievedByDFBridge());        bs.writeBoolean(info.isDroppable());        rc += tightMarshalObjectArray1(wireFormat, info.getCluster(), bs);        rc+=tightMarshalLong1(wireFormat, info.getBrokerInTime(), bs);        rc+=tightMarshalLong1(wireFormat, info.getBrokerOutTime(), bs);        return rc + 9;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        Message info = (Message)o;        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut, bs);        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut, bs);        tightMarshalString2(info.getGroupID(), dataOut, bs);        dataOut.writeInt(info.getGroupSequence());        tightMarshalString2(info.getCorrelationId(), dataOut, bs);        bs.readBoolean();        tightMarshalLong2(wireFormat, info.getExpiration(), dataOut, bs);        dataOut.writeByte(info.getPriority());        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getReplyTo(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getTimestamp(), dataOut, bs);        tightMarshalString2(info.getType(), dataOut, bs);        tightMarshalByteSequence2(info.getContent(), dataOut, bs);        tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDataStructure(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut, bs);        bs.readBoolean();        dataOut.writeInt(info.getRedeliveryCounter());        tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getArrival(), dataOut, bs);        tightMarshalString2(info.getUserID(), dataOut, bs);        bs.readBoolean();        bs.readBoolean();        tightMarshalObjectArray2(wireFormat, info.getCluster(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getBrokerInTime(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getBrokerOutTime(), dataOut, bs);        info.afterMarshall(wireFormat);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        Message info = (Message)o;        info.beforeUnmarshall(wireFormat);                info.setProducerId((org.apache.activemq.command.ProducerId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setGroupID(looseUnmarshalString(dataIn));        info.setGroupSequence(dataIn.readInt());        info.setCorrelationId(looseUnmarshalString(dataIn));        info.setPersistent(dataIn.readBoolean());        info.setExpiration(looseUnmarshalLong(wireFormat, dataIn));        info.setPriority(dataIn.readByte());        info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));        info.setType(looseUnmarshalString(dataIn));        info.setContent(looseUnmarshalByteSequence(wireFormat, dataIn));        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));        info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setCompressed(dataIn.readBoolean());        info.setRedeliveryCounter(dataIn.readInt());        if (dataIn.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);            }            info.setBrokerPath(value);        }        else {            info.setBrokerPath(null);        }        info.setArrival(looseUnmarshalLong(wireFormat, dataIn));        info.setUserID(looseUnmarshalString(dataIn));        info.setRecievedByDFBridge(dataIn.readBoolean());        info.setDroppable(dataIn.readBoolean());        if (dataIn.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);            }            info.setCluster(value);        }        else {            info.setCluster(null);        }        info.setBrokerInTime(looseUnmarshalLong(wireFormat, dataIn));        info.setBrokerOutTime(looseUnmarshalLong(wireFormat, dataIn));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        Message info = (Message)o;        info.beforeMarshall(wireFormat);        super.looseMarshal(wireFormat, o, dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut);        looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut);        looseMarshalString(info.getGroupID(), dataOut);        dataOut.writeInt(info.getGroupSequence());        looseMarshalString(info.getCorrelationId(), dataOut);        dataOut.writeBoolean(info.isPersistent());        looseMarshalLong(wireFormat, info.getExpiration(), dataOut);        dataOut.writeByte(info.getPriority());        looseMarshalNestedObject(wireFormat, (DataStructure)info.getReplyTo(), dataOut);        looseMarshalLong(wireFormat, info.getTimestamp(), dataOut);        looseMarshalString(info.getType(), dataOut);        looseMarshalByteSequence(wireFormat, info.getContent(), dataOut);        looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);        looseMarshalNestedObject(wireFormat, (DataStructure)info.getDataStructure(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut);        dataOut.writeBoolean(info.isCompressed());        dataOut.writeInt(info.getRedeliveryCounter());        looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);        looseMarshalLong(wireFormat, info.getArrival(), dataOut);        looseMarshalString(info.getUserID(), dataOut);        dataOut.writeBoolean(info.isRecievedByDFBridge());        dataOut.writeBoolean(info.isDroppable());        looseMarshalObjectArray(wireFormat, info.getCluster(), dataOut);        looseMarshalLong(wireFormat, info.getBrokerInTime(), dataOut);        looseMarshalLong(wireFormat, info.getBrokerOutTime(), dataOut);    }}
\ No newline at end of file
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v9/PartialCommandMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v9/PartialCommandMarshaller.java
@@ -1 +1 @@
-/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v9;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for PartialCommandMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class PartialCommandMarshaller extends BaseDataStreamMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return PartialCommand.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new PartialCommand();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        PartialCommand info = (PartialCommand)o;        info.setCommandId(dataIn.readInt());        info.setData(tightUnmarshalByteArray(dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        PartialCommand info = (PartialCommand)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalByteArray1(info.getData(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        PartialCommand info = (PartialCommand)o;        dataOut.writeInt(info.getCommandId());        tightMarshalByteArray2(info.getData(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        PartialCommand info = (PartialCommand)o;        info.setCommandId(dataIn.readInt());        info.setData(looseUnmarshalByteArray(dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        PartialCommand info = (PartialCommand)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeInt(info.getCommandId());        looseMarshalByteArray(wireFormat, info.getData(), dataOut);    }}
\ No newline at end of file
+/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v9;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for PartialCommandMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class PartialCommandMarshaller extends BaseDataStreamMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return PartialCommand.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new PartialCommand();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        PartialCommand info = (PartialCommand)o;        info.setCommandId(dataIn.readInt());        info.setData(tightUnmarshalByteArray(wireFormat, dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        PartialCommand info = (PartialCommand)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalByteArray1(info.getData(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        PartialCommand info = (PartialCommand)o;        dataOut.writeInt(info.getCommandId());        tightMarshalByteArray2(info.getData(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        PartialCommand info = (PartialCommand)o;        info.setCommandId(dataIn.readInt());        info.setData(looseUnmarshalByteArray(wireFormat, dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        PartialCommand info = (PartialCommand)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeInt(info.getCommandId());        looseMarshalByteArray(wireFormat, info.getData(), dataOut);    }}
\ No newline at end of file
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v9/WireFormatInfoMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v9/WireFormatInfoMarshaller.java
@@ -1 +1 @@
-/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v9;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for WireFormatInfoMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class WireFormatInfoMarshaller extends BaseDataStreamMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return WireFormatInfo.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new WireFormatInfo();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        WireFormatInfo info = (WireFormatInfo)o;        info.beforeUnmarshall(wireFormat);                info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));        info.setVersion(dataIn.readInt());        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        WireFormatInfo info = (WireFormatInfo)o;        info.beforeMarshall(wireFormat);        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalConstByteArray1(info.getMagic(), bs, 8);        rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        WireFormatInfo info = (WireFormatInfo)o;        tightMarshalConstByteArray2(info.getMagic(), dataOut, bs, 8);        dataOut.writeInt(info.getVersion());        tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);        info.afterMarshall(wireFormat);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        WireFormatInfo info = (WireFormatInfo)o;        info.beforeUnmarshall(wireFormat);                info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));        info.setVersion(dataIn.readInt());        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        WireFormatInfo info = (WireFormatInfo)o;        info.beforeMarshall(wireFormat);        super.looseMarshal(wireFormat, o, dataOut);        looseMarshalConstByteArray(wireFormat, info.getMagic(), dataOut, 8);        dataOut.writeInt(info.getVersion());        looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);    }}
\ No newline at end of file
+/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v9;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for WireFormatInfoMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class WireFormatInfoMarshaller extends BaseDataStreamMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return WireFormatInfo.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new WireFormatInfo();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        WireFormatInfo info = (WireFormatInfo)o;        info.beforeUnmarshall(wireFormat);                info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));        info.setVersion(dataIn.readInt());        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        WireFormatInfo info = (WireFormatInfo)o;        info.beforeMarshall(wireFormat);        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalConstByteArray1(info.getMagic(), bs, 8);        rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        WireFormatInfo info = (WireFormatInfo)o;        tightMarshalConstByteArray2(info.getMagic(), dataOut, bs, 8);        dataOut.writeInt(info.getVersion());        tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);        info.afterMarshall(wireFormat);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        WireFormatInfo info = (WireFormatInfo)o;        info.beforeUnmarshall(wireFormat);                info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));        info.setVersion(dataIn.readInt());        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        WireFormatInfo info = (WireFormatInfo)o;        info.beforeMarshall(wireFormat);        super.looseMarshal(wireFormat, o, dataOut);        looseMarshalConstByteArray(wireFormat, info.getMagic(), dataOut, 8);        dataOut.writeInt(info.getVersion());        looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);    }}
\ No newline at end of file
--- a/activemq-client/src/main/java/org/apache/activemq/openwire/v9/XATransactionIdMarshaller.java
+++ b/activemq-client/src/main/java/org/apache/activemq/openwire/v9/XATransactionIdMarshaller.java
@@ -1 +1 @@
-/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v9;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for XATransactionIdMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class XATransactionIdMarshaller extends TransactionIdMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return XATransactionId.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new XATransactionId();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        XATransactionId info = (XATransactionId)o;        info.setFormatId(dataIn.readInt());        info.setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs));        info.setBranchQualifier(tightUnmarshalByteArray(dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        XATransactionId info = (XATransactionId)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalByteArray1(info.getGlobalTransactionId(), bs);        rc += tightMarshalByteArray1(info.getBranchQualifier(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        XATransactionId info = (XATransactionId)o;        dataOut.writeInt(info.getFormatId());        tightMarshalByteArray2(info.getGlobalTransactionId(), dataOut, bs);        tightMarshalByteArray2(info.getBranchQualifier(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        XATransactionId info = (XATransactionId)o;        info.setFormatId(dataIn.readInt());        info.setGlobalTransactionId(looseUnmarshalByteArray(dataIn));        info.setBranchQualifier(looseUnmarshalByteArray(dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        XATransactionId info = (XATransactionId)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeInt(info.getFormatId());        looseMarshalByteArray(wireFormat, info.getGlobalTransactionId(), dataOut);        looseMarshalByteArray(wireFormat, info.getBranchQualifier(), dataOut);    }}
\ No newline at end of file
+/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v9;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for XATransactionIdMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class XATransactionIdMarshaller extends TransactionIdMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return XATransactionId.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new XATransactionId();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        XATransactionId info = (XATransactionId)o;        info.setFormatId(dataIn.readInt());        info.setGlobalTransactionId(tightUnmarshalByteArray(wireFormat, dataIn, bs));        info.setBranchQualifier(tightUnmarshalByteArray(wireFormat, dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        XATransactionId info = (XATransactionId)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalByteArray1(info.getGlobalTransactionId(), bs);        rc += tightMarshalByteArray1(info.getBranchQualifier(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        XATransactionId info = (XATransactionId)o;        dataOut.writeInt(info.getFormatId());        tightMarshalByteArray2(info.getGlobalTransactionId(), dataOut, bs);        tightMarshalByteArray2(info.getBranchQualifier(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        XATransactionId info = (XATransactionId)o;        info.setFormatId(dataIn.readInt());        info.setGlobalTransactionId(looseUnmarshalByteArray(wireFormat, dataIn));        info.setBranchQualifier(looseUnmarshalByteArray(wireFormat, dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        XATransactionId info = (XATransactionId)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeInt(info.getFormatId());        looseMarshalByteArray(wireFormat, info.getGlobalTransactionId(), dataOut);        looseMarshalByteArray(wireFormat, info.getBranchQualifier(), dataOut);    }}
\ No newline at end of file
--- a/activemq-client/src/main/java/org/apache/activemq/util/ByteSequence.java
+++ b/activemq-client/src/main/java/org/apache/activemq/util/ByteSequence.java
@@ -17,6 +17,8 @@
 
 package org.apache.activemq.util;
 
+import java.util.Arrays;
+
 public class ByteSequence {
 
     public byte[] data;
@@ -126,4 +128,14 @@
         }
         return true;
     }
+
+    /**
+     * Makes a deep copy of the data into a new byte array
+     * starting at the offset.
+     *
+     * @return
+     */
+    public byte[] toArray() {
+        return Arrays.copyOfRange(getData(), getOffset(), getLength());
+    }
 }
--- a/activemq-client/src/main/java/org/apache/activemq/util/IOExceptionSupport.java
+++ b/activemq-client/src/main/java/org/apache/activemq/util/IOExceptionSupport.java
@@ -52,7 +52,13 @@
 
     public static IOException createFrameSizeException(int size, long maxSize) {
         return new MaxFrameSizeExceededException("Frame size of " + toHumanReadableSizeString(size) +
-            " larger than max allowed " + toHumanReadableSizeString(maxSize));
+            " is larger than max allowed " + toHumanReadableSizeString(maxSize));
+    }
+
+    public static IOException createFrameSizeBufferException(int bufferSize, long frameSize) {
+        return new IOException("Estimated allocated buffer size of "
+          + toHumanReadableSizeString(bufferSize) + " is larger than frame size of "
+          + toHumanReadableSizeString(frameSize));
     }
 
     private static String toHumanReadableSizeString(final int size) {
--- /dev/null
+++ b/activemq-client/src/test/java/org/apache/activemq/openwire/OpenWireUtilTest.java
@@ -0,0 +1,119 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.openwire;
+
+
+import javax.jms.InvalidClientIDException;
+import javax.jms.JMSException;
+import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.MaxFrameSizeExceededException;
+import org.apache.activemq.command.WireFormatInfo;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class OpenWireUtilTest {
+
+    @Test
+    public void testValidateIsThrowable() {
+        OpenWireUtil.validateIsThrowable(Exception.class);
+        OpenWireUtil.validateIsThrowable(Throwable.class);
+        OpenWireUtil.validateIsThrowable(JMSException.class);
+        OpenWireUtil.validateIsThrowable(InvalidClientIDException.class);
+
+        try {
+            OpenWireUtil.validateIsThrowable(String.class);
+            fail("Not a valid Throwable");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+
+        try {
+            OpenWireUtil.validateIsThrowable(ActiveMQConnection.class);
+            fail("Not a valid Throwable");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    @Test
+    public void testConvertJmsPackage() {
+        // should not change
+        assertEquals(InvalidClientIDException.class.getName(),
+            OpenWireUtil.convertJmsPackage(InvalidClientIDException.class.getName()));
+
+        // should convert to correct exception type
+        assertEquals(InvalidClientIDException.class.getName(),
+            OpenWireUtil.convertJmsPackage(OpenWireUtil.jmsPackageToReplace + ".InvalidClientIDException"));
+    }
+
+    @Test
+    public void testValidateBufferSize() throws IOException {
+        OpenWireFormatFactory factory = new OpenWireFormatFactory();
+
+        var wireFormat = (OpenWireFormat) factory.createWireFormat();
+
+        // Nothing set, no validation
+        OpenWireUtil.validateBufferSize(wireFormat, 2048);
+
+        // verify max frame check works
+        try {
+            wireFormat.setMaxFrameSize(1024);
+            OpenWireUtil.validateBufferSize(wireFormat, 2048);
+            fail("should have failed");
+        } catch (MaxFrameSizeExceededException e) {
+            // expected
+        }
+
+        // rest max frame size back so we can test validating current size
+        // is less than expected buffer size
+        wireFormat.setMaxFrameSize(OpenWireFormat.DEFAULT_MAX_FRAME_SIZE);
+        WireFormatInfo wfi = new WireFormatInfo();
+        wfi.setProperty("test", "test");
+
+        // should be no error for the first 2 calls, last call should
+        // go over frame size and error
+        initContext(wireFormat, 2048);
+        OpenWireUtil.validateBufferSize(wireFormat, 1024);
+        OpenWireUtil.validateBufferSize(wireFormat, 1024);
+        try {
+            OpenWireUtil.validateBufferSize(wireFormat, 1);
+            fail("should have failed");
+        } catch (IOException e) {
+            // expected
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private void initContext(OpenWireFormat format, int frameSize) throws IOException {
+        try {
+            Field mcThreadLocalField = OpenWireFormat.class.getDeclaredField("marshallingContext");
+            mcThreadLocalField.setAccessible(true);
+            var mcThreadLocal = (ThreadLocal<OpenWireFormat.MarshallingContext>) mcThreadLocalField.get(format);
+            var context = new OpenWireFormat.MarshallingContext();
+            context.setFrameSize(frameSize);
+            mcThreadLocal.set(context);
+        } catch (ReflectiveOperationException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+}
--- a/activemq-client/src/test/java/org/apache/activemq/openwire/OpenWireValidationTest.java
+++ b/activemq-client/src/test/java/org/apache/activemq/openwire/OpenWireValidationTest.java
@@ -16,25 +16,31 @@
  */
 package org.apache.activemq.openwire;
 
-import static org.junit.Assert.assertTrue;
-
+import java.io.DataInputStream;
 import java.io.DataOutput;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
-import org.apache.activemq.command.CommandTypes;
-import org.apache.activemq.command.ExceptionResponse;
+import javassist.util.proxy.MethodHandler;
+import javassist.util.proxy.ProxyFactory;
+import javassist.util.proxy.ProxyObject;
+import org.apache.activemq.command.*;
+import org.apache.activemq.transport.nio.NIOInputStream;
 import org.apache.activemq.util.ByteSequence;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
+import static org.junit.Assert.*;
+
 /**
- * Test that Openwire marshalling will validate Throwable types during
- * unmarshalling commands that contain a Throwable
+ * Test that Openwire marshalling will validate commands correctly
  */
 @RunWith(Parameterized.class)
 public class OpenWireValidationTest {
@@ -53,7 +59,7 @@
         // This will make sure that we don't forget to update this test to include
         // any future versions that are generated
         assertTrue("List of Openwire versions does not include latest version",
-            versions.contains((int)CommandTypes.PROTOCOL_VERSION));
+            versions.contains((int) CommandTypes.PROTOCOL_VERSION));
 
         return versionObjs;
     }
@@ -63,20 +69,97 @@
     }
 
     @Test
+    public void testLooseUnmarshalByteSequenceValidation() throws Exception {
+        testUnmarshalByteSequenceValidation(false);
+    }
+
+    @Test
+    public void testTightUnmarshalByteSequenceValidation() throws Exception {
+        testUnmarshalByteSequenceValidation(true);
+    }
+
+    @Test
+    public void testLooseUnmarshalByteArray() throws Exception {
+        testUnmarshalByteArray(false);
+    }
+
+    @Test
+    public void testTightUnmarshalByteArray() throws Exception {
+        testUnmarshalByteArray(true);
+    }
+
+    // WireFormatInfo eventually delegates to BaseDataStreamMarshaller#tightUnmarshalByteSequence() and
+    // BaseDataStreamMarshaller#looseUnmarshalByteSequence()
+    private void testUnmarshalByteSequenceValidation(boolean tightEncoding) throws Exception {
+        WireFormatInfo wfi = new WireFormatInfo();
+        wfi.setProperty("prop1", "val1");
+        testUnmarshal(wfi, tightEncoding);
+    }
+
+    // PartialCommand eventually delegates to BaseDataStreamMarshaller#tightUnmarshalByteArray()
+    // and BaseDataStreamMarshaller#looseUnmarshalByteArray()
+    private void testUnmarshalByteArray(boolean tightEncoding) throws Exception {
+        PartialCommand pc = new PartialCommand();
+        pc.setData("bytes".getBytes(StandardCharsets.UTF_8));
+        testUnmarshal(pc, tightEncoding);
+    }
+
+    private void testUnmarshal(Command command, boolean tightEncoding) throws Exception {
+        var format = setupWireFormat(tightEncoding);
+        ByteSequence bss = format.marshal(command);
+        try {
+            // We should get an exception from an invalid size value that is too large
+            // Test OpenWireFormat#unmarshal(ByteSequence) method
+            format.unmarshal(bss);
+            fail("Should have received an IOException");
+        } catch (IOException io) {
+            assertTrue(io.getMessage().contains("Estimated allocated buffer size"));
+            assertTrue(io.getMessage().contains("is larger than frame size"));
+        }
+        // Verify thread local is cleared even after exception
+        assertNull(format.getMarshallingContext());
+
+        try {
+            // We should get an exception from an invalid size value that is too large
+            // Test OpenWireFormat#unmarshal(DataInput) method
+            format.unmarshal(new DataInputStream(new NIOInputStream(
+                ByteBuffer.wrap(bss.toArray()))));
+            fail("Should have received an IOException");
+        } catch (IOException io) {
+            assertTrue(io.getMessage().contains("Estimated allocated buffer size"));
+            assertTrue(io.getMessage().contains("is larger than frame size"));
+        }
+        // Verify thread local is cleared even after exception
+        assertNull(format.getMarshallingContext());
+    }
+
+    // Verify MarshallingContext thread local is cleared where there is
+    // successful unmarshalling and no error. The other tests that check
+    // validation works if invalid size will validate the context is cleared
+    // when there is an error
+    @Test
+    public void testUnmarshalNoErrorClearContext() throws Exception {
+        var format = new OpenWireFormat();
+        ByteSequence bss = format.marshal(new ConnectionInfo());
+
+        // make sure context cleared after calling
+        // OpenWireFormat#unmarshal(ByteSequence) method
+        format.unmarshal(bss);
+        assertNull(format.getMarshallingContext());
+
+        // Make sure context cleared after calling
+        // OpenWireFormat#unmarshal(DataInput) method
+        format.unmarshal(new DataInputStream(new NIOInputStream(
+            ByteBuffer.wrap(bss.toArray()))));
+        assertNull(format.getMarshallingContext());
+    }
+
+    @Test
     public void testOpenwireThrowableValidation() throws Exception {
         // Create a format which will use loose encoding by default
         // The code for handling exception creation is shared between both
         // tight/loose encoding so only need to test 1
-        OpenWireFormat format = new OpenWireFormat();
-
-        // Override the marshaller map with a custom impl to purposely marshal a class type that is
-        // not a Throwable for testing the unmarshaller
-        Class<?> marshallerFactory = getMarshallerFactory();
-        Method createMarshallerMap = marshallerFactory.getMethod("createMarshallerMap", OpenWireFormat.class);
-        DataStreamMarshaller[] map = (DataStreamMarshaller[]) createMarshallerMap.invoke(marshallerFactory, format);
-        map[ExceptionResponse.DATA_STRUCTURE_TYPE] = getExceptionMarshaller();
-        // This will trigger updating the marshaller from the marshaller map with the right version
-        format.setVersion(version);
+        var format = setupWireFormat(false);
 
         // Build the response and try to unmarshal which should give an IllegalArgumentExeption on unmarshall
         // as the test marshaller should have encoded a class type that is not a Throwable
@@ -89,6 +172,23 @@
         assertTrue(response.getException().getMessage().contains("is not assignable to Throwable"));
     }
 
+    private OpenWireFormat setupWireFormat(boolean tightEncoding) throws Exception {
+        // Create a format
+        OpenWireFormat format = new OpenWireFormat();
+        format.setTightEncodingEnabled(tightEncoding);
+
+        // Override the marshaller map with a custom impl to purposely marshal a bad size value
+        Class<?> marshallerFactory = getMarshallerFactory();
+        Method createMarshallerMap = marshallerFactory.getMethod("createMarshallerMap", OpenWireFormat.class);
+        DataStreamMarshaller[] map = (DataStreamMarshaller[]) createMarshallerMap.invoke(marshallerFactory, format);
+        map[ExceptionResponse.DATA_STRUCTURE_TYPE] = getExceptionMarshaller();
+        map[WireFormatInfo.DATA_STRUCTURE_TYPE] = getWireFormatInfoMarshaller();
+        map[PartialCommand.DATA_STRUCTURE_TYPE] = getPartialCommandMarshaller();
+        // This will trigger updating the marshaller from the marshaller map with the right version
+        format.setVersion(version);
+        return format;
+    }
+
     static class NotAThrowable {
         private String message;
 
@@ -163,4 +263,127 @@
         }
     }
 
+    // Create test marshallers for all non-legacy versions
+    // WireFormatInfo will test the bytesequence marshallers
+    protected DataStreamMarshaller getWireFormatInfoMarshaller() {
+        switch (version) {
+            case 12:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v12.WireFormatInfoMarshaller());
+            case 11:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v11.WireFormatInfoMarshaller());
+            case 10:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v10.WireFormatInfoMarshaller());
+            case 9:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v9.WireFormatInfoMarshaller());
+            case 1:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v1.WireFormatInfoMarshaller());
+            default:
+                throw new IllegalArgumentException("Unknown OpenWire version of " + version);
+        }
+    }
+
+    // PartialCommand will test the byte array marshallers
+    protected DataStreamMarshaller getPartialCommandMarshaller() {
+        switch (version) {
+            case 12:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v12.PartialCommandMarshaller());
+            case 11:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v11.PartialCommandMarshaller());
+            case 10:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v10.PartialCommandMarshaller());
+            case 9:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v9.PartialCommandMarshaller());
+            case 1:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v1.PartialCommandMarshaller());
+            default:
+                throw new IllegalArgumentException("Unknown OpenWire version of " + version);
+        }
+    }
+
+    protected static void badTightMarshalByteSequence(ByteSequence data, DataOutput dataOut,
+                                               BooleanStream bs) throws IOException {
+        if (bs.readBoolean()) {
+            // Write an invalid length that is much larger than it should be
+            dataOut.writeInt(data.getLength() * 10);
+            dataOut.write(data.getData(), data.getOffset(), data.getLength());
+        }
+    }
+
+    protected static void badLooseMarshalByteSequence(ByteSequence data, DataOutput dataOut)
+        throws IOException {
+        dataOut.writeBoolean(data != null);
+        if (data != null) {
+            // Write an invalid length that is much larger than it should be
+            dataOut.writeInt(data.getLength() * 10);
+            dataOut.write(data.getData(), data.getOffset(), data.getLength());
+        }
+    }
+
+    protected static void badLooseMarshalByteArray(byte[] data,
+                                            DataOutput dataOut) throws IOException {
+        dataOut.writeBoolean(data != null);
+        if (data != null) {
+            // Write an invalid length that is much larger than it should be
+            dataOut.writeInt(data.length * 10);
+            dataOut.write(data);
+        }
+    }
+
+    protected static void badTightMarshalByteArray(byte[] data, DataOutput dataOut,
+                                            BooleanStream bs) throws IOException {
+        if (bs.readBoolean()) {
+            // Write an invalid length that is much larger than it should be
+            dataOut.writeInt(data.length * 10);
+            dataOut.write(data);
+        }
+    }
+
+    // This will create a proxy object to wrap the marhallers so that we can intercept
+    // both the byte and bytesequence methods to write bad sizes for testing
+    protected DataStreamMarshaller proxyBadBufferCommand(DataStreamMarshaller marshaller) {
+        ProxyFactory factory = new ProxyFactory();
+        factory.setSuperclass(marshaller.getClass());
+        Class<?> clazz = factory.createClass();
+
+        try {
+            DataStreamMarshaller instance = (DataStreamMarshaller) clazz.getConstructor().newInstance();
+            ((ProxyObject) instance).setHandler(new BadBufferProxy());
+            return instance;
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    protected static class BadBufferProxy implements MethodHandler {
+
+        @Override
+        public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable {
+            Object result = null;
+
+            try {
+                // This handles writing a bad size for all 4 types of methods that should validate
+                switch (thisMethod.getName()) {
+                    case "looseMarshalByteArray":
+                        badLooseMarshalByteArray((byte[]) args[1], (DataOutput) args[2]);
+                        break;
+                    case "tightMarshalByteArray2":
+                        badTightMarshalByteArray((byte[]) args[0], (DataOutput) args[1], (BooleanStream) args[2]);
+                        break;
+                    case "looseMarshalByteSequence":
+                        badLooseMarshalByteSequence((ByteSequence) args[1], (DataOutput) args[2]);
+                        break;
+                    case "tightMarshalByteSequence2":
+                        badTightMarshalByteSequence((ByteSequence) args[0], (DataOutput) args[1], (BooleanStream) args[2]);
+                        break;
+                    default:
+                        result = proceed.invoke(self, args);
+                        break;
+                }
+            } catch (InvocationTargetException e) {
+                throw e.getCause();
+            }
+
+            return result;
+        }
+    }
 }
--- a/activemq-openwire-legacy/pom.xml
+++ b/activemq-openwire-legacy/pom.xml
@@ -47,6 +47,11 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.javassist</groupId>
+      <artifactId>javassist</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 </project>
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v2/BaseDataStreamMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v2/BaseDataStreamMarshaller.java
@@ -410,10 +410,11 @@
         }
     }
 
-    protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected byte[] tightUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         byte rc[] = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -437,10 +438,11 @@
         }
     }
 
-    protected ByteSequence tightUnmarshalByteSequence(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected ByteSequence tightUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         ByteSequence rc = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             return new ByteSequence(t, 0, size);
@@ -617,10 +619,11 @@
         }
     }
 
-    protected byte[] looseUnmarshalByteArray(DataInput dataIn) throws IOException {
+    protected byte[] looseUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         byte rc[] = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -636,10 +639,11 @@
         }
     }
 
-    protected ByteSequence looseUnmarshalByteSequence(DataInput dataIn) throws IOException {
+    protected ByteSequence looseUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         ByteSequence rc = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             rc = new ByteSequence(t, 0, size);
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v2/MessageMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v2/MessageMarshaller.java
@@ -65,8 +65,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination)tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));
         info.setType(tightUnmarshalString(dataIn, bs));
-        info.setContent(tightUnmarshalByteSequence(dataIn, bs));
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setContent(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
         info.setDataStructure((org.apache.activemq.command.DataStructure)tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
         info.setCompressed(bs.readBoolean());
@@ -199,8 +199,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
         info.setType(looseUnmarshalString(dataIn));
-        info.setContent(looseUnmarshalByteSequence(dataIn));
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setContent(looseUnmarshalByteSequence(wireFormat, dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
         info.setDataStructure((org.apache.activemq.command.DataStructure)looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId)looseUnmarsalCachedObject(wireFormat, dataIn));
         info.setCompressed(dataIn.readBoolean());
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v2/PartialCommandMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v2/PartialCommandMarshaller.java
@@ -68,7 +68,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(tightUnmarshalByteArray(dataIn, bs));
+        info.setData(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -114,7 +114,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(looseUnmarshalByteArray(dataIn));
+        info.setData(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v2/WireFormatInfoMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v2/WireFormatInfoMarshaller.java
@@ -72,7 +72,7 @@
         
         info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
 
         info.afterUnmarshall(wireFormat);
 
@@ -130,7 +130,7 @@
         
         info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
 
         info.afterUnmarshall(wireFormat);
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v2/XATransactionIdMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v2/XATransactionIdMarshaller.java
@@ -68,8 +68,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs));
-        info.setBranchQualifier(tightUnmarshalByteArray(dataIn, bs));
+        info.setGlobalTransactionId(tightUnmarshalByteArray(wireFormat, dataIn, bs));
+        info.setBranchQualifier(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -117,8 +117,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(looseUnmarshalByteArray(dataIn));
-        info.setBranchQualifier(looseUnmarshalByteArray(dataIn));
+        info.setGlobalTransactionId(looseUnmarshalByteArray(wireFormat, dataIn));
+        info.setBranchQualifier(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v3/BaseDataStreamMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v3/BaseDataStreamMarshaller.java
@@ -410,10 +410,11 @@
         }
     }
 
-    protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected byte[] tightUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         byte rc[] = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -437,10 +438,11 @@
         }
     }
 
-    protected ByteSequence tightUnmarshalByteSequence(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected ByteSequence tightUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         ByteSequence rc = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             return new ByteSequence(t, 0, size);
@@ -617,10 +619,11 @@
         }
     }
 
-    protected byte[] looseUnmarshalByteArray(DataInput dataIn) throws IOException {
+    protected byte[] looseUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         byte rc[] = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -636,10 +639,11 @@
         }
     }
 
-    protected ByteSequence looseUnmarshalByteSequence(DataInput dataIn) throws IOException {
+    protected ByteSequence looseUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         ByteSequence rc = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             rc = new ByteSequence(t, 0, size);
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v3/MessageMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v3/MessageMarshaller.java
@@ -65,8 +65,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination)tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));
         info.setType(tightUnmarshalString(dataIn, bs));
-        info.setContent(tightUnmarshalByteSequence(dataIn, bs));
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setContent(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
         info.setDataStructure((org.apache.activemq.command.DataStructure)tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId)tightUnmarsalCachedObject(wireFormat, dataIn, bs));
         info.setCompressed(bs.readBoolean());
@@ -218,8 +218,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination)looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
         info.setType(looseUnmarshalString(dataIn));
-        info.setContent(looseUnmarshalByteSequence(dataIn));
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setContent(looseUnmarshalByteSequence(wireFormat, dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
         info.setDataStructure((org.apache.activemq.command.DataStructure)looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId)looseUnmarsalCachedObject(wireFormat, dataIn));
         info.setCompressed(dataIn.readBoolean());
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v3/PartialCommandMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v3/PartialCommandMarshaller.java
@@ -68,7 +68,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(tightUnmarshalByteArray(dataIn, bs));
+        info.setData(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -114,7 +114,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(looseUnmarshalByteArray(dataIn));
+        info.setData(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v3/WireFormatInfoMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v3/WireFormatInfoMarshaller.java
@@ -72,7 +72,7 @@
         
         info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
 
         info.afterUnmarshall(wireFormat);
 
@@ -130,7 +130,7 @@
         
         info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
 
         info.afterUnmarshall(wireFormat);
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v3/XATransactionIdMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v3/XATransactionIdMarshaller.java
@@ -68,8 +68,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs));
-        info.setBranchQualifier(tightUnmarshalByteArray(dataIn, bs));
+        info.setGlobalTransactionId(tightUnmarshalByteArray(wireFormat, dataIn, bs));
+        info.setBranchQualifier(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -117,8 +117,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(looseUnmarshalByteArray(dataIn));
-        info.setBranchQualifier(looseUnmarshalByteArray(dataIn));
+        info.setGlobalTransactionId(looseUnmarshalByteArray(wireFormat, dataIn));
+        info.setBranchQualifier(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v4/BaseDataStreamMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v4/BaseDataStreamMarshaller.java
@@ -410,10 +410,11 @@
         }
     }
 
-    protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected byte[] tightUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         byte rc[] = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -437,10 +438,11 @@
         }
     }
 
-    protected ByteSequence tightUnmarshalByteSequence(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected ByteSequence tightUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         ByteSequence rc = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             return new ByteSequence(t, 0, size);
@@ -617,10 +619,11 @@
         }
     }
 
-    protected byte[] looseUnmarshalByteArray(DataInput dataIn) throws IOException {
+    protected byte[] looseUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         byte rc[] = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -636,10 +639,11 @@
         }
     }
 
-    protected ByteSequence looseUnmarshalByteSequence(DataInput dataIn) throws IOException {
+    protected ByteSequence looseUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         ByteSequence rc = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             rc = new ByteSequence(t, 0, size);
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v4/MessageMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v4/MessageMarshaller.java
@@ -69,8 +69,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));
         info.setType(tightUnmarshalString(dataIn, bs));
-        info.setContent(tightUnmarshalByteSequence(dataIn, bs));
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setContent(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
         info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
         info.setCompressed(bs.readBoolean());
@@ -225,8 +225,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
         info.setType(looseUnmarshalString(dataIn));
-        info.setContent(looseUnmarshalByteSequence(dataIn));
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setContent(looseUnmarshalByteSequence(wireFormat, dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
         info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));
         info.setCompressed(dataIn.readBoolean());
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v4/PartialCommandMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v4/PartialCommandMarshaller.java
@@ -67,7 +67,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(tightUnmarshalByteArray(dataIn, bs));
+        info.setData(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -113,7 +113,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(looseUnmarshalByteArray(dataIn));
+        info.setData(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v4/WireFormatInfoMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v4/WireFormatInfoMarshaller.java
@@ -71,7 +71,7 @@
         
         info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
 
         info.afterUnmarshall(wireFormat);
 
@@ -129,7 +129,7 @@
         
         info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
 
         info.afterUnmarshall(wireFormat);
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v4/XATransactionIdMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v4/XATransactionIdMarshaller.java
@@ -67,8 +67,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs));
-        info.setBranchQualifier(tightUnmarshalByteArray(dataIn, bs));
+        info.setGlobalTransactionId(tightUnmarshalByteArray(wireFormat, dataIn, bs));
+        info.setBranchQualifier(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -116,8 +116,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(looseUnmarshalByteArray(dataIn));
-        info.setBranchQualifier(looseUnmarshalByteArray(dataIn));
+        info.setGlobalTransactionId(looseUnmarshalByteArray(wireFormat, dataIn));
+        info.setBranchQualifier(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v5/BaseDataStreamMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v5/BaseDataStreamMarshaller.java
@@ -410,10 +410,11 @@
         }
     }
 
-    protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected byte[] tightUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         byte rc[] = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -437,10 +438,11 @@
         }
     }
 
-    protected ByteSequence tightUnmarshalByteSequence(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected ByteSequence tightUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         ByteSequence rc = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             return new ByteSequence(t, 0, size);
@@ -617,10 +619,11 @@
         }
     }
 
-    protected byte[] looseUnmarshalByteArray(DataInput dataIn) throws IOException {
+    protected byte[] looseUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         byte rc[] = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -636,10 +639,11 @@
         }
     }
 
-    protected ByteSequence looseUnmarshalByteSequence(DataInput dataIn) throws IOException {
+    protected ByteSequence looseUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         ByteSequence rc = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             rc = new ByteSequence(t, 0, size);
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v5/MessageMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v5/MessageMarshaller.java
@@ -69,8 +69,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));
         info.setType(tightUnmarshalString(dataIn, bs));
-        info.setContent(tightUnmarshalByteSequence(dataIn, bs));
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setContent(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
         info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
         info.setCompressed(bs.readBoolean());
@@ -225,8 +225,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
         info.setType(looseUnmarshalString(dataIn));
-        info.setContent(looseUnmarshalByteSequence(dataIn));
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setContent(looseUnmarshalByteSequence(wireFormat, dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
         info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));
         info.setCompressed(dataIn.readBoolean());
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v5/PartialCommandMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v5/PartialCommandMarshaller.java
@@ -67,7 +67,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(tightUnmarshalByteArray(dataIn, bs));
+        info.setData(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -113,7 +113,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(looseUnmarshalByteArray(dataIn));
+        info.setData(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v5/WireFormatInfoMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v5/WireFormatInfoMarshaller.java
@@ -71,7 +71,7 @@
         
         info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
 
         info.afterUnmarshall(wireFormat);
 
@@ -129,7 +129,7 @@
         
         info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
 
         info.afterUnmarshall(wireFormat);
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v5/XATransactionIdMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v5/XATransactionIdMarshaller.java
@@ -67,8 +67,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs));
-        info.setBranchQualifier(tightUnmarshalByteArray(dataIn, bs));
+        info.setGlobalTransactionId(tightUnmarshalByteArray(wireFormat, dataIn, bs));
+        info.setBranchQualifier(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -116,8 +116,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(looseUnmarshalByteArray(dataIn));
-        info.setBranchQualifier(looseUnmarshalByteArray(dataIn));
+        info.setGlobalTransactionId(looseUnmarshalByteArray(wireFormat, dataIn));
+        info.setBranchQualifier(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v6/BaseDataStreamMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v6/BaseDataStreamMarshaller.java
@@ -410,10 +410,11 @@
         }
     }
 
-    protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected byte[] tightUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         byte rc[] = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -437,10 +438,11 @@
         }
     }
 
-    protected ByteSequence tightUnmarshalByteSequence(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected ByteSequence tightUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         ByteSequence rc = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             return new ByteSequence(t, 0, size);
@@ -617,10 +619,11 @@
         }
     }
 
-    protected byte[] looseUnmarshalByteArray(DataInput dataIn) throws IOException {
+    protected byte[] looseUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         byte rc[] = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -636,10 +639,11 @@
         }
     }
 
-    protected ByteSequence looseUnmarshalByteSequence(DataInput dataIn) throws IOException {
+    protected ByteSequence looseUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         ByteSequence rc = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             rc = new ByteSequence(t, 0, size);
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v6/MessageMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v6/MessageMarshaller.java
@@ -69,8 +69,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));
         info.setType(tightUnmarshalString(dataIn, bs));
-        info.setContent(tightUnmarshalByteSequence(dataIn, bs));
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setContent(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
         info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));
         info.setCompressed(bs.readBoolean());
@@ -225,8 +225,8 @@
         info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));
         info.setType(looseUnmarshalString(dataIn));
-        info.setContent(looseUnmarshalByteSequence(dataIn));
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setContent(looseUnmarshalByteSequence(wireFormat, dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
         info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));
         info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));
         info.setCompressed(dataIn.readBoolean());
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v6/PartialCommandMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v6/PartialCommandMarshaller.java
@@ -67,7 +67,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(tightUnmarshalByteArray(dataIn, bs));
+        info.setData(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -113,7 +113,7 @@
 
         PartialCommand info = (PartialCommand)o;
         info.setCommandId(dataIn.readInt());
-        info.setData(looseUnmarshalByteArray(dataIn));
+        info.setData(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v6/WireFormatInfoMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v6/WireFormatInfoMarshaller.java
@@ -71,7 +71,7 @@
         
         info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));
+        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));
 
         info.afterUnmarshall(wireFormat);
 
@@ -129,7 +129,7 @@
         
         info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));
         info.setVersion(dataIn.readInt());
-        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));
+        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));
 
         info.afterUnmarshall(wireFormat);
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v6/XATransactionIdMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v6/XATransactionIdMarshaller.java
@@ -67,8 +67,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs));
-        info.setBranchQualifier(tightUnmarshalByteArray(dataIn, bs));
+        info.setGlobalTransactionId(tightUnmarshalByteArray(wireFormat, dataIn, bs));
+        info.setBranchQualifier(tightUnmarshalByteArray(wireFormat, dataIn, bs));
 
     }
 
@@ -116,8 +116,8 @@
 
         XATransactionId info = (XATransactionId)o;
         info.setFormatId(dataIn.readInt());
-        info.setGlobalTransactionId(looseUnmarshalByteArray(dataIn));
-        info.setBranchQualifier(looseUnmarshalByteArray(dataIn));
+        info.setGlobalTransactionId(looseUnmarshalByteArray(wireFormat, dataIn));
+        info.setBranchQualifier(looseUnmarshalByteArray(wireFormat, dataIn));
 
     }
 
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v7/BaseDataStreamMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v7/BaseDataStreamMarshaller.java
@@ -409,10 +409,11 @@
         }
     }
 
-    protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected byte[] tightUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         byte rc[] = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -436,10 +437,11 @@
         }
     }
 
-    protected ByteSequence tightUnmarshalByteSequence(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected ByteSequence tightUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         ByteSequence rc = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             return new ByteSequence(t, 0, size);
@@ -616,10 +618,11 @@
         }
     }
 
-    protected byte[] looseUnmarshalByteArray(DataInput dataIn) throws IOException {
+    protected byte[] looseUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         byte rc[] = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -635,10 +638,11 @@
         }
     }
 
-    protected ByteSequence looseUnmarshalByteSequence(DataInput dataIn) throws IOException {
+    protected ByteSequence looseUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         ByteSequence rc = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             rc = new ByteSequence(t, 0, size);
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v7/MessageMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v7/MessageMarshaller.java
@@ -1 +1 @@
-/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v7;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for MessageMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public abstract class MessageMarshaller extends BaseCommandMarshaller {    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        Message info = (Message)o;        info.beforeUnmarshall(wireFormat);                info.setProducerId((org.apache.activemq.command.ProducerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setMessageId((org.apache.activemq.command.MessageId) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setGroupID(tightUnmarshalString(dataIn, bs));        info.setGroupSequence(dataIn.readInt());        info.setCorrelationId(tightUnmarshalString(dataIn, bs));        info.setPersistent(bs.readBoolean());        info.setExpiration(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setPriority(dataIn.readByte());        info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setType(tightUnmarshalString(dataIn, bs));        info.setContent(tightUnmarshalByteSequence(dataIn, bs));        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));        info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setCompressed(bs.readBoolean());        info.setRedeliveryCounter(dataIn.readInt());        if (bs.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);            }            info.setBrokerPath(value);        }        else {            info.setBrokerPath(null);        }        info.setArrival(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setUserID(tightUnmarshalString(dataIn, bs));        info.setRecievedByDFBridge(bs.readBoolean());        info.setDroppable(bs.readBoolean());        if (bs.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);            }            info.setCluster(value);        }        else {            info.setCluster(null);        }        info.setBrokerInTime(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setBrokerOutTime(tightUnmarshalLong(wireFormat, dataIn, bs));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        Message info = (Message)o;        info.beforeMarshall(wireFormat);        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalDestination(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalTransactionId(), bs);        rc += tightMarshalString1(info.getGroupID(), bs);        rc += tightMarshalString1(info.getCorrelationId(), bs);        bs.writeBoolean(info.isPersistent());        rc+=tightMarshalLong1(wireFormat, info.getExpiration(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getReplyTo(), bs);        rc+=tightMarshalLong1(wireFormat, info.getTimestamp(), bs);        rc += tightMarshalString1(info.getType(), bs);        rc += tightMarshalByteSequence1(info.getContent(), bs);        rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDataStructure(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTargetConsumerId(), bs);        bs.writeBoolean(info.isCompressed());        rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);        rc+=tightMarshalLong1(wireFormat, info.getArrival(), bs);        rc += tightMarshalString1(info.getUserID(), bs);        bs.writeBoolean(info.isRecievedByDFBridge());        bs.writeBoolean(info.isDroppable());        rc += tightMarshalObjectArray1(wireFormat, info.getCluster(), bs);        rc+=tightMarshalLong1(wireFormat, info.getBrokerInTime(), bs);        rc+=tightMarshalLong1(wireFormat, info.getBrokerOutTime(), bs);        return rc + 9;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        Message info = (Message)o;        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut, bs);        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut, bs);        tightMarshalString2(info.getGroupID(), dataOut, bs);        dataOut.writeInt(info.getGroupSequence());        tightMarshalString2(info.getCorrelationId(), dataOut, bs);        bs.readBoolean();        tightMarshalLong2(wireFormat, info.getExpiration(), dataOut, bs);        dataOut.writeByte(info.getPriority());        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getReplyTo(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getTimestamp(), dataOut, bs);        tightMarshalString2(info.getType(), dataOut, bs);        tightMarshalByteSequence2(info.getContent(), dataOut, bs);        tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDataStructure(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut, bs);        bs.readBoolean();        dataOut.writeInt(info.getRedeliveryCounter());        tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getArrival(), dataOut, bs);        tightMarshalString2(info.getUserID(), dataOut, bs);        bs.readBoolean();        bs.readBoolean();        tightMarshalObjectArray2(wireFormat, info.getCluster(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getBrokerInTime(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getBrokerOutTime(), dataOut, bs);        info.afterMarshall(wireFormat);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        Message info = (Message)o;        info.beforeUnmarshall(wireFormat);                info.setProducerId((org.apache.activemq.command.ProducerId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setGroupID(looseUnmarshalString(dataIn));        info.setGroupSequence(dataIn.readInt());        info.setCorrelationId(looseUnmarshalString(dataIn));        info.setPersistent(dataIn.readBoolean());        info.setExpiration(looseUnmarshalLong(wireFormat, dataIn));        info.setPriority(dataIn.readByte());        info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));        info.setType(looseUnmarshalString(dataIn));        info.setContent(looseUnmarshalByteSequence(dataIn));        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));        info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setCompressed(dataIn.readBoolean());        info.setRedeliveryCounter(dataIn.readInt());        if (dataIn.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);            }            info.setBrokerPath(value);        }        else {            info.setBrokerPath(null);        }        info.setArrival(looseUnmarshalLong(wireFormat, dataIn));        info.setUserID(looseUnmarshalString(dataIn));        info.setRecievedByDFBridge(dataIn.readBoolean());        info.setDroppable(dataIn.readBoolean());        if (dataIn.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);            }            info.setCluster(value);        }        else {            info.setCluster(null);        }        info.setBrokerInTime(looseUnmarshalLong(wireFormat, dataIn));        info.setBrokerOutTime(looseUnmarshalLong(wireFormat, dataIn));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        Message info = (Message)o;        info.beforeMarshall(wireFormat);        super.looseMarshal(wireFormat, o, dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut);        looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut);        looseMarshalString(info.getGroupID(), dataOut);        dataOut.writeInt(info.getGroupSequence());        looseMarshalString(info.getCorrelationId(), dataOut);        dataOut.writeBoolean(info.isPersistent());        looseMarshalLong(wireFormat, info.getExpiration(), dataOut);        dataOut.writeByte(info.getPriority());        looseMarshalNestedObject(wireFormat, (DataStructure)info.getReplyTo(), dataOut);        looseMarshalLong(wireFormat, info.getTimestamp(), dataOut);        looseMarshalString(info.getType(), dataOut);        looseMarshalByteSequence(wireFormat, info.getContent(), dataOut);        looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);        looseMarshalNestedObject(wireFormat, (DataStructure)info.getDataStructure(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut);        dataOut.writeBoolean(info.isCompressed());        dataOut.writeInt(info.getRedeliveryCounter());        looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);        looseMarshalLong(wireFormat, info.getArrival(), dataOut);        looseMarshalString(info.getUserID(), dataOut);        dataOut.writeBoolean(info.isRecievedByDFBridge());        dataOut.writeBoolean(info.isDroppable());        looseMarshalObjectArray(wireFormat, info.getCluster(), dataOut);        looseMarshalLong(wireFormat, info.getBrokerInTime(), dataOut);        looseMarshalLong(wireFormat, info.getBrokerOutTime(), dataOut);    }}
\ No newline at end of file
+/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v7;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for MessageMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public abstract class MessageMarshaller extends BaseCommandMarshaller {    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        Message info = (Message)o;        info.beforeUnmarshall(wireFormat);                info.setProducerId((org.apache.activemq.command.ProducerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setMessageId((org.apache.activemq.command.MessageId) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setGroupID(tightUnmarshalString(dataIn, bs));        info.setGroupSequence(dataIn.readInt());        info.setCorrelationId(tightUnmarshalString(dataIn, bs));        info.setPersistent(bs.readBoolean());        info.setExpiration(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setPriority(dataIn.readByte());        info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setType(tightUnmarshalString(dataIn, bs));        info.setContent(tightUnmarshalByteSequence(wireFormat, dataIn, bs));        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));        info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setCompressed(bs.readBoolean());        info.setRedeliveryCounter(dataIn.readInt());        if (bs.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);            }            info.setBrokerPath(value);        }        else {            info.setBrokerPath(null);        }        info.setArrival(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setUserID(tightUnmarshalString(dataIn, bs));        info.setRecievedByDFBridge(bs.readBoolean());        info.setDroppable(bs.readBoolean());        if (bs.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);            }            info.setCluster(value);        }        else {            info.setCluster(null);        }        info.setBrokerInTime(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setBrokerOutTime(tightUnmarshalLong(wireFormat, dataIn, bs));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        Message info = (Message)o;        info.beforeMarshall(wireFormat);        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalDestination(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalTransactionId(), bs);        rc += tightMarshalString1(info.getGroupID(), bs);        rc += tightMarshalString1(info.getCorrelationId(), bs);        bs.writeBoolean(info.isPersistent());        rc+=tightMarshalLong1(wireFormat, info.getExpiration(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getReplyTo(), bs);        rc+=tightMarshalLong1(wireFormat, info.getTimestamp(), bs);        rc += tightMarshalString1(info.getType(), bs);        rc += tightMarshalByteSequence1(info.getContent(), bs);        rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDataStructure(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTargetConsumerId(), bs);        bs.writeBoolean(info.isCompressed());        rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);        rc+=tightMarshalLong1(wireFormat, info.getArrival(), bs);        rc += tightMarshalString1(info.getUserID(), bs);        bs.writeBoolean(info.isRecievedByDFBridge());        bs.writeBoolean(info.isDroppable());        rc += tightMarshalObjectArray1(wireFormat, info.getCluster(), bs);        rc+=tightMarshalLong1(wireFormat, info.getBrokerInTime(), bs);        rc+=tightMarshalLong1(wireFormat, info.getBrokerOutTime(), bs);        return rc + 9;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        Message info = (Message)o;        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut, bs);        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut, bs);        tightMarshalString2(info.getGroupID(), dataOut, bs);        dataOut.writeInt(info.getGroupSequence());        tightMarshalString2(info.getCorrelationId(), dataOut, bs);        bs.readBoolean();        tightMarshalLong2(wireFormat, info.getExpiration(), dataOut, bs);        dataOut.writeByte(info.getPriority());        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getReplyTo(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getTimestamp(), dataOut, bs);        tightMarshalString2(info.getType(), dataOut, bs);        tightMarshalByteSequence2(info.getContent(), dataOut, bs);        tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDataStructure(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut, bs);        bs.readBoolean();        dataOut.writeInt(info.getRedeliveryCounter());        tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getArrival(), dataOut, bs);        tightMarshalString2(info.getUserID(), dataOut, bs);        bs.readBoolean();        bs.readBoolean();        tightMarshalObjectArray2(wireFormat, info.getCluster(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getBrokerInTime(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getBrokerOutTime(), dataOut, bs);        info.afterMarshall(wireFormat);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        Message info = (Message)o;        info.beforeUnmarshall(wireFormat);                info.setProducerId((org.apache.activemq.command.ProducerId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setGroupID(looseUnmarshalString(dataIn));        info.setGroupSequence(dataIn.readInt());        info.setCorrelationId(looseUnmarshalString(dataIn));        info.setPersistent(dataIn.readBoolean());        info.setExpiration(looseUnmarshalLong(wireFormat, dataIn));        info.setPriority(dataIn.readByte());        info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));        info.setType(looseUnmarshalString(dataIn));        info.setContent(looseUnmarshalByteSequence(wireFormat, dataIn));        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));        info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setCompressed(dataIn.readBoolean());        info.setRedeliveryCounter(dataIn.readInt());        if (dataIn.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);            }            info.setBrokerPath(value);        }        else {            info.setBrokerPath(null);        }        info.setArrival(looseUnmarshalLong(wireFormat, dataIn));        info.setUserID(looseUnmarshalString(dataIn));        info.setRecievedByDFBridge(dataIn.readBoolean());        info.setDroppable(dataIn.readBoolean());        if (dataIn.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);            }            info.setCluster(value);        }        else {            info.setCluster(null);        }        info.setBrokerInTime(looseUnmarshalLong(wireFormat, dataIn));        info.setBrokerOutTime(looseUnmarshalLong(wireFormat, dataIn));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        Message info = (Message)o;        info.beforeMarshall(wireFormat);        super.looseMarshal(wireFormat, o, dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut);        looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut);        looseMarshalString(info.getGroupID(), dataOut);        dataOut.writeInt(info.getGroupSequence());        looseMarshalString(info.getCorrelationId(), dataOut);        dataOut.writeBoolean(info.isPersistent());        looseMarshalLong(wireFormat, info.getExpiration(), dataOut);        dataOut.writeByte(info.getPriority());        looseMarshalNestedObject(wireFormat, (DataStructure)info.getReplyTo(), dataOut);        looseMarshalLong(wireFormat, info.getTimestamp(), dataOut);        looseMarshalString(info.getType(), dataOut);        looseMarshalByteSequence(wireFormat, info.getContent(), dataOut);        looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);        looseMarshalNestedObject(wireFormat, (DataStructure)info.getDataStructure(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut);        dataOut.writeBoolean(info.isCompressed());        dataOut.writeInt(info.getRedeliveryCounter());        looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);        looseMarshalLong(wireFormat, info.getArrival(), dataOut);        looseMarshalString(info.getUserID(), dataOut);        dataOut.writeBoolean(info.isRecievedByDFBridge());        dataOut.writeBoolean(info.isDroppable());        looseMarshalObjectArray(wireFormat, info.getCluster(), dataOut);        looseMarshalLong(wireFormat, info.getBrokerInTime(), dataOut);        looseMarshalLong(wireFormat, info.getBrokerOutTime(), dataOut);    }}
\ No newline at end of file
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v7/PartialCommandMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v7/PartialCommandMarshaller.java
@@ -1 +1 @@
-/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v7;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for PartialCommandMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class PartialCommandMarshaller extends BaseDataStreamMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return PartialCommand.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new PartialCommand();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        PartialCommand info = (PartialCommand)o;        info.setCommandId(dataIn.readInt());        info.setData(tightUnmarshalByteArray(dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        PartialCommand info = (PartialCommand)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalByteArray1(info.getData(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        PartialCommand info = (PartialCommand)o;        dataOut.writeInt(info.getCommandId());        tightMarshalByteArray2(info.getData(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        PartialCommand info = (PartialCommand)o;        info.setCommandId(dataIn.readInt());        info.setData(looseUnmarshalByteArray(dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        PartialCommand info = (PartialCommand)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeInt(info.getCommandId());        looseMarshalByteArray(wireFormat, info.getData(), dataOut);    }}
\ No newline at end of file
+/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v7;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for PartialCommandMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class PartialCommandMarshaller extends BaseDataStreamMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return PartialCommand.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new PartialCommand();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        PartialCommand info = (PartialCommand)o;        info.setCommandId(dataIn.readInt());        info.setData(tightUnmarshalByteArray(wireFormat, dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        PartialCommand info = (PartialCommand)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalByteArray1(info.getData(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        PartialCommand info = (PartialCommand)o;        dataOut.writeInt(info.getCommandId());        tightMarshalByteArray2(info.getData(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        PartialCommand info = (PartialCommand)o;        info.setCommandId(dataIn.readInt());        info.setData(looseUnmarshalByteArray(wireFormat, dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        PartialCommand info = (PartialCommand)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeInt(info.getCommandId());        looseMarshalByteArray(wireFormat, info.getData(), dataOut);    }}
\ No newline at end of file
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v7/WireFormatInfoMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v7/WireFormatInfoMarshaller.java
@@ -1 +1 @@
-/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v7;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for WireFormatInfoMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class WireFormatInfoMarshaller extends BaseDataStreamMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return WireFormatInfo.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new WireFormatInfo();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        WireFormatInfo info = (WireFormatInfo)o;        info.beforeUnmarshall(wireFormat);                info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));        info.setVersion(dataIn.readInt());        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        WireFormatInfo info = (WireFormatInfo)o;        info.beforeMarshall(wireFormat);        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalConstByteArray1(info.getMagic(), bs, 8);        rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        WireFormatInfo info = (WireFormatInfo)o;        tightMarshalConstByteArray2(info.getMagic(), dataOut, bs, 8);        dataOut.writeInt(info.getVersion());        tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);        info.afterMarshall(wireFormat);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        WireFormatInfo info = (WireFormatInfo)o;        info.beforeUnmarshall(wireFormat);                info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));        info.setVersion(dataIn.readInt());        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        WireFormatInfo info = (WireFormatInfo)o;        info.beforeMarshall(wireFormat);        super.looseMarshal(wireFormat, o, dataOut);        looseMarshalConstByteArray(wireFormat, info.getMagic(), dataOut, 8);        dataOut.writeInt(info.getVersion());        looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);    }}
\ No newline at end of file
+/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v7;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for WireFormatInfoMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class WireFormatInfoMarshaller extends BaseDataStreamMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return WireFormatInfo.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new WireFormatInfo();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        WireFormatInfo info = (WireFormatInfo)o;        info.beforeUnmarshall(wireFormat);                info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));        info.setVersion(dataIn.readInt());        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        WireFormatInfo info = (WireFormatInfo)o;        info.beforeMarshall(wireFormat);        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalConstByteArray1(info.getMagic(), bs, 8);        rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        WireFormatInfo info = (WireFormatInfo)o;        tightMarshalConstByteArray2(info.getMagic(), dataOut, bs, 8);        dataOut.writeInt(info.getVersion());        tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);        info.afterMarshall(wireFormat);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        WireFormatInfo info = (WireFormatInfo)o;        info.beforeUnmarshall(wireFormat);                info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));        info.setVersion(dataIn.readInt());        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        WireFormatInfo info = (WireFormatInfo)o;        info.beforeMarshall(wireFormat);        super.looseMarshal(wireFormat, o, dataOut);        looseMarshalConstByteArray(wireFormat, info.getMagic(), dataOut, 8);        dataOut.writeInt(info.getVersion());        looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);    }}
\ No newline at end of file
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v7/XATransactionIdMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v7/XATransactionIdMarshaller.java
@@ -1 +1 @@
-/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v7;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for XATransactionIdMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class XATransactionIdMarshaller extends TransactionIdMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return XATransactionId.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new XATransactionId();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        XATransactionId info = (XATransactionId)o;        info.setFormatId(dataIn.readInt());        info.setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs));        info.setBranchQualifier(tightUnmarshalByteArray(dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        XATransactionId info = (XATransactionId)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalByteArray1(info.getGlobalTransactionId(), bs);        rc += tightMarshalByteArray1(info.getBranchQualifier(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        XATransactionId info = (XATransactionId)o;        dataOut.writeInt(info.getFormatId());        tightMarshalByteArray2(info.getGlobalTransactionId(), dataOut, bs);        tightMarshalByteArray2(info.getBranchQualifier(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        XATransactionId info = (XATransactionId)o;        info.setFormatId(dataIn.readInt());        info.setGlobalTransactionId(looseUnmarshalByteArray(dataIn));        info.setBranchQualifier(looseUnmarshalByteArray(dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        XATransactionId info = (XATransactionId)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeInt(info.getFormatId());        looseMarshalByteArray(wireFormat, info.getGlobalTransactionId(), dataOut);        looseMarshalByteArray(wireFormat, info.getBranchQualifier(), dataOut);    }}
\ No newline at end of file
+/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v7;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for XATransactionIdMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class XATransactionIdMarshaller extends TransactionIdMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return XATransactionId.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new XATransactionId();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        XATransactionId info = (XATransactionId)o;        info.setFormatId(dataIn.readInt());        info.setGlobalTransactionId(tightUnmarshalByteArray(wireFormat, dataIn, bs));        info.setBranchQualifier(tightUnmarshalByteArray(wireFormat, dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        XATransactionId info = (XATransactionId)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalByteArray1(info.getGlobalTransactionId(), bs);        rc += tightMarshalByteArray1(info.getBranchQualifier(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        XATransactionId info = (XATransactionId)o;        dataOut.writeInt(info.getFormatId());        tightMarshalByteArray2(info.getGlobalTransactionId(), dataOut, bs);        tightMarshalByteArray2(info.getBranchQualifier(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        XATransactionId info = (XATransactionId)o;        info.setFormatId(dataIn.readInt());        info.setGlobalTransactionId(looseUnmarshalByteArray(wireFormat, dataIn));        info.setBranchQualifier(looseUnmarshalByteArray(wireFormat, dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        XATransactionId info = (XATransactionId)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeInt(info.getFormatId());        looseMarshalByteArray(wireFormat, info.getGlobalTransactionId(), dataOut);        looseMarshalByteArray(wireFormat, info.getBranchQualifier(), dataOut);    }}
\ No newline at end of file
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v8/BaseDataStreamMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v8/BaseDataStreamMarshaller.java
@@ -409,10 +409,11 @@
         }
     }
 
-    protected byte[] tightUnmarshalByteArray(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected byte[] tightUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         byte rc[] = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -436,10 +437,11 @@
         }
     }
 
-    protected ByteSequence tightUnmarshalByteSequence(DataInput dataIn, BooleanStream bs) throws IOException {
+    protected ByteSequence tightUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn, BooleanStream bs) throws IOException {
         ByteSequence rc = null;
         if (bs.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             return new ByteSequence(t, 0, size);
@@ -616,10 +618,11 @@
         }
     }
 
-    protected byte[] looseUnmarshalByteArray(DataInput dataIn) throws IOException {
+    protected byte[] looseUnmarshalByteArray(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         byte rc[] = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             rc = new byte[size];
             dataIn.readFully(rc);
         }
@@ -635,10 +638,11 @@
         }
     }
 
-    protected ByteSequence looseUnmarshalByteSequence(DataInput dataIn) throws IOException {
+    protected ByteSequence looseUnmarshalByteSequence(OpenWireFormat wireFormat, DataInput dataIn) throws IOException {
         ByteSequence rc = null;
         if (dataIn.readBoolean()) {
             int size = dataIn.readInt();
+            OpenWireUtil.validateBufferSize(wireFormat, size);
             byte[] t = new byte[size];
             dataIn.readFully(t);
             rc = new ByteSequence(t, 0, size);
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v8/ConnectionControlMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v8/ConnectionControlMarshaller.java
@@ -1 +1 @@
-/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v8;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for ConnectionControlMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate *        this file. * * */public class ConnectionControlMarshaller extends BaseCommandMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return ConnectionControl.DATA_STRUCTURE_TYPE;    }    /**     * @return a new object instance     */    public DataStructure createObject() {        return new ConnectionControl();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        ConnectionControl info = (ConnectionControl)o;        info.setClose(bs.readBoolean());        info.setExit(bs.readBoolean());        info.setFaultTolerant(bs.readBoolean());        info.setResume(bs.readBoolean());        info.setSuspend(bs.readBoolean());        info.setConnectedBrokers(tightUnmarshalString(dataIn, bs));        info.setReconnectTo(tightUnmarshalString(dataIn, bs));        info.setRebalanceConnection(bs.readBoolean());        info.setToken(tightUnmarshalByteArray(dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        ConnectionControl info = (ConnectionControl)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        bs.writeBoolean(info.isClose());        bs.writeBoolean(info.isExit());        bs.writeBoolean(info.isFaultTolerant());        bs.writeBoolean(info.isResume());        bs.writeBoolean(info.isSuspend());        rc += tightMarshalString1(info.getConnectedBrokers(), bs);        rc += tightMarshalString1(info.getReconnectTo(), bs);        bs.writeBoolean(info.isRebalanceConnection());        rc += tightMarshalByteArray1(info.getToken(), bs);        return rc + 0;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        ConnectionControl info = (ConnectionControl)o;        bs.readBoolean();        bs.readBoolean();        bs.readBoolean();        bs.readBoolean();        bs.readBoolean();        tightMarshalString2(info.getConnectedBrokers(), dataOut, bs);        tightMarshalString2(info.getReconnectTo(), dataOut, bs);        bs.readBoolean();        tightMarshalByteArray2(info.getToken(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        ConnectionControl info = (ConnectionControl)o;        info.setClose(dataIn.readBoolean());        info.setExit(dataIn.readBoolean());        info.setFaultTolerant(dataIn.readBoolean());        info.setResume(dataIn.readBoolean());        info.setSuspend(dataIn.readBoolean());        info.setConnectedBrokers(looseUnmarshalString(dataIn));        info.setReconnectTo(looseUnmarshalString(dataIn));        info.setRebalanceConnection(dataIn.readBoolean());        info.setToken(looseUnmarshalByteArray(dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        ConnectionControl info = (ConnectionControl)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeBoolean(info.isClose());        dataOut.writeBoolean(info.isExit());        dataOut.writeBoolean(info.isFaultTolerant());        dataOut.writeBoolean(info.isResume());        dataOut.writeBoolean(info.isSuspend());        looseMarshalString(info.getConnectedBrokers(), dataOut);        looseMarshalString(info.getReconnectTo(), dataOut);        dataOut.writeBoolean(info.isRebalanceConnection());        looseMarshalByteArray(wireFormat, info.getToken(), dataOut);    }}
\ No newline at end of file
+/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v8;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for ConnectionControlMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate *        this file. * * */public class ConnectionControlMarshaller extends BaseCommandMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return ConnectionControl.DATA_STRUCTURE_TYPE;    }    /**     * @return a new object instance     */    public DataStructure createObject() {        return new ConnectionControl();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        ConnectionControl info = (ConnectionControl)o;        info.setClose(bs.readBoolean());        info.setExit(bs.readBoolean());        info.setFaultTolerant(bs.readBoolean());        info.setResume(bs.readBoolean());        info.setSuspend(bs.readBoolean());        info.setConnectedBrokers(tightUnmarshalString(dataIn, bs));        info.setReconnectTo(tightUnmarshalString(dataIn, bs));        info.setRebalanceConnection(bs.readBoolean());        info.setToken(tightUnmarshalByteArray(wireFormat, dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        ConnectionControl info = (ConnectionControl)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        bs.writeBoolean(info.isClose());        bs.writeBoolean(info.isExit());        bs.writeBoolean(info.isFaultTolerant());        bs.writeBoolean(info.isResume());        bs.writeBoolean(info.isSuspend());        rc += tightMarshalString1(info.getConnectedBrokers(), bs);        rc += tightMarshalString1(info.getReconnectTo(), bs);        bs.writeBoolean(info.isRebalanceConnection());        rc += tightMarshalByteArray1(info.getToken(), bs);        return rc + 0;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        ConnectionControl info = (ConnectionControl)o;        bs.readBoolean();        bs.readBoolean();        bs.readBoolean();        bs.readBoolean();        bs.readBoolean();        tightMarshalString2(info.getConnectedBrokers(), dataOut, bs);        tightMarshalString2(info.getReconnectTo(), dataOut, bs);        bs.readBoolean();        tightMarshalByteArray2(info.getToken(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        ConnectionControl info = (ConnectionControl)o;        info.setClose(dataIn.readBoolean());        info.setExit(dataIn.readBoolean());        info.setFaultTolerant(dataIn.readBoolean());        info.setResume(dataIn.readBoolean());        info.setSuspend(dataIn.readBoolean());        info.setConnectedBrokers(looseUnmarshalString(dataIn));        info.setReconnectTo(looseUnmarshalString(dataIn));        info.setRebalanceConnection(dataIn.readBoolean());        info.setToken(looseUnmarshalByteArray(wireFormat, dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        ConnectionControl info = (ConnectionControl)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeBoolean(info.isClose());        dataOut.writeBoolean(info.isExit());        dataOut.writeBoolean(info.isFaultTolerant());        dataOut.writeBoolean(info.isResume());        dataOut.writeBoolean(info.isSuspend());        looseMarshalString(info.getConnectedBrokers(), dataOut);        looseMarshalString(info.getReconnectTo(), dataOut);        dataOut.writeBoolean(info.isRebalanceConnection());        looseMarshalByteArray(wireFormat, info.getToken(), dataOut);    }}
\ No newline at end of file
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v8/MessageMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v8/MessageMarshaller.java
@@ -1 +1 @@
-/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v8;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for MessageMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public abstract class MessageMarshaller extends BaseCommandMarshaller {    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        Message info = (Message)o;        info.beforeUnmarshall(wireFormat);                info.setProducerId((org.apache.activemq.command.ProducerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setMessageId((org.apache.activemq.command.MessageId) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setGroupID(tightUnmarshalString(dataIn, bs));        info.setGroupSequence(dataIn.readInt());        info.setCorrelationId(tightUnmarshalString(dataIn, bs));        info.setPersistent(bs.readBoolean());        info.setExpiration(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setPriority(dataIn.readByte());        info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setType(tightUnmarshalString(dataIn, bs));        info.setContent(tightUnmarshalByteSequence(dataIn, bs));        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));        info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setCompressed(bs.readBoolean());        info.setRedeliveryCounter(dataIn.readInt());        if (bs.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);            }            info.setBrokerPath(value);        }        else {            info.setBrokerPath(null);        }        info.setArrival(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setUserID(tightUnmarshalString(dataIn, bs));        info.setRecievedByDFBridge(bs.readBoolean());        info.setDroppable(bs.readBoolean());        if (bs.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);            }            info.setCluster(value);        }        else {            info.setCluster(null);        }        info.setBrokerInTime(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setBrokerOutTime(tightUnmarshalLong(wireFormat, dataIn, bs));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        Message info = (Message)o;        info.beforeMarshall(wireFormat);        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalDestination(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalTransactionId(), bs);        rc += tightMarshalString1(info.getGroupID(), bs);        rc += tightMarshalString1(info.getCorrelationId(), bs);        bs.writeBoolean(info.isPersistent());        rc+=tightMarshalLong1(wireFormat, info.getExpiration(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getReplyTo(), bs);        rc+=tightMarshalLong1(wireFormat, info.getTimestamp(), bs);        rc += tightMarshalString1(info.getType(), bs);        rc += tightMarshalByteSequence1(info.getContent(), bs);        rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDataStructure(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTargetConsumerId(), bs);        bs.writeBoolean(info.isCompressed());        rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);        rc+=tightMarshalLong1(wireFormat, info.getArrival(), bs);        rc += tightMarshalString1(info.getUserID(), bs);        bs.writeBoolean(info.isRecievedByDFBridge());        bs.writeBoolean(info.isDroppable());        rc += tightMarshalObjectArray1(wireFormat, info.getCluster(), bs);        rc+=tightMarshalLong1(wireFormat, info.getBrokerInTime(), bs);        rc+=tightMarshalLong1(wireFormat, info.getBrokerOutTime(), bs);        return rc + 9;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        Message info = (Message)o;        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut, bs);        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut, bs);        tightMarshalString2(info.getGroupID(), dataOut, bs);        dataOut.writeInt(info.getGroupSequence());        tightMarshalString2(info.getCorrelationId(), dataOut, bs);        bs.readBoolean();        tightMarshalLong2(wireFormat, info.getExpiration(), dataOut, bs);        dataOut.writeByte(info.getPriority());        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getReplyTo(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getTimestamp(), dataOut, bs);        tightMarshalString2(info.getType(), dataOut, bs);        tightMarshalByteSequence2(info.getContent(), dataOut, bs);        tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDataStructure(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut, bs);        bs.readBoolean();        dataOut.writeInt(info.getRedeliveryCounter());        tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getArrival(), dataOut, bs);        tightMarshalString2(info.getUserID(), dataOut, bs);        bs.readBoolean();        bs.readBoolean();        tightMarshalObjectArray2(wireFormat, info.getCluster(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getBrokerInTime(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getBrokerOutTime(), dataOut, bs);        info.afterMarshall(wireFormat);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        Message info = (Message)o;        info.beforeUnmarshall(wireFormat);                info.setProducerId((org.apache.activemq.command.ProducerId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setGroupID(looseUnmarshalString(dataIn));        info.setGroupSequence(dataIn.readInt());        info.setCorrelationId(looseUnmarshalString(dataIn));        info.setPersistent(dataIn.readBoolean());        info.setExpiration(looseUnmarshalLong(wireFormat, dataIn));        info.setPriority(dataIn.readByte());        info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));        info.setType(looseUnmarshalString(dataIn));        info.setContent(looseUnmarshalByteSequence(dataIn));        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));        info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setCompressed(dataIn.readBoolean());        info.setRedeliveryCounter(dataIn.readInt());        if (dataIn.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);            }            info.setBrokerPath(value);        }        else {            info.setBrokerPath(null);        }        info.setArrival(looseUnmarshalLong(wireFormat, dataIn));        info.setUserID(looseUnmarshalString(dataIn));        info.setRecievedByDFBridge(dataIn.readBoolean());        info.setDroppable(dataIn.readBoolean());        if (dataIn.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);            }            info.setCluster(value);        }        else {            info.setCluster(null);        }        info.setBrokerInTime(looseUnmarshalLong(wireFormat, dataIn));        info.setBrokerOutTime(looseUnmarshalLong(wireFormat, dataIn));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        Message info = (Message)o;        info.beforeMarshall(wireFormat);        super.looseMarshal(wireFormat, o, dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut);        looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut);        looseMarshalString(info.getGroupID(), dataOut);        dataOut.writeInt(info.getGroupSequence());        looseMarshalString(info.getCorrelationId(), dataOut);        dataOut.writeBoolean(info.isPersistent());        looseMarshalLong(wireFormat, info.getExpiration(), dataOut);        dataOut.writeByte(info.getPriority());        looseMarshalNestedObject(wireFormat, (DataStructure)info.getReplyTo(), dataOut);        looseMarshalLong(wireFormat, info.getTimestamp(), dataOut);        looseMarshalString(info.getType(), dataOut);        looseMarshalByteSequence(wireFormat, info.getContent(), dataOut);        looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);        looseMarshalNestedObject(wireFormat, (DataStructure)info.getDataStructure(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut);        dataOut.writeBoolean(info.isCompressed());        dataOut.writeInt(info.getRedeliveryCounter());        looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);        looseMarshalLong(wireFormat, info.getArrival(), dataOut);        looseMarshalString(info.getUserID(), dataOut);        dataOut.writeBoolean(info.isRecievedByDFBridge());        dataOut.writeBoolean(info.isDroppable());        looseMarshalObjectArray(wireFormat, info.getCluster(), dataOut);        looseMarshalLong(wireFormat, info.getBrokerInTime(), dataOut);        looseMarshalLong(wireFormat, info.getBrokerOutTime(), dataOut);    }}
\ No newline at end of file
+/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v8;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for MessageMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public abstract class MessageMarshaller extends BaseCommandMarshaller {    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        Message info = (Message)o;        info.beforeUnmarshall(wireFormat);                info.setProducerId((org.apache.activemq.command.ProducerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setMessageId((org.apache.activemq.command.MessageId) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setGroupID(tightUnmarshalString(dataIn, bs));        info.setGroupSequence(dataIn.readInt());        info.setCorrelationId(tightUnmarshalString(dataIn, bs));        info.setPersistent(bs.readBoolean());        info.setExpiration(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setPriority(dataIn.readByte());        info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setTimestamp(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setType(tightUnmarshalString(dataIn, bs));        info.setContent(tightUnmarshalByteSequence(wireFormat, dataIn, bs));        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));        info.setDataStructure((org.apache.activemq.command.DataStructure) tightUnmarsalNestedObject(wireFormat, dataIn, bs));        info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) tightUnmarsalCachedObject(wireFormat, dataIn, bs));        info.setCompressed(bs.readBoolean());        info.setRedeliveryCounter(dataIn.readInt());        if (bs.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);            }            info.setBrokerPath(value);        }        else {            info.setBrokerPath(null);        }        info.setArrival(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setUserID(tightUnmarshalString(dataIn, bs));        info.setRecievedByDFBridge(bs.readBoolean());        info.setDroppable(bs.readBoolean());        if (bs.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) tightUnmarsalNestedObject(wireFormat,dataIn, bs);            }            info.setCluster(value);        }        else {            info.setCluster(null);        }        info.setBrokerInTime(tightUnmarshalLong(wireFormat, dataIn, bs));        info.setBrokerOutTime(tightUnmarshalLong(wireFormat, dataIn, bs));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        Message info = (Message)o;        info.beforeMarshall(wireFormat);        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getProducerId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getDestination(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTransactionId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalDestination(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getMessageId(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getOriginalTransactionId(), bs);        rc += tightMarshalString1(info.getGroupID(), bs);        rc += tightMarshalString1(info.getCorrelationId(), bs);        bs.writeBoolean(info.isPersistent());        rc+=tightMarshalLong1(wireFormat, info.getExpiration(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getReplyTo(), bs);        rc+=tightMarshalLong1(wireFormat, info.getTimestamp(), bs);        rc += tightMarshalString1(info.getType(), bs);        rc += tightMarshalByteSequence1(info.getContent(), bs);        rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);        rc += tightMarshalNestedObject1(wireFormat, (DataStructure)info.getDataStructure(), bs);        rc += tightMarshalCachedObject1(wireFormat, (DataStructure)info.getTargetConsumerId(), bs);        bs.writeBoolean(info.isCompressed());        rc += tightMarshalObjectArray1(wireFormat, info.getBrokerPath(), bs);        rc+=tightMarshalLong1(wireFormat, info.getArrival(), bs);        rc += tightMarshalString1(info.getUserID(), bs);        bs.writeBoolean(info.isRecievedByDFBridge());        bs.writeBoolean(info.isDroppable());        rc += tightMarshalObjectArray1(wireFormat, info.getCluster(), bs);        rc+=tightMarshalLong1(wireFormat, info.getBrokerInTime(), bs);        rc+=tightMarshalLong1(wireFormat, info.getBrokerOutTime(), bs);        return rc + 9;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        Message info = (Message)o;        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getProducerId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getDestination(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTransactionId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut, bs);        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getMessageId(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut, bs);        tightMarshalString2(info.getGroupID(), dataOut, bs);        dataOut.writeInt(info.getGroupSequence());        tightMarshalString2(info.getCorrelationId(), dataOut, bs);        bs.readBoolean();        tightMarshalLong2(wireFormat, info.getExpiration(), dataOut, bs);        dataOut.writeByte(info.getPriority());        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getReplyTo(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getTimestamp(), dataOut, bs);        tightMarshalString2(info.getType(), dataOut, bs);        tightMarshalByteSequence2(info.getContent(), dataOut, bs);        tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);        tightMarshalNestedObject2(wireFormat, (DataStructure)info.getDataStructure(), dataOut, bs);        tightMarshalCachedObject2(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut, bs);        bs.readBoolean();        dataOut.writeInt(info.getRedeliveryCounter());        tightMarshalObjectArray2(wireFormat, info.getBrokerPath(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getArrival(), dataOut, bs);        tightMarshalString2(info.getUserID(), dataOut, bs);        bs.readBoolean();        bs.readBoolean();        tightMarshalObjectArray2(wireFormat, info.getCluster(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getBrokerInTime(), dataOut, bs);        tightMarshalLong2(wireFormat, info.getBrokerOutTime(), dataOut, bs);        info.afterMarshall(wireFormat);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        Message info = (Message)o;        info.beforeUnmarshall(wireFormat);                info.setProducerId((org.apache.activemq.command.ProducerId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setOriginalDestination((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setMessageId((org.apache.activemq.command.MessageId) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setOriginalTransactionId((org.apache.activemq.command.TransactionId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setGroupID(looseUnmarshalString(dataIn));        info.setGroupSequence(dataIn.readInt());        info.setCorrelationId(looseUnmarshalString(dataIn));        info.setPersistent(dataIn.readBoolean());        info.setExpiration(looseUnmarshalLong(wireFormat, dataIn));        info.setPriority(dataIn.readByte());        info.setReplyTo((org.apache.activemq.command.ActiveMQDestination) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setTimestamp(looseUnmarshalLong(wireFormat, dataIn));        info.setType(looseUnmarshalString(dataIn));        info.setContent(looseUnmarshalByteSequence(wireFormat, dataIn));        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));        info.setDataStructure((org.apache.activemq.command.DataStructure) looseUnmarsalNestedObject(wireFormat, dataIn));        info.setTargetConsumerId((org.apache.activemq.command.ConsumerId) looseUnmarsalCachedObject(wireFormat, dataIn));        info.setCompressed(dataIn.readBoolean());        info.setRedeliveryCounter(dataIn.readInt());        if (dataIn.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);            }            info.setBrokerPath(value);        }        else {            info.setBrokerPath(null);        }        info.setArrival(looseUnmarshalLong(wireFormat, dataIn));        info.setUserID(looseUnmarshalString(dataIn));        info.setRecievedByDFBridge(dataIn.readBoolean());        info.setDroppable(dataIn.readBoolean());        if (dataIn.readBoolean()) {            short size = dataIn.readShort();            org.apache.activemq.command.BrokerId value[] = new org.apache.activemq.command.BrokerId[size];            for( int i=0; i < size; i++ ) {                value[i] = (org.apache.activemq.command.BrokerId) looseUnmarsalNestedObject(wireFormat,dataIn);            }            info.setCluster(value);        }        else {            info.setCluster(null);        }        info.setBrokerInTime(looseUnmarshalLong(wireFormat, dataIn));        info.setBrokerOutTime(looseUnmarshalLong(wireFormat, dataIn));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        Message info = (Message)o;        info.beforeMarshall(wireFormat);        super.looseMarshal(wireFormat, o, dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getProducerId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getDestination(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getTransactionId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalDestination(), dataOut);        looseMarshalNestedObject(wireFormat, (DataStructure)info.getMessageId(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getOriginalTransactionId(), dataOut);        looseMarshalString(info.getGroupID(), dataOut);        dataOut.writeInt(info.getGroupSequence());        looseMarshalString(info.getCorrelationId(), dataOut);        dataOut.writeBoolean(info.isPersistent());        looseMarshalLong(wireFormat, info.getExpiration(), dataOut);        dataOut.writeByte(info.getPriority());        looseMarshalNestedObject(wireFormat, (DataStructure)info.getReplyTo(), dataOut);        looseMarshalLong(wireFormat, info.getTimestamp(), dataOut);        looseMarshalString(info.getType(), dataOut);        looseMarshalByteSequence(wireFormat, info.getContent(), dataOut);        looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);        looseMarshalNestedObject(wireFormat, (DataStructure)info.getDataStructure(), dataOut);        looseMarshalCachedObject(wireFormat, (DataStructure)info.getTargetConsumerId(), dataOut);        dataOut.writeBoolean(info.isCompressed());        dataOut.writeInt(info.getRedeliveryCounter());        looseMarshalObjectArray(wireFormat, info.getBrokerPath(), dataOut);        looseMarshalLong(wireFormat, info.getArrival(), dataOut);        looseMarshalString(info.getUserID(), dataOut);        dataOut.writeBoolean(info.isRecievedByDFBridge());        dataOut.writeBoolean(info.isDroppable());        looseMarshalObjectArray(wireFormat, info.getCluster(), dataOut);        looseMarshalLong(wireFormat, info.getBrokerInTime(), dataOut);        looseMarshalLong(wireFormat, info.getBrokerOutTime(), dataOut);    }}
\ No newline at end of file
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v8/PartialCommandMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v8/PartialCommandMarshaller.java
@@ -1 +1 @@
-/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v8;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for PartialCommandMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class PartialCommandMarshaller extends BaseDataStreamMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return PartialCommand.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new PartialCommand();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        PartialCommand info = (PartialCommand)o;        info.setCommandId(dataIn.readInt());        info.setData(tightUnmarshalByteArray(dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        PartialCommand info = (PartialCommand)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalByteArray1(info.getData(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        PartialCommand info = (PartialCommand)o;        dataOut.writeInt(info.getCommandId());        tightMarshalByteArray2(info.getData(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        PartialCommand info = (PartialCommand)o;        info.setCommandId(dataIn.readInt());        info.setData(looseUnmarshalByteArray(dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        PartialCommand info = (PartialCommand)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeInt(info.getCommandId());        looseMarshalByteArray(wireFormat, info.getData(), dataOut);    }}
\ No newline at end of file
+/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v8;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for PartialCommandMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class PartialCommandMarshaller extends BaseDataStreamMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return PartialCommand.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new PartialCommand();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        PartialCommand info = (PartialCommand)o;        info.setCommandId(dataIn.readInt());        info.setData(tightUnmarshalByteArray(wireFormat, dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        PartialCommand info = (PartialCommand)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalByteArray1(info.getData(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        PartialCommand info = (PartialCommand)o;        dataOut.writeInt(info.getCommandId());        tightMarshalByteArray2(info.getData(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        PartialCommand info = (PartialCommand)o;        info.setCommandId(dataIn.readInt());        info.setData(looseUnmarshalByteArray(wireFormat, dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        PartialCommand info = (PartialCommand)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeInt(info.getCommandId());        looseMarshalByteArray(wireFormat, info.getData(), dataOut);    }}
\ No newline at end of file
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v8/WireFormatInfoMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v8/WireFormatInfoMarshaller.java
@@ -1 +1 @@
-/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v8;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for WireFormatInfoMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class WireFormatInfoMarshaller extends BaseDataStreamMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return WireFormatInfo.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new WireFormatInfo();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        WireFormatInfo info = (WireFormatInfo)o;        info.beforeUnmarshall(wireFormat);                info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));        info.setVersion(dataIn.readInt());        info.setMarshalledProperties(tightUnmarshalByteSequence(dataIn, bs));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        WireFormatInfo info = (WireFormatInfo)o;        info.beforeMarshall(wireFormat);        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalConstByteArray1(info.getMagic(), bs, 8);        rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        WireFormatInfo info = (WireFormatInfo)o;        tightMarshalConstByteArray2(info.getMagic(), dataOut, bs, 8);        dataOut.writeInt(info.getVersion());        tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);        info.afterMarshall(wireFormat);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        WireFormatInfo info = (WireFormatInfo)o;        info.beforeUnmarshall(wireFormat);                info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));        info.setVersion(dataIn.readInt());        info.setMarshalledProperties(looseUnmarshalByteSequence(dataIn));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        WireFormatInfo info = (WireFormatInfo)o;        info.beforeMarshall(wireFormat);        super.looseMarshal(wireFormat, o, dataOut);        looseMarshalConstByteArray(wireFormat, info.getMagic(), dataOut, 8);        dataOut.writeInt(info.getVersion());        looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);    }}
\ No newline at end of file
+/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v8;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for WireFormatInfoMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class WireFormatInfoMarshaller extends BaseDataStreamMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return WireFormatInfo.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new WireFormatInfo();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        WireFormatInfo info = (WireFormatInfo)o;        info.beforeUnmarshall(wireFormat);        info.setMagic(tightUnmarshalConstByteArray(dataIn, bs, 8));        info.setVersion(dataIn.readInt());        info.setMarshalledProperties(tightUnmarshalByteSequence(wireFormat, dataIn, bs));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        WireFormatInfo info = (WireFormatInfo)o;        info.beforeMarshall(wireFormat);        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalConstByteArray1(info.getMagic(), bs, 8);        rc += tightMarshalByteSequence1(info.getMarshalledProperties(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        WireFormatInfo info = (WireFormatInfo)o;        tightMarshalConstByteArray2(info.getMagic(), dataOut, bs, 8);        dataOut.writeInt(info.getVersion());        tightMarshalByteSequence2(info.getMarshalledProperties(), dataOut, bs);        info.afterMarshall(wireFormat);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        WireFormatInfo info = (WireFormatInfo)o;        info.beforeUnmarshall(wireFormat);                info.setMagic(looseUnmarshalConstByteArray(dataIn, 8));        info.setVersion(dataIn.readInt());        info.setMarshalledProperties(looseUnmarshalByteSequence(wireFormat, dataIn));        info.afterUnmarshall(wireFormat);    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        WireFormatInfo info = (WireFormatInfo)o;        info.beforeMarshall(wireFormat);        super.looseMarshal(wireFormat, o, dataOut);        looseMarshalConstByteArray(wireFormat, info.getMagic(), dataOut, 8);        dataOut.writeInt(info.getVersion());        looseMarshalByteSequence(wireFormat, info.getMarshalledProperties(), dataOut);    }}
\ No newline at end of file
--- a/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v8/XATransactionIdMarshaller.java
+++ b/activemq-openwire-legacy/src/main/java/org/apache/activemq/openwire/v8/XATransactionIdMarshaller.java
@@ -1 +1 @@
-/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v8;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for XATransactionIdMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class XATransactionIdMarshaller extends TransactionIdMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return XATransactionId.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new XATransactionId();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        XATransactionId info = (XATransactionId)o;        info.setFormatId(dataIn.readInt());        info.setGlobalTransactionId(tightUnmarshalByteArray(dataIn, bs));        info.setBranchQualifier(tightUnmarshalByteArray(dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        XATransactionId info = (XATransactionId)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalByteArray1(info.getGlobalTransactionId(), bs);        rc += tightMarshalByteArray1(info.getBranchQualifier(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        XATransactionId info = (XATransactionId)o;        dataOut.writeInt(info.getFormatId());        tightMarshalByteArray2(info.getGlobalTransactionId(), dataOut, bs);        tightMarshalByteArray2(info.getBranchQualifier(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        XATransactionId info = (XATransactionId)o;        info.setFormatId(dataIn.readInt());        info.setGlobalTransactionId(looseUnmarshalByteArray(dataIn));        info.setBranchQualifier(looseUnmarshalByteArray(dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        XATransactionId info = (XATransactionId)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeInt(info.getFormatId());        looseMarshalByteArray(wireFormat, info.getGlobalTransactionId(), dataOut);        looseMarshalByteArray(wireFormat, info.getBranchQualifier(), dataOut);    }}
\ No newline at end of file
+/** * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements.  See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License.  You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.activemq.openwire.v8;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import org.apache.activemq.openwire.*;import org.apache.activemq.command.*;/** * Marshalling code for Open Wire Format for XATransactionIdMarshaller * * * NOTE!: This file is auto generated - do not modify! *        if you need to make a change, please see the modify the groovy scripts in the *        under src/gram/script and then use maven openwire:generate to regenerate  *        this file. * *  */public class XATransactionIdMarshaller extends TransactionIdMarshaller {    /**     * Return the type of Data Structure we marshal     * @return short representation of the type data structure     */    public byte getDataStructureType() {        return XATransactionId.DATA_STRUCTURE_TYPE;    }        /**     * @return a new object instance     */    public DataStructure createObject() {        return new XATransactionId();    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void tightUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn, BooleanStream bs) throws IOException {        super.tightUnmarshal(wireFormat, o, dataIn, bs);        XATransactionId info = (XATransactionId)o;        info.setFormatId(dataIn.readInt());        info.setGlobalTransactionId(tightUnmarshalByteArray(wireFormat, dataIn, bs));        info.setBranchQualifier(tightUnmarshalByteArray(wireFormat, dataIn, bs));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public int tightMarshal1(OpenWireFormat wireFormat, Object o, BooleanStream bs) throws IOException {        XATransactionId info = (XATransactionId)o;        int rc = super.tightMarshal1(wireFormat, o, bs);        rc += tightMarshalByteArray1(info.getGlobalTransactionId(), bs);        rc += tightMarshalByteArray1(info.getBranchQualifier(), bs);        return rc + 4;    }    /**     * Write a object instance to data output stream     *     * @param o the instance to be marshaled     * @param dataOut the output stream     * @throws IOException thrown if an error occurs     */    public void tightMarshal2(OpenWireFormat wireFormat, Object o, DataOutput dataOut, BooleanStream bs) throws IOException {        super.tightMarshal2(wireFormat, o, dataOut, bs);        XATransactionId info = (XATransactionId)o;        dataOut.writeInt(info.getFormatId());        tightMarshalByteArray2(info.getGlobalTransactionId(), dataOut, bs);        tightMarshalByteArray2(info.getBranchQualifier(), dataOut, bs);    }    /**     * Un-marshal an object instance from the data input stream     *     * @param o the object to un-marshal     * @param dataIn the data input stream to build the object from     * @throws IOException     */    public void looseUnmarshal(OpenWireFormat wireFormat, Object o, DataInput dataIn) throws IOException {        super.looseUnmarshal(wireFormat, o, dataIn);        XATransactionId info = (XATransactionId)o;        info.setFormatId(dataIn.readInt());        info.setGlobalTransactionId(looseUnmarshalByteArray(wireFormat, dataIn));        info.setBranchQualifier(looseUnmarshalByteArray(wireFormat, dataIn));    }    /**     * Write the booleans that this object uses to a BooleanStream     */    public void looseMarshal(OpenWireFormat wireFormat, Object o, DataOutput dataOut) throws IOException {        XATransactionId info = (XATransactionId)o;        super.looseMarshal(wireFormat, o, dataOut);        dataOut.writeInt(info.getFormatId());        looseMarshalByteArray(wireFormat, info.getGlobalTransactionId(), dataOut);        looseMarshalByteArray(wireFormat, info.getBranchQualifier(), dataOut);    }}
\ No newline at end of file
--- a/activemq-openwire-legacy/src/test/java/org/apache/activemq/openwire/OpenWireLegacyValidationTest.java
+++ b/activemq-openwire-legacy/src/test/java/org/apache/activemq/openwire/OpenWireLegacyValidationTest.java
@@ -21,13 +21,13 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import org.apache.activemq.util.ByteSequence;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 
 /**
- * Test that Openwire marshalling for legacy versions will validate Throwable types during
- * unmarshalling commands that contain a Throwable
+ * Test that Openwire marshalling for legacy versions will validate certain commands correctly
  */
 @RunWith(Parameterized.class)
 public class OpenWireLegacyValidationTest extends OpenWireValidationTest {
@@ -126,4 +126,46 @@
         }
     }
 
+    protected DataStreamMarshaller getWireFormatInfoMarshaller() {
+        switch (version) {
+            case 2:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v2.WireFormatInfoMarshaller());
+            case 3:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v3.WireFormatInfoMarshaller());
+            case 4:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v4.WireFormatInfoMarshaller());
+            case 5:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v5.WireFormatInfoMarshaller());
+            case 6:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v6.WireFormatInfoMarshaller());
+            case 7:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v7.WireFormatInfoMarshaller());
+            case 8:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v8.WireFormatInfoMarshaller());
+            default:
+                throw new IllegalArgumentException("Unknown OpenWire version of " + version);
+        }
+    }
+
+    protected DataStreamMarshaller getPartialCommandMarshaller() {
+        switch (version) {
+            case 2:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v2.PartialCommandMarshaller());
+            case 3:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v3.PartialCommandMarshaller());
+            case 4:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v4.PartialCommandMarshaller());
+            case 5:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v5.PartialCommandMarshaller());
+            case 6:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v6.PartialCommandMarshaller());
+            case 7:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v7.PartialCommandMarshaller());
+            case 8:
+                return proxyBadBufferCommand(new org.apache.activemq.openwire.v8.PartialCommandMarshaller());
+            default:
+                throw new IllegalArgumentException("Unknown OpenWire version of " + version);
+        }
+    }
+
 }
--- a/pom.xml
+++ b/pom.xml
@@ -76,6 +76,7 @@
     <jetty-version>${jetty9-version}</jetty-version>
     <jmdns-version>3.4.1</jmdns-version>
     <tomcat-api-version>9.0.65</tomcat-api-version>
+    <javassist-version>3.27.0</javassist-version>
     <jettison-version>1.5.4</jettison-version>
     <jmock-version>2.5.1</jmock-version>
     <jolokia-version>1.7.1</jolokia-version>
@@ -1054,6 +1055,11 @@
         <artifactId>jettison</artifactId>
         <version>${jettison-version}</version>
     </dependency>
+      <dependency>
+        <groupId>org.javassist</groupId>
+        <artifactId>javassist</artifactId>
+        <version>${javassist-version}</version>
+      </dependency>
 
       <dependency>
         <groupId>annogen</groupId>
