You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2015/07/23 14:06:04 UTC

[01/10] qpid-proton git commit: PROTON-954: fix static access warning

Repository: qpid-proton
Updated Branches:
  refs/heads/master 8f82638b7 -> d37ce2538


PROTON-954: fix static access warning


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/4ca2f049
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/4ca2f049
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/4ca2f049

Branch: refs/heads/master
Commit: 4ca2f0497013b39bfbb317a1f8d1742094a033a4
Parents: 8f82638
Author: Robert Gemmell <ro...@apache.org>
Authored: Thu Jul 23 12:52:17 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Thu Jul 23 12:52:17 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/qpid/proton/engine/impl/TransportImpl.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/4ca2f049/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
index 0902a55..922ba31 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
@@ -80,7 +80,7 @@ public class TransportImpl extends EndpointImpl
     private static final int TRACE_FRAME_PAYLOAD_LENGTH = Integer.getInteger("proton.trace_frame_payload_length", 80);
 
     // trace levels
-    private int _levels = (FRM_ENABLED ? this.TRACE_FRM : 0);
+    private int _levels = (FRM_ENABLED ? TRACE_FRM : 0);
 
     private FrameParser _frameParser;
 


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


[02/10] qpid-proton git commit: PROTON-954: remove TODO that seems to have been implemented

Posted by ro...@apache.org.
PROTON-954: remove TODO that seems to have been implemented


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/a9594ebc
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/a9594ebc
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/a9594ebc

Branch: refs/heads/master
Commit: a9594ebcb9166b072b0a8d146e1b6d108d7237ea
Parents: 4ca2f04
Author: Robert Gemmell <ro...@apache.org>
Authored: Thu Jul 23 12:52:55 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Thu Jul 23 12:52:55 2015 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a9594ebc/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
index 922ba31..5c6aea4 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
@@ -573,7 +573,6 @@ public class TransportImpl extends EndpointImpl
 
             transfer.setMessageFormat(UnsignedInteger.ZERO);
 
-            // TODO - large frames
             ByteBuffer payload = delivery.getData() ==  null ? null :
                 ByteBuffer.wrap(delivery.getData(), delivery.getDataOffset(),
                                 delivery.getDataLength());


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


[10/10] qpid-proton git commit: PROTON-954: remove unused private constants

Posted by ro...@apache.org.
PROTON-954: remove unused private constants


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d37ce253
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d37ce253
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d37ce253

Branch: refs/heads/master
Commit: d37ce253842cdd95e5e8d4e3dbab9103763b0670
Parents: 474d723
Author: Robert Gemmell <ro...@apache.org>
Authored: Thu Jul 23 12:58:12 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Thu Jul 23 12:58:12 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/qpid/proton/engine/impl/DeliveryImpl.java  | 6 ------
 1 file changed, 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d37ce253/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/DeliveryImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/DeliveryImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/DeliveryImpl.java
index 896d8a9..df35d0b 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/DeliveryImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/DeliveryImpl.java
@@ -51,12 +51,6 @@ public class DeliveryImpl implements Delivery
     private DeliveryState _remoteDeliveryState;
     private DeliveryState _defaultDeliveryState = null;
 
