qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1720183 [3/3] - in /qpid/java/trunk: bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/ broker-core/src/main/java/org/apache/qpid/server/message/ broker-core/src/main/java/org/apache/qpid/server/message/internal/ broker-core/s...
Date Tue, 15 Dec 2015 15:45:48 GMT
Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java Tue Dec 15 15:45:46 2015
@@ -21,9 +21,7 @@
 package org.apache.qpid.framing;
 
 import java.io.DataInput;
-import java.io.DataOutput;
 import java.io.IOException;
-import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 
@@ -215,7 +213,7 @@ public class EncodingUtils
         }
     }
 
-    public static void writeLongAsShortString(DataOutput buffer, long l) throws IOException
+    public static void writeLongAsShortString(QpidByteBuffer buffer, long l)
     {
         String s = Long.toString(l);
         byte[] encodedString = new byte[1+s.length()];
@@ -225,27 +223,12 @@ public class EncodingUtils
         {
             encodedString[i+1] = (byte) cha[i];
         }
-        buffer.write(encodedString);
-
-
+        buffer.put(encodedString);
 
     }
 
-    public static void writeShortStringBytes(DataOutput buffer, AMQShortString s) throws IOException
-    {
-        if (s != null)
-        {
 
-            s.writeToBuffer(buffer);
-        }
-        else
-        {
-            // really writing out unsigned byte
-            buffer.write((byte) 0);
-        }
-    }
-
-    public static void writeShortStringBytes(QpidByteBuffer buffer, AMQShortString s) throws IOException
+    public static void writeShortStringBytes(QpidByteBuffer buffer, AMQShortString s)
     {
         if (s != null)
         {
@@ -258,13 +241,13 @@ public class EncodingUtils
         }
     }
 
-    public static void writeLongStringBytes(DataOutput buffer, String s) throws IOException
+    public static void writeLongStringBytes(QpidByteBuffer buffer, String s)
     {
         if (s != null)
         {
             int len = getUTF8Length(s);
             writeUnsignedInteger(buffer, len);
-            buffer.write(asUTF8Bytes(s));
+            buffer.put(asUTF8Bytes(s));
 
         }
         else
@@ -273,28 +256,14 @@ public class EncodingUtils
         }
     }
 
-    public static void writeUnsignedByte(DataOutput buffer, short b) throws IOException
-    {
-        byte bv = (byte) b;
-        buffer.write(bv);
-    }
 
-    public static void writeUnsignedShort(DataOutput buffer, int s) throws IOException
+    public static void writeUnsignedByte(QpidByteBuffer buffer, short b)
     {
-        // TODO: Is this comparison safe? Do I need to cast RHS to long?
-        if (s < Short.MAX_VALUE)
-        {
-            buffer.writeShort(s);
-        }
-        else
-        {
-            short sv = (short) s;
-            buffer.write((byte) (0xFF & (sv >> 8)));
-            buffer.write((byte) (0xFF & sv));
-        }
+        byte bv = (byte) b;
+        buffer.put(bv);
     }
 
-    public static void writeUnsignedShort(QpidByteBuffer buffer, int s) throws IOException
+    public static void writeUnsignedShort(QpidByteBuffer buffer, int s)
     {
         // TODO: Is this comparison safe? Do I need to cast RHS to long?
         if (s < Short.MAX_VALUE)
@@ -315,27 +284,7 @@ public class EncodingUtils
         return 4;
     }
 
-    public static void writeUnsignedInteger(DataOutput buffer, long l) throws IOException
-    {
-        // TODO: Is this comparison safe? Do I need to cast RHS to long?
-        if (l < Integer.MAX_VALUE)
-        {
-            buffer.writeInt((int) l);
-        }
-        else
-        {
-            int iv = (int) l;
-
-            // FIXME: This *may* go faster if we build this into a local 4-byte array and then
-            // put the array in a single call.
-            buffer.write((byte) (0xFF & (iv >> 24)));
-            buffer.write((byte) (0xFF & (iv >> 16)));
-            buffer.write((byte) (0xFF & (iv >> 8)));
-            buffer.write((byte) (0xFF & iv));
-        }
-    }
-
-    public static void writeUnsignedInteger(QpidByteBuffer buffer, long l) throws IOException
+    public static void writeUnsignedInteger(QpidByteBuffer buffer, long l)
     {
         // TODO: Is this comparison safe? Do I need to cast RHS to long?
         if (l < Integer.MAX_VALUE)
@@ -356,7 +305,7 @@ public class EncodingUtils
     }
 
 
-    public static void writeFieldTableBytes(DataOutput buffer, FieldTable table) throws IOException
+    public static void writeFieldTableBytes(QpidByteBuffer buffer, FieldTable table)
     {
         if (table != null)
         {
@@ -368,231 +317,12 @@ public class EncodingUtils
         }
     }
 
