qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lqu...@apache.org
Subject [03/10] qpid-broker-j git commit: QPID-7832: [Java Broker] Refactor store/protocol API using Collection<QpidByteBuffer>
Date Wed, 18 Oct 2017 15:21:37 GMT
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpValueSectionConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpValueSectionConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpValueSectionConstructor.java
index a8e51bc..dea8b76 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpValueSectionConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/AmqpValueSectionConstructor.java
@@ -23,10 +23,7 @@
 
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
-import java.util.List;
-
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
-import org.apache.qpid.server.bytebuffer.QpidByteBufferUtils;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructor;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
 import org.apache.qpid.server.protocol.v1_0.codec.TypeConstructor;
@@ -58,36 +55,36 @@ public class AmqpValueSectionConstructor implements DescribedTypeConstructor<Amq
 
     @Override
     public TypeConstructor<AmqpValueSection> construct(final Object descriptor,
-                                                        final List<QpidByteBuffer> in,
-                                                        final int[] originalPositions,
+                                                        final QpidByteBuffer in,
+                                                        final int originalPosition,
                                                         final ValueHandler valueHandler)
             throws AmqpErrorException
     {
-        return new LazyConstructor(originalPositions);
+        return new LazyConstructor(originalPosition);
     }
 
 
     private class LazyConstructor extends AbstractLazyConstructor<AmqpValueSection>
     {
-        LazyConstructor(final int[] originalPositions)
+        LazyConstructor(final int originalPosition)
         {
-            super(originalPositions);
+            super(originalPosition);
         }
 
         @Override
-        protected AmqpValueSection createObject(final List<QpidByteBuffer> encoding, final ValueHandler handler)
+        protected AmqpValueSection createObject(final QpidByteBuffer encoding, final ValueHandler handler)
         {
             return new AmqpValueSection(encoding);
         }
 
         @Override
-        protected void skipValue(final List<QpidByteBuffer> in) throws AmqpErrorException
+        protected void skipValue(final QpidByteBuffer in) throws AmqpErrorException
         {
-            if (!QpidByteBufferUtils.hasRemaining(in))
+            if (!in.hasRemaining())
             {
                 throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data to decode AMQP value section.");
             }
-            byte formatCode = QpidByteBufferUtils.get(in);
+            byte formatCode = in.get();
 
             if (formatCode == ValueHandler.DESCRIBED_TYPE)
             {
@@ -122,32 +119,32 @@ public class AmqpValueSectionConstructor implements DescribedTypeConstructor<Amq
                     case 0x0a:
                     case 0x0c:
                     case 0x0e:
-                        if (!QpidByteBufferUtils.hasRemaining(in))
+                        if (!in.hasRemaining())
                         {
                             throw new AmqpErrorException(AmqpError.DECODE_ERROR,
                                                          "Insufficient data to decode AMQP value section.");
                         }
-                        skipLength = ((int) QpidByteBufferUtils.get(in)) & 0xFF;
+                        skipLength = in.getUnsignedByte();
                         break;
                     case 0x0b:
                     case 0x0d:
                     case 0x0f:
-                        if (!QpidByteBufferUtils.hasRemaining(in, 4))
+                        if (!in.hasRemaining(4))
                         {
                             throw new AmqpErrorException(AmqpError.DECODE_ERROR,
                                                          "Insufficient data to decode AMQP value section.");
                         }
-                        skipLength = QpidByteBufferUtils.getInt(in);
+                        skipLength = in.getInt();
                         break;
                     default:
                         throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Unknown type");
                 }
-                if (!QpidByteBufferUtils.hasRemaining(in, skipLength))
+                if (!in.hasRemaining(skipLength))
                 {
                     throw new AmqpErrorException(AmqpError.DECODE_ERROR,
                                                  "Insufficient data to decode AMQP value section.");
                 }
-                QpidByteBufferUtils.skip(in,skipLength);
+                in.position(in.position() + skipLength);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ApplicationPropertiesSectionConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ApplicationPropertiesSectionConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ApplicationPropertiesSectionConstructor.java
index a40efcd..2c99841 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ApplicationPropertiesSectionConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/ApplicationPropertiesSectionConstructor.java
@@ -23,8 +23,6 @@
 
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
-import java.util.List;
-
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
@@ -50,7 +48,7 @@ public class ApplicationPropertiesSectionConstructor extends DescribedMapSection
 
     @Override
     protected ApplicationPropertiesSection createObject(final DescribedTypeConstructorRegistry describedTypeRegistry,
-                                                        final List<QpidByteBuffer> encodedForm)
+                                                        final QpidByteBuffer encodedForm)
     {
         return new ApplicationPropertiesSection(encodedForm);
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DataSectionConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DataSectionConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DataSectionConstructor.java
index e27c878..101c60d 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DataSectionConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DataSectionConstructor.java
@@ -23,12 +23,9 @@
 
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
-import java.util.List;
-
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructor;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
-import org.apache.qpid.server.bytebuffer.QpidByteBufferUtils;
 import org.apache.qpid.server.protocol.v1_0.codec.TypeConstructor;
 import org.apache.qpid.server.protocol.v1_0.codec.ValueHandler;
 import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
@@ -59,16 +56,16 @@ public class DataSectionConstructor implements DescribedTypeConstructor<DataSect
 
     @Override
     public TypeConstructor<DataSection> construct(final Object descriptor,
-                                                        final List<QpidByteBuffer> in,
-                                                        final int[] originalPositions,
+                                                        final QpidByteBuffer in,
+                                                        final int originalPosition,
                                                         final ValueHandler valueHandler)
             throws AmqpErrorException
     {
-        if (!QpidByteBufferUtils.hasRemaining(in))
+        if (!in.hasRemaining())
         {
             throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data to decode data section.");
         }
-        int constructorByte = QpidByteBufferUtils.get(in) & 0xff;
+        int constructorByte = in.getUnsignedByte();
         int sizeBytes;
         switch(constructorByte)
         {
@@ -83,7 +80,7 @@ public class DataSectionConstructor implements DescribedTypeConstructor<DataSect
                                              "The described section must always be binary");
         }
 
-        return new LazyConstructor(sizeBytes, originalPositions);
+        return new LazyConstructor(sizeBytes, originalPosition);
     }
 
 
@@ -91,22 +88,22 @@ public class DataSectionConstructor implements DescribedTypeConstructor<DataSect
     {
         private final int _sizeBytes;
 
-        public LazyConstructor(final int sizeBytes, final int[] originalPositions)
+        public LazyConstructor(final int sizeBytes, final int originalPosition)
         {
-            super(originalPositions);
+            super(originalPosition);
             _sizeBytes = sizeBytes;
         }
 
         @Override
-        protected DataSection createObject(final List<QpidByteBuffer> encoding, final ValueHandler handler)
+        protected DataSection createObject(final QpidByteBuffer encoding, final ValueHandler handler)
         {
             return new DataSection(encoding);
         }
 
         @Override
-        protected void skipValue(final List<QpidByteBuffer> in) throws AmqpErrorException
+        protected void skipValue(final QpidByteBuffer in) throws AmqpErrorException
         {
-            if (!QpidByteBufferUtils.hasRemaining(in, _sizeBytes))
+            if (!in.hasRemaining(_sizeBytes))
             {
                 throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data to decode data section.");
             }
@@ -114,19 +111,19 @@ public class DataSectionConstructor implements DescribedTypeConstructor<DataSect
             switch(_sizeBytes)
             {
                 case 1:
-                    size = QpidByteBufferUtils.get(in) & 0xff;
+                    size = in.getUnsignedByte();
                     break;
                 case 4:
-                    size = QpidByteBufferUtils.getInt(in);
+                    size = in.getInt();
                     break;
                 default:
                     throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Unexpected constructor type, can only be 1 or 4");
             }
-            if (!QpidByteBufferUtils.hasRemaining(in, size))
+            if (!in.hasRemaining(size))
             {
                 throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data to decode data section.");
             }
-            QpidByteBufferUtils.skip(in, size);
+            in.position(in.position() + size);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeliveryAnnotationsSectionConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeliveryAnnotationsSectionConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeliveryAnnotationsSectionConstructor.java
index eed18b9..cde1d28 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeliveryAnnotationsSectionConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DeliveryAnnotationsSectionConstructor.java
@@ -23,8 +23,6 @@
 
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
-import java.util.List;
-
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
@@ -50,7 +48,7 @@ public class DeliveryAnnotationsSectionConstructor extends DescribedMapSectionCo
 
     @Override
     protected DeliveryAnnotationsSection createObject(final DescribedTypeConstructorRegistry describedTypeRegistry,
-                                                      final List<QpidByteBuffer> encodedForm)
+                                                      final QpidByteBuffer encodedForm)
     {
         return new DeliveryAnnotationsSection(encodedForm);
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DescribedListSectionConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DescribedListSectionConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DescribedListSectionConstructor.java
index 061521b..31f9f15 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DescribedListSectionConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DescribedListSectionConstructor.java
@@ -23,11 +23,8 @@
 
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
-import java.util.List;
-
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructor;
-import org.apache.qpid.server.bytebuffer.QpidByteBufferUtils;
 import org.apache.qpid.server.protocol.v1_0.codec.TypeConstructor;
 import org.apache.qpid.server.protocol.v1_0.codec.ValueHandler;
 import org.apache.qpid.server.protocol.v1_0.type.AmqpErrorException;
@@ -39,16 +36,16 @@ public abstract class DescribedListSectionConstructor<S extends AbstractSection>
 
     @Override
     public TypeConstructor<S> construct(final Object descriptor,
-                                                        final List<QpidByteBuffer> in,
-                                                        final int[] originalPositions,
-                                                        final ValueHandler valueHandler)
+                                        final QpidByteBuffer in,
+                                        final int originalPosition,
+                                        final ValueHandler valueHandler)
             throws AmqpErrorException
     {
-        if (!QpidByteBufferUtils.hasRemaining(in))
+        if (!in.hasRemaining())
         {
             throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data to decode section.");
         }
-        int constructorByte = QpidByteBufferUtils.get(in) & 0xff;
+        int constructorByte = in.getUnsignedByte();
         int sizeBytes;
         switch(constructorByte)
         {
@@ -66,7 +63,7 @@ public abstract class DescribedListSectionConstructor<S extends AbstractSection>
                                              "The described section must always be a list");
         }
 
-        return new LazyConstructor(sizeBytes, originalPositions);
+        return new LazyConstructor(sizeBytes, originalPosition);
     }
 
 
@@ -74,22 +71,22 @@ public abstract class DescribedListSectionConstructor<S extends AbstractSection>
     {
         private final int _sizeBytes;
 
-        LazyConstructor(final int sizeBytes, final int[] originalPositions)
+        LazyConstructor(final int sizeBytes, final int originalPosition)
         {
-            super(originalPositions);
+            super(originalPosition);
             _sizeBytes = sizeBytes;
         }
 
         @Override
-        protected S createObject(final List<QpidByteBuffer> encoding, final ValueHandler handler)
+        protected S createObject(final QpidByteBuffer encoding, final ValueHandler handler)
         {
             return DescribedListSectionConstructor.this.createObject(encoding);
         }
 
         @Override
-        protected void skipValue(final List<QpidByteBuffer> in) throws AmqpErrorException
+        protected void skipValue(final QpidByteBuffer in) throws AmqpErrorException
         {
-            if (!QpidByteBufferUtils.hasRemaining(in, _sizeBytes))
+            if (!in.hasRemaining(_sizeBytes))
             {
                 throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data to decode section.");
             }
@@ -100,21 +97,21 @@ public abstract class DescribedListSectionConstructor<S extends AbstractSection>
                     size = 0;
                     break;
                 case 1:
-                    size = QpidByteBufferUtils.get(in) & 0xFF;
+                    size = in.getUnsignedByte();
                     break;
                 case 4:
-                    size = QpidByteBufferUtils.getInt(in);
+                    size = in.getInt();
                     break;
                 default:
                     throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Unexpected constructor type, can only be 0,1 or 4");
             }
-            if (!QpidByteBufferUtils.hasRemaining(in, size))
+            if (!in.hasRemaining(size))
             {
                 throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data to decode section.");
             }
-            QpidByteBufferUtils.skip(in, size);
+            in.position(in.position() + size);
         }
     }
 