-    private static final int DELIVERY_STATE_CHANGED = 1;
-    private static final int ABLE_TO_SEND = 2;
-    private static final int IO_WORK = 4;
-    private static final int DELIVERY_SETTLED = 8;
-
-
     /**
      * A bit-mask representing the outstanding work on this delivery received from the transport layer
      * that has not yet been processed by the application.


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


[06/10] qpid-proton git commit: PROTON-956: avoid overhead of creating frame and payload duplicate objects for logging or tracing if the logging is disabled and there is no tracer

Posted by ro...@apache.org.
PROTON-956: avoid overhead of creating frame and payload duplicate objects for logging or tracing if the logging is disabled and there is no tracer


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/13682652
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/13682652
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/13682652

Branch: refs/heads/master
Commit: 13682652f635544e82c29aa16654fe5031a143db
Parents: b0f3a98
Author: Robert Gemmell <ro...@apache.org>
Authored: Thu Jul 23 12:56:41 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Thu Jul 23 12:56:41 2015 +0100

----------------------------------------------------------------------
 .../qpid/proton/engine/impl/FrameWriter.java    | 35 +++++++++++---------
 .../qpid/proton/engine/impl/TransportImpl.java  |  7 +++-
 2 files changed, 26 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/13682652/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
index b23932a..4c2cc9d 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
@@ -154,23 +154,28 @@ class FrameWriter
         }
         int payloadSize = Math.min(payload == null ? 0 : payload.remaining(), capacity);
 
-        ByteBuffer originalPayload = null;
-        if( payload!=null )
+        ProtocolTracer tracer = _protocolTracer == null ? null : _protocolTracer.get();
+        if( tracer != null || _transport.isTraceFramesEnabled())
         {
-            originalPayload = payload.duplicate();
-            originalPayload.limit(payload.position() + payloadSize);
-        }
-
-        // XXX: this is a bit of a hack but it eliminates duplicate
-        // code, further refactor will fix this
-        if (_frameType == AMQP_FRAME_TYPE) {
-            TransportFrame frame = new TransportFrame(channel, (FrameBody) frameBody, Binary.create(originalPayload));
-            _transport.log(TransportImpl.OUTGOING, frame);
-
-            ProtocolTracer tracer = _protocolTracer.get();
-            if(tracer != null)
+            // XXX: this is a bit of a hack but it eliminates duplicate
+            // code, further refactor will fix this
+            if (_frameType == AMQP_FRAME_TYPE)
             {
-                tracer.sentFrame(frame);
+                ByteBuffer originalPayload = null;
+                if( payload!=null )
+                {
+                    originalPayload = payload.duplicate();
+                    originalPayload.limit(payload.position() + payloadSize);
+                }
+
+                Binary payloadBin = Binary.create(originalPayload);
+                TransportFrame frame = new TransportFrame(channel, (FrameBody) frameBody, payloadBin);
+                _transport.log(TransportImpl.OUTGOING, frame);
+
+                if(tracer != null)
+                {
+                    tracer.sentFrame(frame);
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/13682652/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
index 95a811b..3c472b0 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
@@ -1589,7 +1589,7 @@ public class TransportImpl extends EndpointImpl
 
     void log(String event, TransportFrame frame)
     {
-        if ((_levels & TRACE_FRM) != 0) {
+        if (isTraceFramesEnabled()) {
             StringBuilder msg = new StringBuilder();
             msg.append("[").append(System.identityHashCode(this)).append(":")
                 .append(frame.getChannel()).append("]");
@@ -1605,6 +1605,11 @@ public class TransportImpl extends EndpointImpl
         }
     }
 
+    boolean isTraceFramesEnabled()
+    {
+        return (_levels & TRACE_FRM) != 0;
+    }
+
     @Override
     void localOpen() {}
 


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


[07/10] qpid-proton git commit: PROTON-954: remove unused 'offset' and commented out system.out debug

Posted by ro...@apache.org.
PROTON-954: remove unused 'offset' and commented out system.out debug


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/fff10617
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/fff10617
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/fff10617

Branch: refs/heads/master
Commit: fff1061738a68e3c2de641b7c768c5df9cd68498
Parents: 1368265
Author: Robert Gemmell <ro...@apache.org>
Authored: Thu Jul 23 12:57:01 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Thu Jul 23 12:57:01 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/qpid/proton/engine/impl/FrameWriter.java    | 5 -----
 1 file changed, 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fff10617/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
index 4c2cc9d..aaff3e8 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
@@ -125,9 +125,6 @@ class FrameWriter
         _buffer.put(_frameType);
         _buffer.putShort((short) channel);
         _buffer.position(limit);
-
-        int offset = _bbuf.arrayOffset() + _frameStart;
-        //System.out.println("RAW: \"" + new Binary(_bbuf.array(), offset, frameSize) + "\"");
     }
 
     void writeFrame(int channel, Object frameBody, ByteBuffer payload,
@@ -219,8 +216,6 @@ class FrameWriter
         _bbuf.rewind();
         _bbuf.put(src);
 
-        //System.out.println("RAW: \"" + new Binary(dst.array(), dst.arrayOffset(), dst.position()) + "\"");
-
         return size;
     }
 


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


[03/10] qpid-proton git commit: PROTON-954: remove dead code

Posted by ro...@apache.org.
PROTON-954: remove dead code


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/783129a2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/783129a2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/783129a2

Branch: refs/heads/master
Commit: 783129a28820e4b2a5028c0ae28c29d540d188f7
Parents: a9594eb
Author: Robert Gemmell <ro...@apache.org>
Authored: Thu Jul 23 12:55:25 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Thu Jul 23 12:55:25 2015 +0100

----------------------------------------------------------------------
 .../apache/qpid/proton/engine/impl/TransportImpl.java    | 11 -----------
 1 file changed, 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/783129a2/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
index 5c6aea4..32b20af 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
@@ -492,17 +492,6 @@ public class TransportImpl extends EndpointImpl
         }
     }
 
-    private void dumpQueue(String msg)
-    {
-        System.out.print("  " + msg + "{");
-        DeliveryImpl dlv = _connectionEndpoint.getTransportWorkHead();
-        while (dlv != null) {
-            System.out.print(new Binary(dlv.getTag()) + ", ");
-            dlv = dlv.getTransportWorkNext();
-        }
-        System.out.println("}");
-    }
-
     private void processTransportWork()
     {
         if(_connectionEndpoint != null)


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


[08/10] qpid-proton git commit: PROTON-957: make transfer frame logging more like proton-c, report payload size rather than string length, do it regardless whether string is truncated, indicate whether string is truncated

Posted by ro...@apache.org.
PROTON-957: make transfer frame logging more like proton-c, report payload size rather than string length, do it regardless whether string is truncated, indicate whether string is truncated


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/de99c061
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/de99c061
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/de99c061

Branch: refs/heads/master
Commit: de99c06137a5f51063cce9d997424988e4fb2e29
Parents: fff1061
Author: Robert Gemmell <ro...@apache.org>
Authored: Thu Jul 23 12:57:27 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Thu Jul 23 12:57:27 2015 +0100

----------------------------------------------------------------------
 .../qpid/proton/engine/impl/StringUtils.java    |  92 +++++++++++++
 .../qpid/proton/engine/impl/TransportImpl.java  |  13 +-
 .../proton/engine/impl/StringUtilsTest.java     | 136 +++++++++++++++++++
 3 files changed, 234 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/de99c061/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/StringUtils.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/StringUtils.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/StringUtils.java
new file mode 100644
index 0000000..f80cca3
--- /dev/null
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/StringUtils.java
@@ -0,0 +1,92 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.proton.engine.impl;
+
+import org.apache.qpid.proton.amqp.Binary;
+
+public class StringUtils
+{
+    /**
+     * Converts the Binary to a quoted string.
+     *
+     * @param bin the Binary to convert
+     * @param stringLength the maximum length of stringified content (excluding the quotes, and truncated indicator)
+     * @param appendIfTruncated appends "...(truncated)" if not all of the payload is present in the string
+     * @return the converted string
+     */
+    public static String toQuotedString(final Binary bin,final int stringLength,final boolean appendIfTruncated)
+    {
+        if(bin == null)
+        {
+             return "\"\"";
+        }
+
+        final byte[] binData = bin.getArray();
+        final int binLength = bin.getLength();
+        final int offset = bin.getArrayOffset();
+
+        StringBuilder str = new StringBuilder();
+        str.append("\"");
+
+        int size = 0;
+        boolean truncated = false;
+        for (int i = 0; i < binLength; i++)
+        {
+            byte c = binData[offset + i];
+
+            if (c > 31 && c < 127 && c != '\\')
+            {
+                if (size + 1 <= stringLength)
+                {
+                    size += 1;
+                    str.append((char) c);
+                }
+                else
+                {
+                    truncated = true;
+                    break;
+                }
+            }
+            else
+            {
+                if (size + 4 <= stringLength)
+                {
+                    size += 4;
+                    str.append(String.format("\\x%02x", c));
+                }
+                else
+                {
+                    truncated = true;
+                    break;
+                }
+            }
+        }
+
+        str.append("\"");
+
+        if (truncated && appendIfTruncated)
+        {
+            str.append("...(truncated)");
+        }
+
+        return str.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/de99c061/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
index 3c472b0..7faadc6 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
@@ -77,7 +77,7 @@ public class TransportImpl extends EndpointImpl
     }
 
     private static final boolean FRM_ENABLED = getBooleanEnv("PN_TRACE_FRM");