-    public static void writeBooleans(DataOutput buffer, boolean[] values) throws IOException
-    {
-        byte packedValue = 0;
-        for (int i = 0; i < values.length; i++)
-        {
-            if (values[i])
-            {
-                packedValue = (byte) (packedValue | (1 << i));
-            }
-        }
-
-        buffer.write(packedValue);
-    }
-
-    public static void writeBooleans(DataOutput buffer, boolean value) throws IOException
-    {
-
-        buffer.write(value ? (byte) 1 : (byte) 0);
-    }
-
-    public static void writeBooleans(DataOutput buffer, boolean value0, boolean value1) throws IOException
-    {
-        byte packedValue = value0 ? (byte) 1 : (byte) 0;
-
-        if (value1)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 1));
-        }
-
-        buffer.write(packedValue);
-    }
-
-    public static void writeBooleans(DataOutput buffer, boolean value0, boolean value1, boolean value2) throws IOException
-    {
-        byte packedValue = value0 ? (byte) 1 : (byte) 0;
-
-        if (value1)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 1));
-        }
-
-        if (value2)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 2));
-        }
-
-        buffer.write(packedValue);
-    }
-
-    public static void writeBooleans(DataOutput buffer, boolean value0, boolean value1, boolean value2, boolean value3) throws IOException
-    {
-        byte packedValue = value0 ? (byte) 1 : (byte) 0;
-
-        if (value1)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 1));
-        }
-
-        if (value2)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 2));
-        }
-
-        if (value3)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 3));
-        }
-
-        buffer.write(packedValue);
-    }
-
-    public static void writeBooleans(DataOutput buffer, boolean value0, boolean value1, boolean value2, boolean value3,
-        boolean value4) throws IOException
-    {
-        byte packedValue = value0 ? (byte) 1 : (byte) 0;
-
-        if (value1)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 1));
-        }
-
-        if (value2)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 2));
-        }
-
-        if (value3)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 3));
-        }
-
-        if (value4)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 4));
-        }
-
-        buffer.write(packedValue);
-    }
-
-    public static void writeBooleans(DataOutput buffer, boolean value0, boolean value1, boolean value2, boolean value3,
-        boolean value4, boolean value5) throws IOException
-    {
-        byte packedValue = value0 ? (byte) 1 : (byte) 0;
-
-        if (value1)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 1));
-        }
-
-        if (value2)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 2));
-        }
-
-        if (value3)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 3));
-        }
-
-        if (value4)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 4));
-        }
-
-        if (value5)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 5));
-        }
-
-        buffer.write(packedValue);
-    }
-
-    public static void writeBooleans(DataOutput buffer, boolean value0, boolean value1, boolean value2, boolean value3,
-        boolean value4, boolean value5, boolean value6) throws IOException
-    {
-        byte packedValue = value0 ? (byte) 1 : (byte) 0;
-
-        if (value1)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 1));
-        }
-
-        if (value2)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 2));
-        }
-
-        if (value3)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 3));
-        }
-
-        if (value4)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 4));
-        }
-
-        if (value5)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 5));
-        }
-
-        if (value6)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 6));
-        }
-
-        buffer.write(packedValue);
-    }
-
-    public static void writeBooleans(DataOutput buffer, boolean value0, boolean value1, boolean value2, boolean value3,
-        boolean value4, boolean value5, boolean value6, boolean value7) throws IOException
-    {
-        byte packedValue = value0 ? (byte) 1 : (byte) 0;
-
-        if (value1)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 1));
-        }
-
-        if (value2)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 2));
-        }
-
-        if (value3)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 3));
-        }
-
-        if (value4)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 4));
-        }
-
-        if (value5)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 5));
-        }
-
-        if (value6)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 6));
-        }
-
-        if (value7)
-        {
-            packedValue = (byte) (packedValue | (byte) (1 << 7));
-        }
-
-        buffer.write(packedValue);
-    }
-
-    /**
-     * This is used for writing longstrs.
-     * @param buffer buffer to write to
-     * @param data data to write
-     * @throws IOException if there is an issue writing the output
-     */
-    public static void writeLongstr(DataOutput buffer, byte[] data) throws IOException
+    public static void writeLongstr(QpidByteBuffer buffer, byte[] data)
     {
         if (data != null)
         {
             writeUnsignedInteger(buffer, data.length);
-            buffer.write(data);
+            buffer.put(data);
         }
         else
         {
@@ -600,38 +330,6 @@ public class EncodingUtils
         }
     }
 
-    public static void writeTimestamp(DataOutput buffer, long timestamp) throws IOException
-    {
-        writeLong(buffer, timestamp);
-    }
-
-    public static boolean[] readBooleans(DataInput buffer) throws IOException
-    {
-        final byte packedValue = buffer.readByte();
-        if (packedValue == 0)
-        {
-            return ALL_FALSE_ARRAY;
-        }
-
-        final boolean[] result = new boolean[8];
-
-        result[0] = ((packedValue & 1) != 0);
-        result[1] = ((packedValue & (1 << 1)) != 0);
-        result[2] = ((packedValue & (1 << 2)) != 0);
-        result[3] = ((packedValue & (1 << 3)) != 0);
-        if ((packedValue & 0xF0) == 0)
-        {
-            result[0] = ((packedValue & 1) != 0);
-        }
-
-        result[4] = ((packedValue & (1 << 4)) != 0);
-        result[5] = ((packedValue & (1 << 5)) != 0);
-        result[6] = ((packedValue & (1 << 6)) != 0);
-        result[7] = ((packedValue & (1 << 7)) != 0);
-
-        return result;
-    }
-
     public static FieldTable readFieldTable(MarkableDataInput input) throws AMQFrameDecodingException, IOException
     {
         long length = ((long)(input.readInt())) & 0xFFFFFFFFL;
@@ -652,32 +350,6 @@ public class EncodingUtils
 
     }
 
-    public static String readShortString(DataInput buffer) throws IOException
-    {
-        short length = (short) (((short)buffer.readByte()) & 0xFF);
-        if (length == 0)
-        {
-            return null;
-        }
-        else
-        {
-            // this may seem rather odd to declare two array but testing has shown
-            // that constructing a string from a byte array is 5 (five) times slower
-            // than constructing one from a char array.
-            // this approach here is valid since we know that all the chars are
-            // ASCII (0-127)
-            byte[] stringBytes = new byte[length];
-            buffer.readFully(stringBytes, 0, length);
-            char[] stringChars = new char[length];
-            for (int i = 0; i < stringChars.length; i++)
-            {
-                stringChars[i] = (char) stringBytes[i];
-            }
-
-            return new String(stringChars);
-        }
-    }
-
     public static String readLongString(DataInput buffer) throws IOException
     {
         long length = ((long)(buffer.readInt())) & 0xFFFFFFFFL;
@@ -715,29 +387,6 @@ public class EncodingUtils
         return buffer.readLong();
     }
 
