qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [22/50] [abbrv] qpid-proton git commit: Bug fixes and a quick message impl.
Date Fri, 15 May 2015 13:23:58 GMT
Bug fixes and a quick message impl.


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

Branch: refs/heads/rajith-codec
Commit: f711aafa23a7083cc2d9e4c8ce99ea62fd8da8de
Parents: 0951e6a
Author: Rajith Attapattu <rajith@apache.org>
Authored: Tue May 12 10:56:13 2015 -0400
Committer: Rajith Attapattu <rajith@apache.org>
Committed: Tue May 12 10:56:13 2015 -0400

----------------------------------------------------------------------
 .../qpid/proton/message2/AmqpSequence.java      |  1 +
 .../apache/qpid/proton/message2/AmqpValue.java  |  5 ++-
 .../proton/message2/ApplicationProperties.java  |  1 +
 .../org/apache/qpid/proton/message2/Data.java   |  5 ++-
 .../proton/message2/DeliveryAnnotations.java    |  1 +
 .../org/apache/qpid/proton/message2/Footer.java |  1 +
 .../proton/message2/MessageAnnotations.java     |  1 +
 .../qpid/proton/message2/MessageImpl2.java      | 34 +++++++-------------
 .../apache/qpid/proton/message2/Properties.java | 31 +++++++++++++++---
 .../apache/qpid/proton/message2/Released.java   |  1 +
 10 files changed, 52 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f711aafa/proton-j/src/main/java/org/apache/qpid/proton/message2/AmqpSequence.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message2/AmqpSequence.java b/proton-j/src/main/java/org/apache/qpid/proton/message2/AmqpSequence.java