-    private static final int TRACE_FRAME_PAYLOAD_LENGTH = Integer.getInteger("proton.trace_frame_payload_length", 80);
+    private static final int TRACE_FRAME_PAYLOAD_LENGTH = Integer.getInteger("proton.trace_frame_payload_length", 1024);
 
     // trace levels
     private int _levels = (FRM_ENABLED ? TRACE_FRM : 0);
@@ -1594,12 +1594,11 @@ public class TransportImpl extends EndpointImpl
             msg.append("[").append(System.identityHashCode(this)).append(":")
                 .append(frame.getChannel()).append("]");
             msg.append(" ").append(event).append(" ").append(frame.getBody());
-            if (frame.getPayload() != null) {
-                String payload = frame.getPayload().toString();
-                if (payload.length() > TRACE_FRAME_PAYLOAD_LENGTH) {
-                    payload = payload.substring(0, TRACE_FRAME_PAYLOAD_LENGTH) + "(" + payload.length() + ")";
-                }
-                msg.append(" \"").append(payload).append("\"");
+
+            Binary bin = frame.getPayload();
+            if (bin != null) {
+                msg.append(" (").append(bin.getLength()).append(") ");
+                msg.append(StringUtils.toQuotedString(bin, TRACE_FRAME_PAYLOAD_LENGTH, true));
             }
             System.out.println(msg.toString());
         }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/de99c061/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/StringUtilsTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/StringUtilsTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/StringUtilsTest.java