-    protected abstract S createObject(final List<QpidByteBuffer> encodedForm);
+    protected abstract S createObject(final QpidByteBuffer encodedForm);
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DescribedMapSectionConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DescribedMapSectionConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DescribedMapSectionConstructor.java
index c7793b5..a06078c 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DescribedMapSectionConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/DescribedMapSectionConstructor.java
@@ -23,10 +23,7 @@
 
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
-import java.util.List;
-
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
-import org.apache.qpid.server.bytebuffer.QpidByteBufferUtils;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructor;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
 import org.apache.qpid.server.protocol.v1_0.codec.SectionDecoderRegistry;
@@ -42,16 +39,16 @@ public abstract class DescribedMapSectionConstructor<S extends AbstractSection>
 
     @Override
     public TypeConstructor<S> construct(final Object descriptor,
-                                                        final List<QpidByteBuffer> in,
-                                                        final int[] originalPositions,
-                                                        final ValueHandler valueHandler)
+                                        final QpidByteBuffer in,
+                                        final int originalPosition,
+                                        final ValueHandler valueHandler)
             throws AmqpErrorException
     {
-        if (!QpidByteBufferUtils.hasRemaining(in))
+        if (!in.hasRemaining())
         {
             throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data to decode section.");
         }
-        int constructorByte = QpidByteBufferUtils.get(in) & 0xff;
+        int constructorByte = in.getUnsignedByte();
         int sizeBytes;
         switch(constructorByte)
         {
@@ -66,7 +63,7 @@ public abstract class DescribedMapSectionConstructor<S extends AbstractSection>
                                              "The described section must always be a map");
         }
 