-    static byte[] hexToByteArray(String id)
-    {
-        // Should check param for null, long enough for this check, upper-case and trailing char
-        String s = (id.charAt(1) == 'x') ? id.substring(2) : id; // strip 0x
-
-        int len = s.length();
-        int byte_len = len / 2;
-        byte[] b = new byte[byte_len];
-
-        for (int i = 0; i < byte_len; i++)
-        {
-            // fixme: refine these repetitive subscript calcs.
-            int ch = i * 2;
-
-            byte b1 = Byte.parseByte(s.substring(ch, ch + 1), 16);
-            byte b2 = Byte.parseByte(s.substring(ch + 1, ch + 2), 16);
-
-            b[i] = (byte) ((b1 * 16) + b2);
-        }
-
-        return (b);
-    }
-
     public static char[] convertToHexCharArray(byte[] from)
     {
         int length = from.length;
@@ -765,34 +414,15 @@ public class EncodingUtils
         return (result_buff);
     }
 
-    public static String convertToHexString(byte[] from)
-    {
-        return (new String(convertToHexCharArray(from)));
-    }
-
-    public static String convertToHexString(ByteBuffer bb)
-    {
-        int size = bb.limit();
-
-        byte[] from = new byte[size];
-
-        for (int i = 0; i < size; i++)
-        {
-            from[i] = bb.get(i);
-        }
-
-        return (new String(convertToHexCharArray(from)));
-    }
-
     private static char[] hex_chars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
 
     // **** new methods
 
     // AMQP_BOOLEAN_PROPERTY_PREFIX
 
-    public static void writeBoolean(DataOutput buffer, boolean aBoolean) throws IOException
+    public static void writeBoolean(QpidByteBuffer buffer, boolean aBoolean)
     {
-        buffer.write(aBoolean ? 1 : 0);
+        buffer.put(aBoolean ? (byte)1 : (byte)0);
     }
 
     public static boolean readBoolean(DataInput buffer) throws IOException
@@ -807,12 +437,6 @@ public class EncodingUtils
         return 1;
     }
 
-    // AMQP_BYTE_PROPERTY_PREFIX
-    public static void writeByte(DataOutput buffer, byte aByte) throws IOException
-    {
-        buffer.writeByte(aByte);
-    }
-
     public static byte readByte(DataInput buffer) throws IOException
     {
         return buffer.readByte();
@@ -823,12 +447,6 @@ public class EncodingUtils
         return 1;
     }
 
-    // AMQP_SHORT_PROPERTY_PREFIX
-    public static void writeShort(DataOutput buffer, short aShort) throws IOException
-    {
-        buffer.writeShort(aShort);
-    }
-
     public static short readShort(DataInput buffer) throws IOException
     {
         return buffer.readShort();
@@ -839,12 +457,6 @@ public class EncodingUtils
         return 2;
     }
 
-    // INTEGER_PROPERTY_PREFIX
-    public static void writeInteger(DataOutput buffer, int aInteger) throws IOException
-    {
-        buffer.writeInt(aInteger);
-    }
-
     public static int readInteger(DataInput buffer) throws IOException
     {
         return buffer.readInt();
@@ -855,12 +467,6 @@ public class EncodingUtils
         return 4;
     }
 
-    // AMQP_LONG_PROPERTY_PREFIX
-    public static void writeLong(DataOutput buffer, long aLong) throws IOException
-    {
-        buffer.writeLong(aLong);
-    }
-
     public static long readLong(DataInput buffer) throws IOException
     {
         return buffer.readLong();
@@ -871,12 +477,6 @@ public class EncodingUtils
         return 8;
     }
 
-    // Float_PROPERTY_PREFIX
-    public static void writeFloat(DataOutput buffer, float aFloat) throws IOException
-    {
-        buffer.writeFloat(aFloat);
-    }
-
     public static float readFloat(DataInput buffer) throws IOException
     {
         return buffer.readFloat();
@@ -887,12 +487,6 @@ public class EncodingUtils
         return 4;
     }
 
-    // Double_PROPERTY_PREFIX
-    public static void writeDouble(DataOutput buffer, Double aDouble) throws IOException
-    {
-        buffer.writeDouble(aDouble);
-    }
-
     public static double readDouble(DataInput buffer) throws IOException
     {
         return buffer.readDouble();
@@ -919,16 +513,16 @@ public class EncodingUtils
         }
     }
 
-    public static void writeBytes(DataOutput buffer, byte[] data) throws IOException
+    public static void writeBytes(QpidByteBuffer buffer, byte[] data)
     {
         if (data != null)
         {
             // TODO: check length fits in an unsigned byte
             writeUnsignedInteger(buffer,  (long)data.length);
-            buffer.write(data);
+            buffer.put(data);
         }
         else
-        {                                                    
+        {
             writeUnsignedInteger(buffer, 0L);
         }
     }
@@ -945,12 +539,6 @@ public class EncodingUtils
         return (char) buffer.readByte();
     }
 