new file mode 100644
index 0000000..8711b9f
--- /dev/null
+++ b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/StringUtilsTest.java
@@ -0,0 +1,136 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.proton.engine.impl;
+
+import static org.junit.Assert.*;
+
+import org.apache.qpid.proton.amqp.Binary;
+import org.junit.Test;
+
+public class StringUtilsTest
+{
+    @Test
+    public void testNullBinary()
+    {
+        assertEquals("unexpected result", "\"\"", StringUtils.toQuotedString(null, 10, true));
+    }
+
+    @Test
+    public void testEmptyBinaryEmptyArray()
+    {
+        Binary bin = new Binary(new byte[0]);
+        assertEquals("unexpected result", "\"\"", StringUtils.toQuotedString(bin, 10, true));
+    }
+
+    @Test
+    public void testEmptyBinaryNonEmptyArray()
+    {
+        byte[] bytes = new byte[] {(byte) 0, (byte) 0, (byte) 0};
+        Binary bin = new Binary(bytes, 0, 0);
+        assertEquals("unexpected result", "\"\"", StringUtils.toQuotedString(bin, 10, true));
+    }
+
+    @Test
+    public void testEmptyBinaryNonEmptyArrayWithOffset()
+    {
+        byte[] bytes = new byte[] {(byte) 0, (byte) 0, (byte) 0};
+        Binary bin = new Binary(bytes, 1, 0);
+        assertEquals("unexpected result", "\"\"", StringUtils.toQuotedString(bin, 10, true));
+    }
+
+    @Test
+    public void testBinaryStringifiedSmallerThanGivenMaxLength()
+    {
+        byte[] bytes = new byte[] {(byte) 0, (byte) 1, (byte) 3, (byte) 65, (byte) 152};
+        String expected = "\"\\x00\\x01\\x03A\\x98\"";
+        Binary bin = new Binary(bytes);
+        assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 100, true));
+        assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 100, false));
+    }
+
+    @Test
+    public void testBinaryStringifiedSmallerThanGivenMaxLengthWithOffset()
+    {
+        byte[] bytes = new byte[] {(byte) 0, (byte) 1, (byte) 3, (byte) 65, (byte) 152};
+        String expected = "\"\\x01\\x03A\\x98\"";
+        Binary bin = new Binary(bytes, 1, 4);
+        assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 100, true));
+        assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 100, false));
+    }
+
+    @Test
+    public void testBinaryStringifiedEqualToGivenMaxLength()
+    {
+        byte[] bytes = new byte[] {(byte) 0, (byte) 1, (byte) 3, (byte) 65};
+        String expected = "\"\\x00\\x01\\x03A\"";
+        Binary bin = new Binary(bytes);
+        assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 15, true));
+        assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 15, false));
+
+        bytes = new byte[] {(byte) 0, (byte) 1, (byte) 65, (byte) 3};
+        expected = "\"\\x00\\x01A\\x03\"";
+        bin = new Binary(bytes);
+        assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 15, true));
+        assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 15, false));
+    }
+
+    @Test
+    public void testBinaryStringifiedEqualToGivenMaxLengthWithOffset()
+    {
+        byte[] bytes = new byte[] {(byte) 0, (byte) 1, (byte) 3, (byte) 65};
+        String expected = "\"\\x01\\x03A\"";
+        Binary bin = new Binary(bytes, 1, 3);
+        assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 11, true));
+        assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 11, false));
+
+        bytes = new byte[] {(byte) 0, (byte) 1, (byte) 65, (byte) 3};
+        expected = "\"\\x01A\\x03\"";
+        bin = new Binary(bytes, 1, 3);
+        assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 11, true));
+        assertEquals("unexpected result", expected, StringUtils.toQuotedString(bin, 11, false));
+    }
+
+    @Test
+    public void testBinaryStringifiedLargerThanGivenMaxLength()
+    {
+        byte[] bytes = new byte[] {(byte) 0, (byte) 1, (byte) 3};
+        String expected1 = "\"\\x00\\x01\"";
+        Binary bin = new Binary(bytes);
+
+        assertEquals("unexpected result", expected1, StringUtils.toQuotedString(bin, 10, false));
+
+        String expected2 = "\"\\x00\\x01\"...(truncated)";
+        assertEquals("unexpected result", expected2, StringUtils.toQuotedString(bin, 10, true));
+    }
+
+    @Test
+    public void testBinaryStringifiedLargerThanGivenMaxLengthWithOffset()
+    {
+        byte[] bytes = new byte[] {(byte) 0, (byte) 1, (byte) 3};
+        String expected1 = "\"\\x00\\x01\"";
+        Binary bin = new Binary(bytes);
+
+        assertEquals("unexpected result", expected1, StringUtils.toQuotedString(bin, 10, false));
+
+        String expected2 = "\"\\x00\\x01\"...(truncated)";
+        assertEquals("unexpected result", expected2, StringUtils.toQuotedString(bin, 10, true));
+    }
+}


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