-        return new LazyConstructor(sizeBytes, originalPositions);
+        return new LazyConstructor(sizeBytes, originalPosition);
     }
 
 
@@ -74,23 +71,23 @@ public abstract class DescribedMapSectionConstructor<S extends AbstractSection>
     {
         private final int _sizeBytes;
 
-        LazyConstructor(final int sizeBytes, final int[] originalPositions)
+        LazyConstructor(final int sizeBytes, final int originalPosition)
         {
-            super(originalPositions);
+            super(originalPosition);
             _sizeBytes = sizeBytes;
         }
 
         @Override
-        protected S createObject(final List<QpidByteBuffer> encoding, final ValueHandler handler)
+        protected S createObject(final QpidByteBuffer encoding, final ValueHandler handler)
         {
             return DescribedMapSectionConstructor.this.createObject(((SectionDecoderRegistry) handler.getDescribedTypeRegistry())
                                                                             .getUnderlyingRegistry(), encoding);
         }
 
         @Override
-        protected void skipValue(final List<QpidByteBuffer> in) throws AmqpErrorException
+        protected void skipValue(final QpidByteBuffer in) throws AmqpErrorException
         {
-            if (!QpidByteBufferUtils.hasRemaining(in, _sizeBytes))
+            if (!in.hasRemaining(_sizeBytes))
             {
                 throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data to decode section.");
             }
@@ -98,22 +95,22 @@ public abstract class DescribedMapSectionConstructor<S extends AbstractSection>
             switch(_sizeBytes)
             {
                 case 1:
-                    size = QpidByteBufferUtils.get(in) & 0xff;
+                    size = in.getUnsignedByte();
                     break;
                 case 4:
-                    size = QpidByteBufferUtils.getInt(in);
+                    size = in.getInt();
                     break;
                 default:
                     throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Unexpected constructor type, can only be 1 or 4");
             }
-            if (!QpidByteBufferUtils.hasRemaining(in, size))
+            if (!in.hasRemaining(size))
             {
                 throw new AmqpErrorException(AmqpError.DECODE_ERROR, "Insufficient data to decode section.");
             }
-            QpidByteBufferUtils.skip(in, size);
+            in.position(in.position() + size);
         }
     }
 
     protected abstract S createObject(final DescribedTypeConstructorRegistry describedTypeRegistry,
-                                      final List<QpidByteBuffer> encodedForm);
+                                      final QpidByteBuffer encodedForm);
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/EncodingRetaining.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/EncodingRetaining.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/EncodingRetaining.java
index d35a875..de38511 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/EncodingRetaining.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/EncodingRetaining.java
@@ -20,15 +20,13 @@
  */
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
-import java.util.List;
-
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
 
 public interface EncodingRetaining
 {
     void writeTo(QpidByteBuffer dest);
     long getEncodedSize();
-    List<QpidByteBuffer> getEncodedForm();
+    QpidByteBuffer getEncodedForm();
     void clearEncodedForm();
     EncodingRetaining copy();
     void reallocate();

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/FooterSectionConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/FooterSectionConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/FooterSectionConstructor.java
index a2f9e93..43d87d3 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/FooterSectionConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/FooterSectionConstructor.java
@@ -23,8 +23,6 @@
 
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
-import java.util.List;
-
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
@@ -50,7 +48,7 @@ public class FooterSectionConstructor extends DescribedMapSectionConstructor<Foo
 
     @Override
     protected FooterSection createObject(final DescribedTypeConstructorRegistry describedTypeRegistry,
-                                         final List<QpidByteBuffer> encodedForm)
+                                         final QpidByteBuffer encodedForm)
     {
         return new FooterSection(encodedForm);
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/HeaderSectionConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/HeaderSectionConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/HeaderSectionConstructor.java
index 205290e..362f2f5 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/HeaderSectionConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/HeaderSectionConstructor.java
@@ -23,8 +23,6 @@
 
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
-import java.util.List;
-
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
@@ -49,7 +47,7 @@ public class HeaderSectionConstructor extends DescribedListSectionConstructor<He
     }
 
     @Override
-    protected HeaderSection createObject(final List<QpidByteBuffer> encodedForm)
+    protected HeaderSection createObject(final QpidByteBuffer encodedForm)
     {
         return new HeaderSection(encodedForm);
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MessageAnnotationsSectionConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MessageAnnotationsSectionConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MessageAnnotationsSectionConstructor.java
index 4504c12..c61b025 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MessageAnnotationsSectionConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/MessageAnnotationsSectionConstructor.java
@@ -23,8 +23,6 @@
 
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
-import java.util.List;
-
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
@@ -50,7 +48,7 @@ public class MessageAnnotationsSectionConstructor extends DescribedMapSectionCon
 
     @Override
     protected MessageAnnotationsSection createObject(final DescribedTypeConstructorRegistry describedTypeRegistry,
-                                                     final List<QpidByteBuffer> encodedForm)
+                                                     final QpidByteBuffer encodedForm)
     {
         return new MessageAnnotationsSection(encodedForm);
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/PropertiesSectionConstructor.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/PropertiesSectionConstructor.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/PropertiesSectionConstructor.java
index 4e40362..331d172 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/PropertiesSectionConstructor.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/PropertiesSectionConstructor.java
@@ -23,8 +23,6 @@
 
 package org.apache.qpid.server.protocol.v1_0.type.messaging.codec;
 
-import java.util.List;
-
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.server.protocol.v1_0.codec.DescribedTypeConstructorRegistry;
 import org.apache.qpid.server.protocol.v1_0.type.Symbol;
@@ -49,7 +47,7 @@ public class PropertiesSectionConstructor extends DescribedListSectionConstructo
     }
 
     @Override