-    public static void writeChar(DataOutput buffer, char character) throws IOException
-    {
-        // This is valid as we know that the Character is ASCII 0..127
-        writeByte(buffer, (byte) character);
-    }
-
     public static long readLongAsShortString(DataInput buffer) throws IOException
     {
         short length = (short) buffer.readUnsignedByte();

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeBoundBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeBoundBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeBoundBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeBoundBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class ExchangeBoundBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -95,7 +95,7 @@ public class ExchangeBoundBody extends A
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
         writeAMQShortString( buffer, _exchange );
         writeAMQShortString( buffer, _routingKey );

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeBoundOkBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeBoundOkBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeBoundOkBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeBoundOkBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class ExchangeBoundOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -92,7 +92,7 @@ public class ExchangeBoundOkBody extends
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
         writeUnsignedShort( buffer, _replyCode );
         writeAMQShortString( buffer, _replyText );

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class ExchangeDeclareBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -157,7 +157,7 @@ public class ExchangeDeclareBody extends
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
         writeUnsignedShort( buffer, _ticket );
         writeAMQShortString( buffer, _exchange );

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareOkBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareOkBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareOkBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeclareOkBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class ExchangeDeclareOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -68,7 +68,7 @@ public class ExchangeDeclareOkBody exten
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
     }
 

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class ExchangeDeleteBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -108,7 +108,7 @@ public class ExchangeDeleteBody extends
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
         writeUnsignedShort( buffer, _ticket );
         writeAMQShortString( buffer, _exchange );

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteOkBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteOkBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteOkBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ExchangeDeleteOkBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class ExchangeDeleteOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -68,7 +68,7 @@ public class ExchangeDeleteOkBody extend
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
     }
 

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/FieldArray.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/FieldArray.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/FieldArray.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/FieldArray.java Tue Dec 15 15:45:46 2015
@@ -21,7 +21,6 @@
 package org.apache.qpid.framing;
 
 import java.io.DataInput;
-import java.io.DataOutput;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.AbstractCollection;
@@ -34,6 +33,8 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
+
 public class FieldArray<T> extends AbstractCollection<T>
 {
 
@@ -105,9 +106,9 @@ public class FieldArray<T> extends Abstr
         }
     }
 
