qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [5/5] qpid-proton git commit: Bug fixes
Date Mon, 05 Oct 2015 16:46:51 GMT
Bug fixes


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

Branch: refs/heads/rajith-codec
Commit: 12ff4f5cb0c179cbce4d7c98df3b182681c21f8f
Parents: e0325d5
Author: Rajith Attapattu <rajith@apache.org>
Authored: Sun Oct 4 18:14:57 2015 -0400
Committer: Rajith Attapattu <rajith@apache.org>
Committed: Sun Oct 4 18:14:57 2015 -0400

----------------------------------------------------------------------
 .../qpid/proton/engine/impl/FrameParser2.java   | 28 +++++++++++++++++---
 .../qpid/proton/engine/impl/FrameWriter2.java   | 17 +++++-------
 .../qpid/proton/engine/impl/TransportImpl2.java | 12 +++++++--
 3 files changed, 40 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/12ff4f5c/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameParser2.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameParser2.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameParser2.java
index c1ab38b..e45a25e 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameParser2.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameParser2.java
@@ -379,16 +379,19 @@ class FrameParser2 implements TransportInput
                             // temp workaround
                             byte[] body = new byte[in.remaining()];
                             in.get(body);
-                            _decoder.init(body, 0, body.length);
+                            
+                            int payloadStart = payloadStart(body); 
+                            
+                            _decoder.init(body, 0, payloadStart);
                             POJOBuilder pb = new POJOBuilder();
                             _decoder.decode(pb);
                             List l = (List) pb.build();
                             Object obj = l.get(0);
                             byte[] payloadBytes = null;
-                            if(in.hasRemaining())
+                            if(payloadStart < body.length)
                             {                          
-                                payloadBytes = new byte[in.remaining()];
-                                in.get(payloadBytes);
+                                payloadBytes = new byte[body.length - payloadStart];
+                                System.arraycopy(body, payloadStart, payloadBytes, 0, payloadBytes.length);
                             }
 
                             if(obj instanceof Performative)
@@ -475,6 +478,23 @@ class FrameParser2 implements TransportInput
         }
     }
 
+    int payloadStart(byte[] body)
+    {      
+        if (body.length > 15 && body[9] == 0x14)
+        {
+            int a = 0xFF & body[11];
+            int b = 0xFF & body[12];
+            int c = 0xFF & body[13];
+            int d = 0xFF & body[14];
+            int value = a << 24 | b << 16 | c << 8 | d;
+            return value + 11;
+        }
+        else
+        {
+            return body.length;
+        }
+    }
+    
     @Override
     public int capacity()
     {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/12ff4f5c/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter2.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter2.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter2.java
index 757302e..4340002 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter2.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/FrameWriter2.java
@@ -96,10 +96,9 @@ class FrameWriter2
     {
         byte[] old = _buffer;
         _buffer = new byte[_buffer.length * 2];
-        int pos = _position;
-        System.arraycopy(old, 0, _buffer, 0, pos);
+        System.arraycopy(old, 0, _buffer, 0, _position);
 
-        _encoder.init(_buffer, pos, _buffer.length * 2);
+        _encoder.init(_buffer, _position, _buffer.length * 2);
     }
 
     void writeHeader(byte[] header)
@@ -203,7 +202,7 @@ class FrameWriter2
             }
 
             payload.get(_buffer, _position, payloadSize);
-            _position = _position + payloadSize + 1;
+            _position = _position + payloadSize;
         }
         endFrame(channel);
         _framesOutput += 1;
@@ -237,17 +236,13 @@ class FrameWriter2
         int size = Math.min(_position - _read, dst.remaining());
 
         dst.put(_buffer, _read, size);
-        _read = _position - (_read + size);
+        _read = _read + size;
 
-        // If we have have copied everything we can go back to the beginning
-        // size > 0 ensures we go reset the buffer if we don't endup reading at
-        // all.
-        if (_read == 0 && size > 0)
+        if (_read == _position)
         {
             _position = 0;
+            _read = 0;
         }
-        // System.out.println("RAW: \"" + new Binary(dst.array(),
-        // dst.arrayOffset(), dst.position()) + "\"");
 
         return size;
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/12ff4f5c/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl2.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl2.java
b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl2.java
index 8ae4a4c..beaca12 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl2.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl2.java
@@ -1354,7 +1354,7 @@ public class TransportImpl2 extends EndpointImpl
         int channel = frame.getChannel();
         if (Transfer.CODE == performative.getCode())
         {
-            this.handleTransfer((Transfer) performative, frame.getPayload(), 0, frame.getPayload().length,
channel);
+            this.handleTransfer((Transfer) performative, frame.getPayload(), 0, frame.getPayload()
== null ? 0 : frame.getPayload().length, channel);
         }
         else if (Disposition.CODE == performative.getCode())
         {
@@ -1498,7 +1498,15 @@ public class TransportImpl2 extends EndpointImpl
         try {
             init();
             int beforePosition = _inputProcessor.position();
-            _inputProcessor.process();
+            try
+            {
+                _inputProcessor.process();
+            }
+            catch (Exception e)
+            {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
             _bytesInput += beforePosition - _inputProcessor.position();
         } catch (TransportException e) {
             _head_closed = true;


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


Mime
View raw message