index 2c1b5c5..7e74aae 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/message2/AmqpSequence.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/message2/AmqpSequence.java
@@ -54,6 +54,7 @@ public final class AmqpSequence implements Section, Encodable
     {
         encoder.putDescriptor();
         encoder.putUlong(DESCRIPTOR_LONG);
+        encoder.putList();
         CodecHelper.encodeList(encoder, _value);
         encoder.end();
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f711aafa/proton-j/src/main/java/org/apache/qpid/proton/message2/AmqpValue.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message2/AmqpValue.java b/proton-j/src/main/java/org/apache/qpid/proton/message2/AmqpValue.java
index 00a59dc..43451d4 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/message2/AmqpValue.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/message2/AmqpValue.java
@@ -21,6 +21,8 @@
 
 package org.apache.qpid.proton.message2;
 
+import java.util.List;
+
 import org.apache.qpid.proton.codec2.CodecHelper;
 import org.apache.qpid.proton.codec2.DecodeException;
 import org.apache.qpid.proton.codec2.DescribedTypeFactory;
@@ -52,6 +54,7 @@ public final class AmqpValue implements Section, Encodable
     {
         encoder.putDescriptor();
         encoder.putUlong(DESCRIPTOR_LONG);
+        encoder.putList();
         CodecHelper.encodeObject(encoder, _value);
         encoder.end();
     }
@@ -60,7 +63,7 @@ public final class AmqpValue implements Section, Encodable
     {
         public Object create(Object in) throws DecodeException
         {
-            return new Data((byte[]) in);
+            return new AmqpValue(((List<Object>)in).get(0));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f711aafa/proton-j/src/main/java/org/apache/qpid/proton/message2/ApplicationProperties.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message2/ApplicationProperties.java
b/proton-j/src/main/java/org/apache/qpid/proton/message2/ApplicationProperties.java
index 80d9384..e4351af 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/message2/ApplicationProperties.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/message2/ApplicationProperties.java
@@ -54,6 +54,7 @@ public final class ApplicationProperties implements Encodable
     {
         encoder.putDescriptor();
         encoder.putUlong(DESCRIPTOR_LONG);
+        encoder.putList();
         CodecHelper.encodeMap(encoder, _value);
         encoder.end();
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f711aafa/proton-j/src/main/java/org/apache/qpid/proton/message2/Data.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message2/Data.java b/proton-j/src/main/java/org/apache/qpid/proton/message2/Data.java
index 82ecd52..9aa8d3a 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/message2/Data.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/message2/Data.java
@@ -21,6 +21,8 @@
 
 package org.apache.qpid.proton.message2;
 
+import java.util.List;
+
 import org.apache.qpid.proton.codec2.DecodeException;
 import org.apache.qpid.proton.codec2.DescribedTypeFactory;
 import org.apache.qpid.proton.codec2.Encodable;
@@ -51,6 +53,7 @@ public final class Data implements Section, Encodable
     {
         encoder.putDescriptor();
         encoder.putUlong(DESCRIPTOR_LONG);
+        encoder.putList();
         encoder.putBinary(_value, 0, _value.length);
         encoder.end();
     }
@@ -59,7 +62,7 @@ public final class Data implements Section, Encodable
     {
         public Object create(Object in) throws DecodeException
         {
-            return new Data((byte[]) in);
+            return new Data((byte[]) ((List)in).get(0));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f711aafa/proton-j/src/main/java/org/apache/qpid/proton/message2/DeliveryAnnotations.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message2/DeliveryAnnotations.java
b/proton-j/src/main/java/org/apache/qpid/proton/message2/DeliveryAnnotations.java
index c5f89f9..009a72b 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/message2/DeliveryAnnotations.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/message2/DeliveryAnnotations.java
@@ -54,6 +54,7 @@ public final class DeliveryAnnotations implements Encodable
     {
         encoder.putDescriptor();
         encoder.putUlong(DESCRIPTOR_LONG);
+        encoder.putList();
         CodecHelper.encodeMapWithKeyAsSymbol(encoder, _value);
         encoder.end();
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f711aafa/proton-j/src/main/java/org/apache/qpid/proton/message2/Footer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message2/Footer.java b/proton-j/src/main/java/org/apache/qpid/proton/message2/Footer.java
index 5a91572..89a31a1 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/message2/Footer.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/message2/Footer.java
@@ -54,6 +54,7 @@ public final class Footer implements Encodable
     {
         encoder.putDescriptor();
         encoder.putUlong(DESCRIPTOR_LONG);
+        encoder.putList();
         CodecHelper.encodeMap(encoder, _value);
         encoder.end();
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f711aafa/proton-j/src/main/java/org/apache/qpid/proton/message2/MessageAnnotations.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message2/MessageAnnotations.java
b/proton-j/src/main/java/org/apache/qpid/proton/message2/MessageAnnotations.java
index 9c668db..055ca27 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/message2/MessageAnnotations.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/message2/MessageAnnotations.java
@@ -54,6 +54,7 @@ public final class MessageAnnotations implements Encodable
     {
         encoder.putDescriptor();
         encoder.putUlong(DESCRIPTOR_LONG);
+        encoder.putList();
         CodecHelper.encodeMapWithKeyAsSymbol(encoder, _value);
         encoder.end();
     }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f711aafa/proton-j/src/main/java/org/apache/qpid/proton/message2/MessageImpl2.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message2/MessageImpl2.java b/proton-j/src/main/java/org/apache/qpid/proton/message2/MessageImpl2.java
index 634d0e3..26a7b0c 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/message2/MessageImpl2.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/message2/MessageImpl2.java
@@ -687,13 +687,6 @@ public class MessageImpl2 implements Message
         decoder.setByteBuffer(null); */
     }
 
-    @Override
-    public int encode(byte[] data, int offset, int length)
-    {
-        ByteBuffer buffer = ByteBuffer.wrap(data, offset, length);
-        return encode(new WritableBuffer.ByteBufferWrapper(buffer));
-    }
-
     //@Override
     public int encode2(byte[] data, int offset, int length)
     {
@@ -702,48 +695,45 @@ public class MessageImpl2 implements Message
         DroppingWritableBuffer second = new DroppingWritableBuffer();
         CompositeWritableBuffer composite = new CompositeWritableBuffer(first, second);
         int start = composite.position();
-        encode(composite);
+        //encode(composite);
         return composite.position() - start;
     }
 
     //@Override
-    public int encode(WritableBuffer buffer)
+    public int encode(byte[] data, int offset, int length)
     {
-        int length = buffer.remaining();
-        EncoderImpl encoder = null; //tlsCodec.get().encoder;
-        encoder.setByteBuffer(buffer);
+        ByteArrayEncoder encoder = tlsCodec.get().encoder;
+        encoder.init(data, 0, data.length);
 
         if(getHeader() != null)
         {
-            encoder.writeObject(getHeader());
+            getHeader().encode(encoder);
         }
         if(getDeliveryAnnotations() != null)
         {
-            encoder.writeObject(getDeliveryAnnotations());
+            getDeliveryAnnotations().encode(encoder);
         }
         if(getMessageAnnotations() != null)
         {
-            encoder.writeObject(getMessageAnnotations());
+            getMessageAnnotations().encode(encoder);;
         }
         if(getProperties() != null)
         {
-            encoder.writeObject(getProperties());
+            getProperties().encode(encoder);;
         }
         if(getApplicationProperties() != null)
         {
-            encoder.writeObject(getApplicationProperties());
+            getApplicationProperties().encode(encoder);;
         }
         if(getBody() != null)
         {
-            encoder.writeObject(getBody());
+            CodecHelper.encodeObject(encoder, getBody());
         }
         if(getFooter() != null)
         {
-            encoder.writeObject(getFooter());
+            getFooter().encode(encoder);;
         }
-        encoder.setByteBuffer((WritableBuffer)null);
-
-        return length - buffer.remaining();
+        return encoder.getPosition();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f711aafa/proton-j/src/main/java/org/apache/qpid/proton/message2/Properties.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message2/Properties.java b/proton-j/src/main/java/org/apache/qpid/proton/message2/Properties.java
index 9cd35d4..261a951 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/message2/Properties.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/message2/Properties.java
@@ -201,15 +201,36 @@ public final class Properties implements Encodable
         encoder.putUlong(DESCRIPTOR_LONG);
         encoder.putList();
         CodecHelper.encodeObject(encoder, _messageId);
-        encoder.putBinary(_userId, 0, _userId.length);
+        if (_userId == null)
+        {
+            encoder.putNull();
+        }
+        else
+        {
+            encoder.putBinary(_userId, 0, _userId.length);
+        }
         encoder.putString(_to);
         encoder.putString(_subject);
         encoder.putString(_replyTo);
         CodecHelper.encodeObject(encoder, _correlationId);
         encoder.putSymbol(_contentType);
         encoder.putSymbol(_contentEncoding);
-        encoder.putTimestamp(_absoluteExpiryTime.getTime());
-        encoder.putTimestamp(_creationTime.getTime());
+        if (_absoluteExpiryTime == null)
+        {
+            encoder.putNull();
+        }
+        else
+        {
+            encoder.putTimestamp(_absoluteExpiryTime.getTime());
+        }
+        if (_creationTime == null)
+        {
+            encoder.putNull();
+        }
+        else
+        {
+            encoder.putTimestamp(_creationTime.getTime());
+        }        
         encoder.putString(_groupId);
         encoder.putUint(_groupSequence);
         encoder.putString(_replyToGroupId);
@@ -234,9 +255,9 @@ public final class Properties implements Encodable
             case 2:
                 props.setGroupId((String) l.get(10));
             case 3:
-                props.setCreationTime(new Date((Long) l.get(9)));
+                props.setCreationTime(l.get(9) == null ? null : new Date((Long) l.get(9)));
             case 4:
-                props.setAbsoluteExpiryTime(new Date((Long) l.get(8)));
+                props.setAbsoluteExpiryTime(l.get(8) == null ? null : new Date((Long) l.get(8)));
             case 5:
                 props.setContentEncoding((String) l.get(7));
             case 6:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f711aafa/proton-j/src/main/java/org/apache/qpid/proton/message2/Released.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/message2/Released.java b/proton-j/src/main/java/org/apache/qpid/proton/message2/Released.java
index 4635e94..62a4c66 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/message2/Released.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/message2/Released.java
@@ -42,6 +42,7 @@ public final class Released implements DeliveryState, Outcome, Encodable
     {
         encoder.putDescriptor();
         encoder.putUlong(DESCRIPTOR_LONG);
+        encoder.putList();
         encoder.end();
     }
 


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


Mime
View raw message