-    protected PropertiesSection createObject(final List<QpidByteBuffer> encodedForm)
+    protected PropertiesSection createObject(final QpidByteBuffer encodedForm)
     {
         return new PropertiesSection(encodedForm);
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/Transfer.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/Transfer.java b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/Transfer.java
index d757cb7..e4d3231 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/Transfer.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/transport/Transfer.java
@@ -23,14 +23,11 @@
 package org.apache.qpid.server.protocol.v1_0.type.transport;
 
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
-import org.apache.qpid.server.protocol.v1_0.ConnectionHandler;
-import org.apache.qpid.server.protocol.v1_0.type.Binary;
 import org.apache.qpid.server.protocol.v1_0.CompositeType;
 import org.apache.qpid.server.protocol.v1_0.CompositeTypeField;
+import org.apache.qpid.server.protocol.v1_0.ConnectionHandler;
+import org.apache.qpid.server.protocol.v1_0.type.Binary;
 import org.apache.qpid.server.protocol.v1_0.type.DeliveryState;
 import org.apache.qpid.server.protocol.v1_0.type.FrameBody;
 import org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger;
@@ -38,7 +35,7 @@ import org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger;
 @CompositeType( symbolicDescriptor = "amqp:transfer:list", numericDescriptor = 0x0000000000000014L)
 public class Transfer implements FrameBody
 {
-    private volatile List<QpidByteBuffer> _payload;
+    private volatile QpidByteBuffer _payload;
 
     @CompositeTypeField(index = 0, mandatory = true)
     private UnsignedInteger _handle;
@@ -298,7 +295,7 @@ public class Transfer implements FrameBody
         conn.receiveTransfer(channel, this);
     }
 
-    public List<QpidByteBuffer> getPayload()
+    public QpidByteBuffer getPayload()
     {
         if (_payload == null)
         {
@@ -306,16 +303,11 @@ public class Transfer implements FrameBody
         }
         else
         {
-            List<QpidByteBuffer> payloadDup = new ArrayList<>(_payload.size());
-            for (QpidByteBuffer buf : _payload)
-            {
-                payloadDup.add(buf.duplicate());
-            }
-            return payloadDup;
+            return _payload.duplicate();
         }
     }
 
-    public void setPayload(List<QpidByteBuffer> payload)
+    public void setPayload(QpidByteBuffer payload)
     {
         if (payload == null)
         {
@@ -323,11 +315,7 @@ public class Transfer implements FrameBody
         }
         else
         {
-            _payload = new ArrayList<>(payload.size());
-            for (QpidByteBuffer buf : payload)
-            {
-                _payload.add(buf.duplicate());
-            }
+            _payload = payload.duplicate();
         }
     }
 
@@ -335,10 +323,7 @@ public class Transfer implements FrameBody
     {
         if (_payload != null)
         {
-            for (QpidByteBuffer buf : _payload)
-            {
-                buf.dispose();
-            }
+            _payload.dispose();
             _payload = null;
         }
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0Test.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0Test.java b/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0Test.java
index 9d3ef53..42abcf9 100644
--- a/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0Test.java
+++ b/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0Test.java
@@ -22,19 +22,18 @@ package org.apache.qpid.server.protocol.v1_0;
 
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
 
-import junit.framework.TestCase;
-
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.server.message.MessageInstance;
 import org.apache.qpid.server.message.MessageInstanceConsumer;
@@ -56,8 +55,9 @@ import org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotationsSec
 import org.apache.qpid.server.protocol.v1_0.type.messaging.Properties;
 import org.apache.qpid.server.protocol.v1_0.type.transport.Transfer;
 import org.apache.qpid.server.store.StoredMessage;
+import org.apache.qpid.test.utils.QpidTestCase;
 
-public class ConsumerTarget_1_0Test extends TestCase
+public class ConsumerTarget_1_0Test extends QpidTestCase
 {
     private final AMQPDescribedTypeRegistry _describedTypeRegistry = AMQPDescribedTypeRegistry.newInstance()
                                                                                               .registerTransportLayer()
@@ -98,20 +98,16 @@ public class ConsumerTarget_1_0Test extends TestCase
         final MessageInstance messageInstance = mock(MessageInstance.class);
         when(messageInstance.getMessage()).thenReturn(message);
 
-        AtomicReference<List<QpidByteBuffer>> payload = new AtomicReference<>();
+        AtomicReference<QpidByteBuffer> payloadRef = new AtomicReference<>();
         doAnswer(invocation ->
                  {
                      final Object[] args = invocation.getArguments();
                      Transfer transfer = (Transfer) args[0];
 
-                     List<QpidByteBuffer> transferPayload = transfer.getPayload();
+                     QpidByteBuffer transferPayload = transfer.getPayload();
 
-                     final List<QpidByteBuffer> payloadCopy = new ArrayList<>(transferPayload.size());
-                     for (QpidByteBuffer qpidByteBuffer : transferPayload)
-                     {
-                         payloadCopy.add(qpidByteBuffer.duplicate());
-                     }
-                     payload.set(payloadCopy);
+                     QpidByteBuffer payloadCopy = transferPayload.duplicate();
+                     payloadRef.set(payloadCopy);
                      return null;
                  }).when(_sendingLinkEndpoint).transfer(any(Transfer.class), anyBoolean());
 
@@ -119,11 +115,11 @@ public class ConsumerTarget_1_0Test extends TestCase
 
         verify(_sendingLinkEndpoint, times(1)).transfer(any(Transfer.class), anyBoolean());
 
-        List<QpidByteBuffer> fragments = payload.get();
-
-        final List<EncodingRetainingSection<?>> sections =
-                new SectionDecoderImpl(_describedTypeRegistry.getSectionDecoderRegistry()).parseAll(fragments);
-
+        final List<EncodingRetainingSection<?>> sections;
+        try (QpidByteBuffer payload = payloadRef.get())
+        {
+            sections = new SectionDecoderImpl(_describedTypeRegistry.getSectionDecoderRegistry()).parseAll(payload);
+        }
         Header sentHeader = null;
         for (EncodingRetainingSection<?> section : sections)
         {
@@ -133,11 +129,6 @@ public class ConsumerTarget_1_0Test extends TestCase
             }
         }
 
-        for (QpidByteBuffer fragment : fragments)
-        {
-            fragment.dispose();
-        }
-
         assertNotNull("Header is not found", sentHeader);
         assertNotNull("Ttl is not set", sentHeader.getTtl());
         assertTrue("Unexpected ttl", sentHeader.getTtl().longValue() <= 1000);
@@ -162,6 +153,7 @@ public class ConsumerTarget_1_0Test extends TestCase
                                                                0);
 
         final StoredMessage<MessageMetaData_1_0> storedMessage = mock(StoredMessage.class);
+        when(storedMessage.getContent(eq(0), anyInt())).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
         when(storedMessage.getMetaData()).thenReturn(metaData);
         return new Message_1_0(storedMessage);
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_Internal_to_1_0Test.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_Internal_to_1_0Test.java b/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_Internal_to_1_0Test.java
index d29175c..9ee7c86 100644
--- a/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_Internal_to_1_0Test.java
+++ b/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_Internal_to_1_0Test.java
@@ -29,7 +29,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -38,8 +37,6 @@ import java.util.UUID;
 
 import com.google.common.collect.Lists;
 import org.mockito.ArgumentCaptor;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
 
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.server.message.AMQMessageHeader;
@@ -281,12 +278,12 @@ public class MessageConverter_Internal_to_1_0Test extends QpidTestCase
         }
     }
 