-    public void writeToBuffer(final DataOutput buffer) throws IOException
+    public void writeToBuffer(final QpidByteBuffer buffer)
     {
-        buffer.writeInt(getEncodingSize());
+        buffer.putInt(getEncodingSize());
         for( T obj : this)
         {
             AMQTypedValue.toTypedValue(obj).writeToBuffer(buffer);

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/FieldTable.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/FieldTable.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/FieldTable.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/FieldTable.java Tue Dec 15 15:45:46 2015
@@ -20,12 +20,8 @@
  */
 package org.apache.qpid.framing;
 
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutput;
-import java.io.DataOutputStream;
 import java.io.IOException;
 import java.math.BigDecimal;
-import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
@@ -44,7 +40,6 @@ import org.apache.qpid.AMQPInvalidClassE
 import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
-// extends FieldTable
 public class FieldTable
 {
     private static final Logger _logger = LoggerFactory.getLogger(FieldTable.class);
@@ -826,7 +821,7 @@ public class FieldTable
 
     // *************************  Byte Buffer Processing
 
-    public void writeToBuffer(DataOutput buffer) throws IOException
+    public void writeToBuffer(QpidByteBuffer buffer)
     {
         final boolean trace = _logger.isDebugEnabled();
 
@@ -844,21 +839,15 @@ public class FieldTable
         putDataInBuffer(buffer);
     }
 
+
     public byte[] getDataAsBytes()
     {
         if(_encodedForm == null)
         {
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            try
-            {
-                putDataInBuffer(new DataOutputStream(baos));
-                return baos.toByteArray();
-            }
-            catch (IOException e)
-            {
-                throw new IllegalArgumentException("IO Exception should never be thrown here");
-            }
-
+            byte[] data = new byte[(int) getEncodedSize()];
+            QpidByteBuffer buf = QpidByteBuffer.wrap(data);
+            putDataInBuffer(buf);
+            return data;
         }
         else
         {
@@ -1119,14 +1108,14 @@ public class FieldTable
         return _properties.keySet();
     }
 
-    private void putDataInBuffer(DataOutput buffer) throws IOException
+    private void putDataInBuffer(QpidByteBuffer buffer)
     {
         if (_encodedForm != null)
         {
             byte[] encodedCopy = new byte[_encodedForm.remaining()];
             _encodedForm.copyTo(encodedCopy);
 
-            buffer.write(encodedCopy);
+            buffer.put(encodedCopy);
         }
         else if (_properties != null)
         {
@@ -1152,6 +1141,7 @@ public class FieldTable
         }
     }
 
+
     private void setFromBuffer() throws AMQFrameDecodingException, IOException
     {
 

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/HeartbeatBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/HeartbeatBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/HeartbeatBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/HeartbeatBody.java Tue Dec 15 15:45:46 2015
@@ -21,7 +21,6 @@
 package org.apache.qpid.framing;
 
 import java.io.DataInputStream;
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
@@ -58,12 +57,8 @@ public class HeartbeatBody implements AM
         return 0;//heartbeats we generate have no payload
     }
 
-    public void writePayload(DataOutput buffer)
-    {
-    }
-
     @Override
-    public long writePayload(final ByteBufferSender sender) throws IOException
+    public long writePayload(final ByteBufferSender sender)
     {
         return 0l;
     }

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/ProtocolInitiation.java Tue Dec 15 15:45:46 2015
@@ -20,10 +20,8 @@
  */
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
-import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 
@@ -31,7 +29,6 @@ import org.apache.qpid.QpidException;
 import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 import org.apache.qpid.transport.ByteBufferSender;
-import org.apache.qpid.util.BytesDataOutput;
 
 public class ProtocolInitiation extends AMQDataBlock implements EncodableAMQDataBlock
 {
@@ -82,22 +79,18 @@ public class ProtocolInitiation extends
         return 4 + 1 + 1 + 1 + 1;
     }
 
-    public void writePayload(DataOutput buffer) throws IOException
-    {
-
-        buffer.write(_protocolHeader);
-        buffer.write(_protocolClass);
-        buffer.write(_protocolInstance);
-        buffer.write(_protocolMajor);
-        buffer.write(_protocolMinor);
-    }
-
     @Override
-    public long writePayload(final ByteBufferSender sender) throws IOException
+    public long writePayload(final ByteBufferSender sender)
     {
         byte[] data = new byte[8];
-        BytesDataOutput out = new BytesDataOutput(data);
-        writePayload(out);
+        for(int i = 0; i < _protocolHeader.length; i++)
+        {
+            data[i] = _protocolHeader[i];
+        }
+        data[4] = _protocolClass;
+        data[5] = _protocolInstance;
+        data[6] = _protocolMajor;
+        data[7] = _protocolMinor;
         sender.send(QpidByteBuffer.wrap(data));
         return 8l;
     }

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueBindBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueBindBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueBindBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueBindBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class QueueBindBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -126,7 +126,7 @@ public class QueueBindBody extends AMQMe
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
         writeUnsignedShort( buffer, _ticket );
         writeAMQShortString( buffer, _queue );

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueBindOkBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueBindOkBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueBindOkBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueBindOkBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class QueueBindOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -68,7 +68,7 @@ public class QueueBindOkBody extends AMQ
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
     }
 

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeclareBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeclareBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeclareBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeclareBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class QueueDeclareBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -148,7 +148,7 @@ public class QueueDeclareBody extends AM
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
         writeUnsignedShort( buffer, _ticket );
         writeAMQShortString( buffer, _queue );

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeclareOkBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeclareOkBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeclareOkBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeclareOkBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class QueueDeclareOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -93,7 +93,7 @@ public class QueueDeclareOkBody extends
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
         writeAMQShortString( buffer, _queue );
         writeUnsignedInteger( buffer, _messageCount );

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeleteBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeleteBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeleteBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeleteBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class QueueDeleteBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -118,7 +118,7 @@ public class QueueDeleteBody extends AMQ
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
         writeUnsignedShort( buffer, _ticket );
         writeAMQShortString( buffer, _queue );

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeleteOkBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeleteOkBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeleteOkBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueDeleteOkBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class QueueDeleteOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -76,7 +76,7 @@ public class QueueDeleteOkBody extends A
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
         writeUnsignedInteger( buffer, _messageCount );
     }

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueuePurgeBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueuePurgeBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueuePurgeBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueuePurgeBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class QueuePurgeBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -98,7 +98,7 @@ public class QueuePurgeBody extends AMQM
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
         writeUnsignedShort( buffer, _ticket );
         writeAMQShortString( buffer, _queue );

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueuePurgeOkBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueuePurgeOkBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueuePurgeOkBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueuePurgeOkBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class QueuePurgeOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -76,7 +76,7 @@ public class QueuePurgeOkBody extends AM
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
         writeUnsignedInteger( buffer, _messageCount );
     }

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueUnbindBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueUnbindBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueUnbindBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueUnbindBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class QueueUnbindBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -112,7 +112,7 @@ public class QueueUnbindBody extends AMQ
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
         writeUnsignedShort( buffer, _ticket );
         writeAMQShortString( buffer, _queue );

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueUnbindOkBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueUnbindOkBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueUnbindOkBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/QueueUnbindOkBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,10 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.codec.MarkableDataInput;
 
 public class QueueUnbindOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
@@ -68,7 +68,7 @@ public class QueueUnbindOkBody extends A
         return size;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
     }
 

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxCommitBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxCommitBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxCommitBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxCommitBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,8 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
-import java.io.IOException;
-
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 
 public class TxCommitBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
 {
@@ -63,7 +61,7 @@ public class TxCommitBody extends AMQMet
         return 0;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
     }
 

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxCommitOkBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxCommitOkBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxCommitOkBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxCommitOkBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,8 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
-import java.io.IOException;
-
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 
 public class TxCommitOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
 {
@@ -61,7 +59,7 @@ public class TxCommitOkBody extends AMQM
         return 0;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
     }
 

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxRollbackBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxRollbackBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxRollbackBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxRollbackBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,8 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
-import java.io.IOException;
-
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 
 public class TxRollbackBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
 {
@@ -61,7 +59,7 @@ public class TxRollbackBody extends AMQM
         return 0;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
     }
 

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxRollbackOkBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxRollbackOkBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxRollbackOkBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxRollbackOkBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,8 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
-import java.io.IOException;
-
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 
 public class TxRollbackOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
 {
@@ -62,7 +60,7 @@ public class TxRollbackOkBody extends AM
         return 0;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
     }
 

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxSelectBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxSelectBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxSelectBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxSelectBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,8 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
-import java.io.IOException;
-
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 
 public class TxSelectBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
 {
@@ -64,7 +62,7 @@ public class TxSelectBody extends AMQMet
         return 0;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
     }
 

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxSelectOkBody.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxSelectOkBody.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxSelectOkBody.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/TxSelectOkBody.java Tue Dec 15 15:45:46 2015
@@ -27,10 +27,8 @@
 
 package org.apache.qpid.framing;
 
-import java.io.DataOutput;
-import java.io.IOException;
-
 import org.apache.qpid.QpidException;
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 
 public class TxSelectOkBody extends AMQMethodBodyImpl implements EncodableAMQDataBlock, AMQMethodBody
 {
@@ -60,7 +58,7 @@ public class TxSelectOkBody extends AMQM
         return 0;
     }
 
-    public void writeMethodPayload(DataOutput buffer) throws IOException
+    public void writeMethodPayload(QpidByteBuffer buffer)
     {
     }
 