[04/10] qpid-proton git commit: PROTON-954: remove TODO that no longer applies - suggested action is now done during init()

Posted by ro...@apache.org.
PROTON-954: remove TODO that no longer applies - suggested action is now done during init()


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c72ec776
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c72ec776
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c72ec776

Branch: refs/heads/master
Commit: c72ec776443c223a5d3a9cc9d343f6a00dcd5373
Parents: 783129a
Author: Robert Gemmell <ro...@apache.org>
Authored: Thu Jul 23 12:55:46 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Thu Jul 23 12:55:46 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/qpid/proton/engine/impl/TransportImpl.java    | 3 ---
 1 file changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c72ec776/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
index 32b20af..95a811b 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java
@@ -190,9 +190,6 @@ public class TransportImpl extends EndpointImpl
         return _remoteMaxFrameSize;
     }
 
-    /**
-     * TODO propagate the new value to {@link #_outputProcessor} etc
-     */
     @Override
     public void setMaxFrameSize(int maxFrameSize)
     {


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


[05/10] qpid-proton git commit: PROTON-955: only pass the payload that will be included in the transfer, not the full remaining payload

Posted by ro...@apache.org.
PROTON-955: only pass the payload that will be included in the transfer, not the full remaining payload


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/b0f3a987
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b0f3a987
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b0f3a987

Branch: refs/heads/master
Commit: b0f3a9873fa0cb430c69ac3dd5fa262e338f7263
Parents: c72ec77
Author: Robert Gemmell <ro...@apache.org>
Authored: Thu Jul 23 12:56:12 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Thu Jul 23 12:56:12 2015 +0100

----------------------------------------------------------------------
 .../qpid/proton/engine/impl/FrameWriter.java       | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b0f3a987/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
index 382c726..b23932a 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter.java
@@ -146,10 +146,19 @@ class FrameWriter
             writePerformative(frameBody);
         }
 