-    private List<EncodingRetainingSection<?>> getEncodingRetainingSections(final Collection<QpidByteBuffer> content,
+    private List<EncodingRetainingSection<?>> getEncodingRetainingSections(final QpidByteBuffer content,
                                                                            final int expectedNumberOfSections)
             throws Exception
     {
         SectionDecoder sectionDecoder = new SectionDecoderImpl(_typeRegistry.getSectionDecoderRegistry());
-        final List<EncodingRetainingSection<?>> sections = sectionDecoder.parseAll(new ArrayList<>(content));
+        final List<EncodingRetainingSection<?>> sections = sectionDecoder.parseAll(content);
         assertEquals("Unexpected number of sections", expectedNumberOfSections, sections.size());
         return sections;
     }
@@ -324,15 +321,8 @@ public class MessageConverter_Internal_to_1_0Test extends QpidTestCase
         final ArgumentCaptor<Integer> sizeCaptor = ArgumentCaptor.forClass(Integer.class);
 
         when(_handle.getContent(offsetCaptor.capture(),
-                                sizeCaptor.capture())).then(new Answer<Collection<QpidByteBuffer>>()
-        {
-            @Override
-            public Collection<QpidByteBuffer> answer(final InvocationOnMock invocation) throws Throwable
-            {
-                final QpidByteBuffer view = combined.view(offsetCaptor.getValue(), sizeCaptor.getValue());
-                return Collections.singleton(view);
-            }
-        });
+                                sizeCaptor.capture())).then(invocation -> combined.view(offsetCaptor.getValue(),
+                                                                                        sizeCaptor.getValue()));
     }
 
     private Byte getJmsMessageTypeAnnotation(final Message_1_0 convertedMessage)
@@ -362,7 +352,7 @@ public class MessageConverter_Internal_to_1_0Test extends QpidTestCase
     {
         final InternalMessage sourceMessage = getAmqMessage(messageBytes, mimeType);
         final Message_1_0 convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent();
 
         List<EncodingRetainingSection<?>> sections = getEncodingRetainingSections(content, 1);
         EncodingRetainingSection<?> encodingRetainingSection = sections.get(0);

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_v1_0_to_InternalTest.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_v1_0_to_InternalTest.java b/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_v1_0_to_InternalTest.java
index 3b2ac14..21f9d69 100644
--- a/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_v1_0_to_InternalTest.java
+++ b/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/MessageConverter_v1_0_to_InternalTest.java
@@ -57,7 +57,6 @@ import org.apache.qpid.server.protocol.v1_0.type.messaging.Header;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations;
 import org.apache.qpid.server.protocol.v1_0.type.messaging.Properties;
 import org.apache.qpid.server.store.StoredMessage;
-import org.apache.qpid.server.util.ByteBufferUtils;
 import org.apache.qpid.test.utils.QpidTestCase;
 
 public class MessageConverter_v1_0_to_InternalTest extends QpidTestCase
@@ -117,8 +116,6 @@ public class MessageConverter_v1_0_to_InternalTest extends QpidTestCase
 
         final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
-
         assertEquals("Unexpected mime type",
                      "application/x-java-serialized-object",
                      convertedMessage.getMessageHeader().getMimeType());
@@ -133,8 +130,6 @@ public class MessageConverter_v1_0_to_InternalTest extends QpidTestCase
 
         final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
-
         assertEquals("Unexpected mime type", null, convertedMessage.getMessageHeader().getMimeType());
         assertNull("Unexpected content", convertedMessage.getMessageBody());
     }
@@ -218,7 +213,6 @@ public class MessageConverter_v1_0_to_InternalTest extends QpidTestCase
         final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
         assertEquals("Unexpected mime type", "text/plain", convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertEquals("Unexpected content", expected, convertedMessage.getMessageBody());
     }
 
@@ -611,17 +605,6 @@ public class MessageConverter_v1_0_to_InternalTest extends QpidTestCase
         assertEquals("Unexpected content", null, convertedMessage.getMessageBody());
     }
 