Modified: qpid/java/trunk/common/src/test/java/org/apache/qpid/codec/AMQDecoderTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/test/java/org/apache/qpid/codec/AMQDecoderTest.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/test/java/org/apache/qpid/codec/AMQDecoderTest.java (original)
+++ qpid/java/trunk/common/src/test/java/org/apache/qpid/codec/AMQDecoderTest.java Tue Dec 15 15:45:46 2015
@@ -21,14 +21,15 @@
 package org.apache.qpid.codec;
 
 
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
 import java.util.Random;
 
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.framing.AMQBody;
 import org.apache.qpid.framing.AMQDataBlock;
 import org.apache.qpid.framing.AMQFrame;
@@ -39,7 +40,8 @@ import org.apache.qpid.framing.FrameCrea
 import org.apache.qpid.framing.HeartbeatBody;
 import org.apache.qpid.framing.ProtocolVersion;
 import org.apache.qpid.test.utils.QpidTestCase;
-import org.apache.qpid.util.BytesDataOutput;
+import org.apache.qpid.transport.ByteBufferSender;
+import org.apache.qpid.util.ByteBufferUtils;
 
 public class AMQDecoderTest extends QpidTestCase
 {
@@ -57,9 +59,9 @@ public class AMQDecoderTest extends Qpid
     
     private ByteBuffer getHeartbeatBodyBuffer() throws IOException
     {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        HeartbeatBody.FRAME.writePayload(new DataOutputStream(baos));
-        return ByteBuffer.wrap(baos.toByteArray());
+        TestSender sender = new TestSender();
+        HeartbeatBody.FRAME.writePayload(sender);
+        return ByteBufferUtils.combine(sender.getSentBuffers());
     }
     
     public void testSingleFrameDecode() throws AMQProtocolVersionException, AMQFrameDecodingException, IOException
@@ -85,13 +87,18 @@ public class AMQDecoderTest extends Qpid
         random.nextBytes(payload);
         final AMQBody body = new ContentBody(ByteBuffer.wrap(payload));
         AMQFrame frame = new AMQFrame(1, body);
-        byte[] outputBuf = new byte[4096];
-        BytesDataOutput dataOutput = new BytesDataOutput(outputBuf);
-        frame.writePayload(dataOutput);
-        for(int i = 0 ; i < dataOutput.length(); i++)
+        TestSender sender = new TestSender();
+        frame.writePayload(sender);
+        ByteBuffer allData = ByteBufferUtils.combine(sender.getSentBuffers());
+
+
+        for(int i = 0 ; i < allData.remaining(); i++)
         {
-            _decoder.decodeBuffer(ByteBuffer.wrap(outputBuf, i, 1));
+            byte[] minibuf = new byte[1];
+            minibuf[0] = allData.get(i);
+            _decoder.decodeBuffer(ByteBuffer.wrap(minibuf));
         }
+
         List<AMQDataBlock> frames = _methodProcessor.getProcessedMethods();
         if (frames.get(0) instanceof AMQFrame)
         {
@@ -202,5 +209,34 @@ public class AMQDecoderTest extends Qpid
             }
         }
     }
-    
+
+    private static class TestSender implements ByteBufferSender
+    {
+        private final Collection<QpidByteBuffer> _sentBuffers = new ArrayList<>();
+
+        @Override
+        public void send(final QpidByteBuffer msg)
+        {
+            _sentBuffers.add(msg.duplicate());
+            msg.position(msg.limit());
+        }
+
+        @Override
+        public void flush()
+        {
+
+        }
+
+        @Override
+        public void close()
+        {
+
+        }
+
+        public Collection<QpidByteBuffer> getSentBuffers()
+        {
+            return _sentBuffers;
+        }
+    }
+
 }

Modified: qpid/java/trunk/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java (original)
+++ qpid/java/trunk/common/src/test/java/org/apache/qpid/framing/BasicContentHeaderPropertiesTest.java Tue Dec 15 15:45:46 2015
@@ -80,11 +80,6 @@ public class BasicContentHeaderPropertie
         assertEquals(99, _testProperties.getPropertyFlags());
     }
 