+        int capacity;
+        if (_maxFrameSize > 0) {
+            capacity = _maxFrameSize - _performativeSize;
+        } else {
+            capacity = Integer.MAX_VALUE;
+        }
+        int payloadSize = Math.min(payload == null ? 0 : payload.remaining(), capacity);
+
         ByteBuffer originalPayload = null;
         if( payload!=null )
         {
             originalPayload = payload.duplicate();
+            originalPayload.limit(payload.position() + payloadSize);
         }
 
         // XXX: this is a bit of a hack but it eliminates duplicate
@@ -165,14 +174,6 @@ class FrameWriter
             }
         }
 
-        int capacity;
-        if (_maxFrameSize > 0) {
-            capacity = _maxFrameSize - _performativeSize;
-        } else {
-            capacity = Integer.MAX_VALUE;
-        }
-        int payloadSize = Math.min(payload == null ? 0 : payload.remaining(), capacity);
-
         if(payloadSize > 0)
         {
             while (_buffer.remaining() < payloadSize) {


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


[09/10] qpid-proton git commit: PROTON-954: remove unused imports

Posted by ro...@apache.org.
PROTON-954: remove unused imports


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/474d7238
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/474d7238
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/474d7238

Branch: refs/heads/master
Commit: 474d7238c1f0d729cb3ecd3134ffe96743a4298d
Parents: de99c06
Author: Robert Gemmell <ro...@apache.org>
Authored: Thu Jul 23 12:57:44 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Thu Jul 23 12:57:44 2015 +0100

----------------------------------------------------------------------
 proton-j/src/main/java/org/apache/qpid/proton/TestDecoder.java | 2 --
 proton-j/src/main/java/org/apache/qpid/proton/amqp/Binary.java | 2 --
 2 files changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/474d7238/proton-j/src/main/java/org/apache/qpid/proton/TestDecoder.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/TestDecoder.java b/proton-j/src/main/java/org/apache/qpid/proton/TestDecoder.java
index 144fc2f..50d53f7 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/TestDecoder.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/TestDecoder.java
@@ -28,13 +28,11 @@ import org.apache.qpid.proton.amqp.UnsignedByte;
 import org.apache.qpid.proton.amqp.UnsignedInteger;
 import org.apache.qpid.proton.amqp.UnsignedLong;
 import org.apache.qpid.proton.amqp.UnsignedShort;
-import org.apache.qpid.proton.amqp.messaging.AmqpValue;
 import org.apache.qpid.proton.codec.AMQPDefinedTypes;
 
 import org.apache.qpid.proton.codec.DecoderImpl;
 import org.apache.qpid.proton.codec.EncoderImpl;
 
-import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Date;
 import java.util.List;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/474d7238/proton-j/src/main/java/org/apache/qpid/proton/amqp/Binary.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/amqp/Binary.java b/proton-j/src/main/java/org/apache/qpid/proton/amqp/Binary.java
index f640e3c..aac3fc5 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/amqp/Binary.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/amqp/Binary.java
@@ -23,8 +23,6 @@ package org.apache.qpid.proton.amqp;
 import java.nio.ByteBuffer;
 import java.util.Collection;
 
-import static java.lang.Math.min;
-
 public final class Binary
 {
 


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