-    private byte[] getBytes(final Collection<QpidByteBuffer> content) throws Exception
-    {
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        for (QpidByteBuffer buf : content)
-        {
-            ByteStreams.copy(buf.asInputStream(), bos);
-            buf.dispose();
-        }
-        return bos.toByteArray();
-    }
-
     private Message_1_0 createTestMessage(final EncodingRetainingSection encodingRetainingSection)
     {
         return createTestMessage(new Properties(), encodingRetainingSection);
@@ -684,19 +667,19 @@ public class MessageConverter_v1_0_to_InternalTest extends QpidTestCase
 
         if (section != null)
         {
-            final QpidByteBuffer combined = QpidByteBuffer.wrap(ByteBufferUtils.combine(section.getEncodedForm()));
+            // TODO this is leaking QBBs
+            final QpidByteBuffer combined = section.getEncodedForm();
             when(storedMessage.getContentSize()).thenReturn((int) section.getEncodedSize());
             final ArgumentCaptor<Integer> offsetCaptor = ArgumentCaptor.forClass(Integer.class);
             final ArgumentCaptor<Integer> sizeCaptor = ArgumentCaptor.forClass(Integer.class);
 
             when(storedMessage.getContent(offsetCaptor.capture(),
-                                          sizeCaptor.capture())).then(invocation ->
-                                                                      {
-                                                                          final QpidByteBuffer view = combined.view(
-                                                                                  offsetCaptor.getValue(),
-                                                                                  sizeCaptor.getValue());
-                                                                          return Collections.singleton(view);
-                                                                      });
+                                          sizeCaptor.capture())).then(invocation -> combined.view(offsetCaptor.getValue(),
+                                                                                                  sizeCaptor.getValue()));
+        }
+        else
+        {
+            when(storedMessage.getContent(0,0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
         }
         return new Message_1_0(storedMessage);
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/PropertyConverter_v1_0_to_InternalTest.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/PropertyConverter_v1_0_to_InternalTest.java b/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/PropertyConverter_v1_0_to_InternalTest.java
index dea495a..cbb6dac 100644
--- a/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/PropertyConverter_v1_0_to_InternalTest.java
+++ b/broker-plugins/amqp-1-0-protocol/src/test/java/org/apache/qpid/server/protocol/v1_0/PropertyConverter_v1_0_to_InternalTest.java
@@ -28,12 +28,10 @@ import static org.mockito.Mockito.when;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
-import org.apache.qpid.server.bytebuffer.QpidByteBufferUtils;
 import org.apache.qpid.server.message.internal.InternalMessage;
 import org.apache.qpid.server.model.NamedAddressSpace;
 import org.apache.qpid.server.protocol.v1_0.type.Binary;
@@ -390,10 +388,15 @@ public class PropertyConverter_v1_0_to_InternalTest extends QpidTestCase
         {
             Binary binary = new Binary(content);
             DataSection dataSection = new Data(binary).createEncodingRetainingSection();
-            List<QpidByteBuffer> qbbList = dataSection.getEncodedForm();
-            int length = (int) QpidByteBufferUtils.remaining(qbbList);
+            QpidByteBuffer qbb = dataSection.getEncodedForm();
+            int length = qbb.remaining();
             when(storedMessage.getContentSize()).thenReturn(length);
-            when(storedMessage.getContent(0, length)).thenReturn(qbbList);
+            when(storedMessage.getContent(0, length)).thenReturn(qbb);
+        }
+        else
+        {
+            when(storedMessage.getContentSize()).thenReturn(0);
+            when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
         }
         return new Message_1_0(storedMessage);
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_1_0_to_v0_10.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_1_0_to_v0_10.java b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_1_0_to_v0_10.java
index 3a36b58..50a9484 100644
--- a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_1_0_to_v0_10.java
+++ b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/main/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_1_0_to_v0_10.java
@@ -33,8 +33,6 @@ import static org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.get
 import static org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getUserId;
 
 import java.nio.ByteBuffer;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.Date;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -127,9 +125,9 @@ public class MessageConverter_1_0_to_v0_10 implements MessageConverter<Message_1
             }
 
             @Override
-            public Collection<QpidByteBuffer> getContent(final int offset, final int length)
+            public QpidByteBuffer getContent(final int offset, final int length)
             {
-                return Collections.singleton(QpidByteBuffer.wrap(convertedContent, offset, length));
+                return QpidByteBuffer.wrap(convertedContent, offset, length);
             }
 
             @Override

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0Test.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0Test.java b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0Test.java
index 7cf43ce..21f17c4 100644
--- a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0Test.java
+++ b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_0_10_to_1_0Test.java
@@ -29,8 +29,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -38,8 +36,6 @@ import java.util.UUID;
 
 import com.google.common.collect.Lists;
 import org.mockito.ArgumentCaptor;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
 
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.server.message.AMQMessageHeader;
@@ -342,12 +338,12 @@ public class MessageConverter_0_10_to_1_0Test extends QpidTestCase
         return expected;
     }
 
-    private List<EncodingRetainingSection<?>> getEncodingRetainingSections(final Collection<QpidByteBuffer> content,
+    private List<EncodingRetainingSection<?>> getEncodingRetainingSections(final QpidByteBuffer content,
                                                                            final int expectedNumberOfSections)
             throws Exception
     {
         SectionDecoder sectionDecoder = new SectionDecoderImpl(_typeRegistry.getSectionDecoderRegistry());
-        final List<EncodingRetainingSection<?>> sections = sectionDecoder.parseAll(new ArrayList<>(content));
+        final List<EncodingRetainingSection<?>> sections = sectionDecoder.parseAll(content);
         assertEquals("Unexpected number of sections", expectedNumberOfSections, sections.size());
         return sections;
     }
@@ -378,15 +374,8 @@ public class MessageConverter_0_10_to_1_0Test extends QpidTestCase
         final ArgumentCaptor<Integer> sizeCaptor = ArgumentCaptor.forClass(Integer.class);
 
         when(_handle.getContent(offsetCaptor.capture(),
-                                sizeCaptor.capture())).then(new Answer<Collection<QpidByteBuffer>>()
-        {
-            @Override
-            public Collection<QpidByteBuffer> answer(final InvocationOnMock invocation) throws Throwable
-            {
-                final QpidByteBuffer view = combined.view(offsetCaptor.getValue(), sizeCaptor.getValue());
-                return Collections.singleton(view);
-            }
-        });
+                                sizeCaptor.capture())).then(invocation -> combined.view(offsetCaptor.getValue(),
+                                                                                        sizeCaptor.getValue()));
     }
 
     private Byte getJmsMessageTypeAnnotation(final Message_1_0 convertedMessage)