-    public void testWritePropertyListPayload() throws IOException
-    {
-        _testProperties.writePropertyListPayload(new DataOutputStream(new ByteArrayOutputStream(300)));
-    }
-
     public void testPopulatePropertiesFromBuffer() throws Exception
     {
         ByteArrayDataInput buf = new ByteArrayDataInput(new byte[300]);

Modified: qpid/java/trunk/common/src/test/java/org/apache/qpid/framing/FieldTableTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/test/java/org/apache/qpid/framing/FieldTableTest.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/common/src/test/java/org/apache/qpid/framing/FieldTableTest.java (original)
+++ qpid/java/trunk/common/src/test/java/org/apache/qpid/framing/FieldTableTest.java Tue Dec 15 15:45:46 2015
@@ -470,16 +470,16 @@ public class FieldTableTest extends Qpid
         outerTable.setFieldTable("innerTable", innerTable);
 
         // Write the outer table into the buffer.
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        QpidByteBuffer buf = QpidByteBuffer.allocate(EncodingUtils.encodedFieldTableLength(outerTable));
 
-        outerTable.writeToBuffer(new DataOutputStream(baos));
+        outerTable.writeToBuffer(buf);
 
-        byte[] data = baos.toByteArray();
+        buf.flip();
 
         // Extract the table back from the buffer again.
         try
         {
-            FieldTable extractedOuterTable = EncodingUtils.readFieldTable(new ByteArrayDataInput(data));
+            FieldTable extractedOuterTable = EncodingUtils.readFieldTable(buf.asDataInput());
 
             FieldTable extractedTable = extractedOuterTable.getFieldTable("innerTable");
 
@@ -599,10 +599,10 @@ public class FieldTableTest extends Qpid
         table.setString("null-string", null);
 
 
-        ByteArrayOutputStream baos = new ByteArrayOutputStream((int) table.getEncodedSize() + 4);
-        table.writeToBuffer(new DataOutputStream(baos));
+        QpidByteBuffer buf = QpidByteBuffer.allocate((int) table.getEncodedSize() + 4);
+        table.writeToBuffer(buf);
 
-        QpidByteBuffer buf = QpidByteBuffer.wrap(baos.toByteArray());
+        buf.flip();
 
         long length = buf.getInt() & 0xFFFFFFFFL;
         buf = buf.slice();

Modified: qpid/java/trunk/systests/src/test/java/org/apache/qpid/systest/MessageCompressionTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/systest/MessageCompressionTest.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/systest/MessageCompressionTest.java (original)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/systest/MessageCompressionTest.java Tue Dec 15 15:45:46 2015
@@ -38,6 +38,7 @@ import org.apache.qpid.jms.ConnectionURL
 import org.apache.qpid.server.management.plugin.HttpManagement;
 import org.apache.qpid.server.model.AuthenticationProvider;
 import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.Exchange;
 import org.apache.qpid.server.model.Plugin;
 import org.apache.qpid.server.model.Port;
 import org.apache.qpid.systest.rest.RestTestHelper;

Modified: qpid/java/trunk/systests/src/test/java/org/apache/qpid/transport/MaxFrameSizeTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/transport/MaxFrameSizeTest.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/transport/MaxFrameSizeTest.java (original)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/transport/MaxFrameSizeTest.java Tue Dec 15 15:45:46 2015
@@ -20,13 +20,14 @@
  */
 package org.apache.qpid.transport;
 
-import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.Socket;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
@@ -40,8 +41,8 @@ import javax.security.sasl.Sasl;
 import javax.security.sasl.SaslClient;
 import javax.security.sasl.SaslException;
 
+import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.client.BrokerDetails;
-import org.apache.qpid.codec.AMQDecoder;
 import org.apache.qpid.codec.ClientDecoder;
 import org.apache.qpid.framing.*;
 import org.apache.qpid.server.model.AuthenticationProvider;
@@ -242,19 +243,18 @@ public class MaxFrameSizeTest extends Qp
         }
 
         ConnectionStartOkBody startOK = new ConnectionStartOkBody(new FieldTable(), AMQShortString.valueOf("PLAIN"), response, AMQShortString.valueOf("en_US"));
-
-        DataOutputStream dos = new DataOutputStream(os);
-        new AMQFrame(0, startOK).writePayload(dos);
-        dos.flush();
+        TestSender sender = new TestSender(os);
+        new AMQFrame(0, startOK).writePayload(sender);
+        sender.flush();
         ConnectionTuneOkBody tuneOk = new ConnectionTuneOkBody(256, frameSize, 0);
-        new AMQFrame(0, tuneOk).writePayload(dos);
-        dos.flush();
+        new AMQFrame(0, tuneOk).writePayload(sender);
+        sender.flush();
         ConnectionOpenBody open = new ConnectionOpenBody(AMQShortString.valueOf(""),AMQShortString.EMPTY_STRING, false);
 
         try
         {
-            new AMQFrame(0, open).writePayload(dos);
-            dos.flush();
+            new AMQFrame(0, open).writePayload(sender);
+            sender.flush();
 
             socket.setSoTimeout(5000);
         }
@@ -281,17 +281,8 @@ public class MaxFrameSizeTest extends Qp
         }
 
 
-
-        try
-        {
-            new AMQFrame(0, closeOk).writePayload(dos);
-            dos.flush();
-
-        }
-        catch (IOException e)
-        {
-            // ignore - the broker may have closed the socket already
-        }
+        new AMQFrame(0, closeOk).writePayload(sender);
+        sender.flush();
 
 
     }
@@ -378,4 +369,63 @@ public class MaxFrameSizeTest extends Qp
         }
 
     }
+
+    private static class TestSender implements ByteBufferSender
+    {
+        private final Collection<QpidByteBuffer> _sentBuffers = new ArrayList<>();
+        private final OutputStream _output;
+
+
+        private TestSender(final OutputStream output)
+        {
+            _output = output;
+        }
+
+        @Override
+        public void send(final QpidByteBuffer msg)
+        {
+            _sentBuffers.add(msg.duplicate());
+            msg.position(msg.limit());
+        }
+
+        @Override
+        public void flush()
+        {
+            int size = 0;
+            for(QpidByteBuffer buf : _sentBuffers)
+            {
+                size += buf.remaining();
+            }
+            byte[] data = new byte[size];
+            int offset = 0;
+            for(QpidByteBuffer buf : _sentBuffers)
+            {
+                int bufSize = buf.remaining();
+                buf.get(data, offset, bufSize);
+                offset+=bufSize;
+                buf.dispose();
+            }
+            try
+            {
+                _output.write(data);
+            }
+            catch (IOException e)
+            {
+                throw new RuntimeException(e);
+            }
+            finally
+            {
+                _sentBuffers.clear();
+            }
+
+        }
+
+        @Override
+        public void close()
+        {
+
+        }
+
+    }
+
 }

Modified: qpid/java/trunk/systests/src/test/java/org/apache/qpid/transport/ProtocolNegotiationTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/transport/ProtocolNegotiationTest.java?rev=1720183&r1=1720182&r2=1720183&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/transport/ProtocolNegotiationTest.java (original)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/transport/ProtocolNegotiationTest.java Tue Dec 15 15:45:46 2015
@@ -22,12 +22,10 @@ package org.apache.qpid.transport;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.InetSocketAddress;
 import java.net.Socket;