@@ -468,7 +457,7 @@ public class MessageConverter_0_10_to_1_0Test extends QpidTestCase
     {
         final MessageTransferMessage sourceMessage = getAmqMessage(messageBytes, mimeType);
         final Message_1_0 convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
 
         List<EncodingRetainingSection<?>> sections = getEncodingRetainingSections(content, 1);
         EncodingRetainingSection<?> encodingRetainingSection = sections.get(0);

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_1_0_to_v0_10Test.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_1_0_to_v0_10Test.java b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_1_0_to_v0_10Test.java
index 3e83f73..8bbc6a7 100644
--- a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_1_0_to_v0_10Test.java
+++ b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/MessageConverter_1_0_to_v0_10Test.java
@@ -27,9 +27,9 @@ import static org.mockito.Mockito.when;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.ObjectOutputStream;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -67,7 +67,6 @@ import org.apache.qpid.server.typedmessage.mimecontentconverter.JmsMapMessageToM
 import org.apache.qpid.server.typedmessage.mimecontentconverter.JmsStreamMessageToList;
 import org.apache.qpid.server.typedmessage.mimecontentconverter.ListToJmsStreamMessage;
 import org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage;
-import org.apache.qpid.server.util.ByteBufferUtils;
 import org.apache.qpid.test.utils.QpidTestCase;
 
 public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
@@ -127,7 +126,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
 
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
 
         assertEquals("Unexpected mime type",
                      "application/java-object-stream",
@@ -143,7 +142,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
 
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
 
         assertEquals("Unexpected mime type", "jms/map-message", convertedMessage.getMessageHeader().getMimeType());
         assertArrayEquals("Unexpected content size",
@@ -235,7 +234,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
 
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
 
         assertEquals("Unexpected mime type", "jms/map-message", convertedMessage.getMessageHeader().getMimeType());
 
@@ -268,7 +267,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
         assertEquals("Unexpected mime type", "text/plain", convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertEquals("Unexpected content", expected, new String(getBytes(content), UTF_8));
     }
 
@@ -282,7 +281,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
         assertEquals("Unexpected mime type", "text/plain", convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertEquals("Unexpected content", expected, new String(getBytes(content), UTF_8));
     }
 
@@ -298,7 +297,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
         assertEquals("Unexpected mime type", "jms/map-message", convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
 
         Map<String, Object> convertedMap = new JmsMapMessageToMap().toObject(getBytes(content));
         assertEquals("Unexpected size", originalMap.size(), convertedMap.size());
@@ -319,7 +318,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
         assertEquals("Unexpected mime type", "amqp/map", convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
 
         Map<String, Object> convertedMap = new AmqpMapToMapConverter().toObject(getBytes(content));
         assertEquals("Unexpected size", originalMap.size(), convertedMap.size());
@@ -355,7 +354,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
         assertEquals("Unexpected mime type", "jms/stream-message", convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
 
         List<Object> convertedList = new JmsStreamMessageToList().toObject(getBytes(content));
         assertEquals("Unexpected size", originalList.size(), convertedList.size());
@@ -374,7 +373,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
         assertEquals("Unexpected mime type", "amqp/list", convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
 
         List<Object> convertedList = new AmqpListToListConverter().toObject(getBytes(content));
         assertEquals("Unexpected size", originalList.size(), convertedList.size());
@@ -427,7 +426,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
         assertEquals("Unexpected mime type", "jms/stream-message", convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertEquals("Unexpected content", expected, new JmsStreamMessageToList().toObject(getBytes(content)));
     }
 
@@ -440,7 +439,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
         assertEquals("Unexpected mime type", "amqp/list", convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
 
         List<Object> convertedList = new AmqpListToListConverter().toObject(getBytes(content));
         assertEquals("Unexpected size", originalList.size(), convertedList.size());
@@ -500,7 +499,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
 
         assertEquals("Unexpected mime type",
                      expectedMimeType, convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertArrayEquals("Unexpected content", data, getBytes(content));
     }
 
@@ -520,7 +519,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
 
         assertEquals("Unexpected mime type",
                      expectedMimeType, convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertArrayEquals("Unexpected content", data, getBytes(content));
     }
 
@@ -553,7 +552,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
 
         assertEquals("Unexpected mime type",
                      expectedMimeType, convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertArrayEquals("Unexpected content", data, getBytes(content));
     }
 
@@ -573,7 +572,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
 
         assertEquals("Unexpected mime type",
                      expectedMimeType, convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertArrayEquals("Unexpected content", data, getBytes(content));
     }
 
@@ -643,7 +642,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
         assertEquals("Unexpected mime type", "amqp/map", convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertArrayEquals("Unexpected content", bytes, getBytes(content));
     }
 
@@ -660,7 +659,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
         assertEquals("Unexpected mime type", "jms/map-message", convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertArrayEquals("Unexpected content", bytes, getBytes(content));
     }
 
@@ -677,7 +676,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
         assertEquals("Unexpected mime type", "amqp/list", convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertArrayEquals("Unexpected content", bytes, getBytes(content));
     }
 
@@ -694,7 +693,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
         assertEquals("Unexpected mime type", "jms/stream-message", convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertArrayEquals("Unexpected content", bytes, getBytes(content));
     }
 
@@ -711,7 +710,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         assertEquals("Unexpected mime type",
                      "application/java-object-stream",
                      convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertArrayEquals("Unexpected content", expected, getBytes(content));
     }
 
@@ -729,7 +728,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         assertEquals("Unexpected mime type",
                      "application/java-object-stream",
                      convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertArrayEquals("Unexpected content", expected, getBytes(content));
     }
 
@@ -746,7 +745,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         assertEquals("Unexpected mime type",
                      "application/octet-stream",
                      convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertArrayEquals("Unexpected content", expected, getBytes(content));
     }
 
@@ -761,7 +760,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
         assertEquals("Unexpected mime type",
                      "application/octet-stream",
                      convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertArrayEquals("Unexpected content", expected, getBytes(content));
     }
 
@@ -781,7 +780,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
 
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
 
         assertEquals("Unexpected mime type",
                      "application/java-object-stream",
@@ -795,7 +794,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
 
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
 
         assertEquals("Unexpected mime type", "jms/map-message", convertedMessage.getMessageHeader().getMimeType());
         assertArrayEquals("Unexpected content size",
@@ -894,7 +893,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
 
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
 
         assertEquals("Unexpected mime type", "jms/map-message", convertedMessage.getMessageHeader().getMimeType());
 
@@ -929,21 +928,21 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
 
         final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
 
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
         assertEquals("Unexpected content", expected, new String(getBytes(content), UTF_8));
 
         assertEquals("Unexpected mime type", "text/plain", convertedMessage.getMessageHeader().getMimeType());
     }
 
-    private byte[] getBytes(final Collection<QpidByteBuffer> content) throws Exception
+    private byte[] getBytes(final QpidByteBuffer content) throws Exception
     {
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        for (QpidByteBuffer buf : content)
+        try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
+             InputStream contentInputStream = content.asInputStream())
         {
-            ByteStreams.copy(buf.asInputStream(), bos);
-            buf.dispose();
+            ByteStreams.copy(contentInputStream, bos);
+            content.dispose();
+            return bos.toByteArray();
         }
-        return bos.toByteArray();
     }
 
     private Message_1_0 createTestMessage(final EncodingRetainingSection encodingRetainingSection)
@@ -1008,20 +1007,21 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
 
         if (section != null)
         {
-            final QpidByteBuffer combined = QpidByteBuffer.wrap(ByteBufferUtils.combine(section.getEncodedForm()));
+            // TODO this seems to leak QBBs
+            final QpidByteBuffer combined = section.getEncodedForm();
             when(storedMessage.getContentSize()).thenReturn((int) section.getEncodedSize());
             final ArgumentCaptor<Integer> offsetCaptor = ArgumentCaptor.forClass(Integer.class);
             final ArgumentCaptor<Integer> sizeCaptor = ArgumentCaptor.forClass(Integer.class);
 
             when(storedMessage.getContent(offsetCaptor.capture(),
-                                          sizeCaptor.capture())).then(invocation ->
-                                                                      {
-                                                                          final QpidByteBuffer view = combined.view(
-                                                                                  offsetCaptor.getValue(),
-                                                                                  sizeCaptor.getValue());
-                                                                          return Collections.singleton(view);
-                                                                      });
+                                          sizeCaptor.capture())).then(invocation -> combined.view(offsetCaptor.getValue(),
+                                                                                                  sizeCaptor.getValue()));
         }
+        else
+        {
+            when(storedMessage.getContent(0,0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
+        }
+
         return new Message_1_0(storedMessage);
     }
 
@@ -1048,7 +1048,7 @@ public class MessageConverter_1_0_to_v0_10Test extends QpidTestCase
 
         assertEquals("Unexpected mime type",
                      expectedMimeType, convertedMessage.getMessageHeader().getMimeType());
-        final Collection<QpidByteBuffer> content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
+        final QpidByteBuffer content = convertedMessage.getContent();
         assertArrayEquals("Unexpected content", data, getBytes(content));
     }
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_0_10_to_1_0Test.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_0_10_to_1_0Test.java b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_0_10_to_1_0Test.java
index f9b90f6..26f6ff1 100644
--- a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_0_10_to_1_0Test.java
+++ b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_0_10_to_1_0Test.java
@@ -546,8 +546,12 @@ public class PropertyConverter_0_10_to_1_0Test extends QpidTestCase
         if (content != null)
         {
             when(storedMessage.getContentSize()).thenReturn(content.length);
-            when(storedMessage.getContent(0, content.length)).thenReturn(Collections.singleton(QpidByteBuffer.wrap(
-                    content)));
+            when(storedMessage.getContent(0, content.length)).thenReturn(QpidByteBuffer.wrap(content));
+        }
+        else
+        {
+            when(storedMessage.getContentSize()).thenReturn(0);
+            when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
         }
         return new MessageTransferMessage(storedMessage, null);
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_1_0_to_0_10Test.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_1_0_to_0_10Test.java b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_1_0_to_0_10Test.java
index 9e664ba..fea4a40 100644
--- a/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_1_0_to_0_10Test.java
+++ b/broker-plugins/amqp-msg-conv-0-10-to-1-0/src/test/java/org/apache/qpid/server/protocol/converter/v0_10_v1_0/PropertyConverter_1_0_to_0_10Test.java
@@ -31,15 +31,10 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
-import org.apache.qpid.server.bytebuffer.QpidByteBufferUtils;
-import org.apache.qpid.server.message.AMQMessageHeader;
-import org.apache.qpid.server.message.MessageDestination;
-import org.apache.qpid.server.message.internal.InternalMessage;
 import org.apache.qpid.server.model.Exchange;
 import org.apache.qpid.server.model.NamedAddressSpace;
 import org.apache.qpid.server.model.Queue;
@@ -1054,10 +1049,15 @@ public class PropertyConverter_1_0_to_0_10Test extends QpidTestCase
         {
             Binary binary = new Binary(content);
             DataSection dataSection = new Data(binary).createEncodingRetainingSection();
-            List<QpidByteBuffer> qbbList = dataSection.getEncodedForm();
-            int length = (int) QpidByteBufferUtils.remaining(qbbList);
+            QpidByteBuffer qbb = dataSection.getEncodedForm();
+            int length = qbb.remaining();
             when(storedMessage.getContentSize()).thenReturn(length);
-            when(storedMessage.getContent(0, length)).thenReturn(qbbList);
+            when(storedMessage.getContent(0, length)).thenReturn(qbb);
+        }
+        else
+        {
+            when(storedMessage.getContentSize()).thenReturn(0);
+            when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
         }
         return new Message_1_0(storedMessage);
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/660c206d/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_10_to_0_8.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_10_to_0_8.java b/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_10_to_0_8.java
index 1d298d8..7a2c82c 100644
--- a/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_10_to_0_8.java
+++ b/broker-plugins/amqp-msg-conv-0-8-to-0-10/src/main/java/org/apache/qpid/server/protocol/converter/v0_8_v0_10/MessageConverter_0_10_to_0_8.java
@@ -20,33 +20,32 @@
  */
 package org.apache.qpid.server.protocol.converter.v0_8_v0_10;
 
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.qpid.server.protocol.converter.MessageConversionException;
-import org.apache.qpid.server.protocol.v0_8.AMQPInvalidClassException;
 import org.apache.qpid.server.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.server.exchange.ExchangeDefaults;
-import org.apache.qpid.server.protocol.v0_8.AMQShortString;
-import org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties;
-import org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody;
-import org.apache.qpid.server.protocol.v0_8.FieldTable;
-import org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo;
 import org.apache.qpid.server.message.MessageDestination;
 import org.apache.qpid.server.model.Exchange;
 import org.apache.qpid.server.model.NamedAddressSpace;
 import org.apache.qpid.server.plugin.MessageConverter;
 import org.apache.qpid.server.plugin.PluggableService;
+import org.apache.qpid.server.protocol.converter.MessageConversionException;
 import org.apache.qpid.server.protocol.v0_10.MessageTransferMessage;
-import org.apache.qpid.server.protocol.v0_8.AMQMessage;
-import org.apache.qpid.server.protocol.v0_8.MessageMetaData;
-import org.apache.qpid.server.store.StoredMessage;
 import org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties;
 import org.apache.qpid.server.protocol.v0_10.transport.Header;
 import org.apache.qpid.server.protocol.v0_10.transport.MessageDeliveryMode;
 import org.apache.qpid.server.protocol.v0_10.transport.MessageProperties;
 import org.apache.qpid.server.protocol.v0_10.transport.ReplyTo;
+import org.apache.qpid.server.protocol.v0_8.AMQMessage;
+import org.apache.qpid.server.protocol.v0_8.AMQPInvalidClassException;
+import org.apache.qpid.server.protocol.v0_8.AMQShortString;
+import org.apache.qpid.server.protocol.v0_8.FieldTable;
+import org.apache.qpid.server.protocol.v0_8.MessageMetaData;
+import org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties;
+import org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody;
+import org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo;
+import org.apache.qpid.server.store.StoredMessage;
 
 @PluggableService
 public class MessageConverter_0_10_to_0_8 implements MessageConverter<MessageTransferMessage, AMQMessage>
@@ -257,7 +256,7 @@ public class MessageConverter_0_10_to_0_8 implements MessageConverter<MessageTra
             }
 
             @Override
-            public Collection<QpidByteBuffer> getContent(final int offset, final int length)
+            public QpidByteBuffer getContent(final int offset, final int length)
             {
                 return message.getContent(offset, length);
             }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message