-import java.net.SocketException;
 import java.net.SocketTimeoutException;
-import java.nio.ByteBuffer;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.framing.ByteArrayDataInput;
@@ -127,11 +125,13 @@ public class ProtocolNegotiationTest ext
 
             assertTrue("Expected socket to be connected", socket.isConnected());
 
-            final DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());
+            OutputStream outputStream = socket.getOutputStream();
+            final TestSender sender = new TestSender(outputStream);
             final InputStream inputStream = socket.getInputStream();
 
             // write header
-            pi.writePayload(dataOutputStream);
+            pi.writePayload(sender);
+            sender.flush();
 
             // reader header
             byte[] receivedHeader = new byte[AMQP_HEADER_LEN];
@@ -143,9 +143,9 @@ public class ProtocolNegotiationTest ext
 
             long timeout = System.currentTimeMillis() + 3000;
             boolean brokenPipe = false;
-            while(timeout > System.currentTimeMillis())
+            while (timeout > System.currentTimeMillis())
             {
-                if (!writeHeartbeat(dataOutputStream));
+                if (!writeHeartbeat(sender)) ;
                 {
                     brokenPipe = true;
                     break;
@@ -172,110 +172,39 @@ public class ProtocolNegotiationTest ext
 
             assertTrue("Expected socket to be connected", socket.isConnected());
 
-            final DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());
             final InputStream inputStream = socket.getInputStream();
 
             // write header
-            pi.writePayload(dataOutputStream);
+            TestSender sender = new TestSender(socket.getOutputStream());
+            pi.writePayload(sender);
+            sender.flush();
 
             // reader header
             byte[] receivedHeader = new byte[AMQP_HEADER_LEN];
             int len = inputStream.read(receivedHeader);
             assertEquals("Unexpected number of bytes available from socket", receivedHeader.length, len);
 
-            dataOutputStream.write("NOTANAMPQFRAME".getBytes());
-
+            sender.send(QpidByteBuffer.wrap("NOTANAMPQFRAME".getBytes()));
 
         }
     }
 
-    private boolean writeHeartbeat(final DataOutputStream dataOutputStream)
+    private boolean writeHeartbeat(final TestSender sender)
             throws IOException
     {
-        final AtomicBoolean success = new AtomicBoolean(true);
         if (isBroker010())
         {
             ConnectionHeartbeat heartbeat = new ConnectionHeartbeat();
-            ServerDisassembler serverDisassembler = new ServerDisassembler(new ByteBufferSender()
-            {
-                private void send(final ByteBuffer msg)
-                {
-                    try
-                    {
-                        if(msg.hasArray())
-                        {
-                            dataOutputStream.write(msg.array(), msg.arrayOffset() + msg.position(), msg.remaining());
-                        }
-                        else
-                        {
-                            byte[] data = new byte[msg.remaining()];
-                            msg.duplicate().get(data);
-                            dataOutputStream.write(data, 0, data.length);
-                        }
-                    }
-                    catch (SocketException se)
-                    {
-
-                        success.set(false);
-                    }
-                    catch(IOException e)
-                    {
-                        throw new RuntimeException("Unexpected IOException", e);
-                    }
-                }
-
-                @Override
-                public void send(final QpidByteBuffer msg)
-                {
-                    try
-                    {
-                        if(msg.hasArray())
-                        {
-                            dataOutputStream.write(msg.array(), msg.arrayOffset() + msg.position(), msg.remaining());
-                        }
-                        else
-                        {
-                            byte[] data = new byte[msg.remaining()];
-                            msg.duplicate().get(data);
-                            dataOutputStream.write(data, 0, data.length);
-                        }
-                    }
-                    catch (SocketException se)
-                    {
-
-                        success.set(false);
-                    }
-                    catch(IOException e)
-                    {
-                        throw new RuntimeException("Unexpected IOException", e);
-                    }
-                }
-
-                @Override
-                public void flush()
-                {
-                }
-
-                @Override
-                public void close()
-                {
-                }
-            }, Frame.HEADER_SIZE + 1);
+            ServerDisassembler serverDisassembler = new ServerDisassembler(sender, Frame.HEADER_SIZE + 1);
             serverDisassembler.command(null, heartbeat);
         }
         else
         {
-            try
-            {
-                HeartbeatBody.FRAME.writePayload(dataOutputStream);
-            }
-            catch (SocketException se)
-            {
-                success.set(false);
-            }
+            HeartbeatBody.FRAME.writePayload(sender);
+
         }
 
-        return success.get();
+        return sender.hasSuccess();
     }
 
     private ProtocolVersion convertProtocolToProtocolVersion(final Protocol p)
@@ -300,4 +229,52 @@ public class ProtocolNegotiationTest ext
         }
         return protocolVersion;
     }
+
+    private static class TestSender implements ByteBufferSender
+    {
+        private final OutputStream _output;
+        private boolean _success = true;
+
+
+        private TestSender(final OutputStream output)
+        {
+            _output = output;
+        }
+
+        @Override
+        public void send(final QpidByteBuffer msg)
+        {
+            byte[] data = new byte[msg.remaining()];
+            msg.get(data);
+            try
+            {
+                _output.write(data);
+            }
+            catch (IOException e)
+            {
+                _success = false;
+                throw new RuntimeException(e);
+            }
+
+        }
+
+        public boolean hasSuccess()
+        {
+            return _success;
+        }
+
+        @Override
+        public void flush()
+        {
+
+        }
+
+        @Override
+        public void close()
+        {
+
+        }
+
+    }
+
 }



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


Mime
View raw message