qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lqu...@apache.org
Subject [1/2] qpid-broker-j git commit: QPID-7777: [Java Broker] In AMQP 1.0 take copies of MetaData Sections instead of exposing private fields
Date Fri, 12 May 2017 10:48:26 GMT
Repository: qpid-broker-j
Updated Branches:
  refs/heads/master c94d60e31 -> dc7dca5f8


QPID-7777: [Java Broker] In AMQP 1.0 take copies of MetaData Sections instead of exposing
private fields


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

Branch: refs/heads/master
Commit: f18fe94ff6d30b5c9955fb83855cec72d8096ceb
Parents: c94d60e
Author: Lorenz Quack <lquack@apache.org>
Authored: Fri May 12 10:52:34 2017 +0100
Committer: Lorenz Quack <lquack@apache.org>
Committed: Fri May 12 10:52:34 2017 +0100

----------------------------------------------------------------------
 .../qpid/server/protocol/v1_0/ConsumerTarget_1_0.java   |  8 +++++++-
 .../qpid/server/protocol/v1_0/MessageMetaData_1_0.java  | 12 ++++++------
 .../protocol/v1_0/type/messaging/AbstractSection.java   |  7 +++++++
 .../v1_0/type/messaging/AmqpSequenceSection.java        | 11 +++++++++++
 .../protocol/v1_0/type/messaging/AmqpValueSection.java  | 11 +++++++++++
 .../type/messaging/ApplicationPropertiesSection.java    | 11 +++++++++++
 .../protocol/v1_0/type/messaging/DataSection.java       | 11 +++++++++++
 .../v1_0/type/messaging/DeliveryAnnotationsSection.java | 11 +++++++++++
 .../protocol/v1_0/type/messaging/FooterSection.java     | 11 +++++++++++
 .../protocol/v1_0/type/messaging/HeaderSection.java     | 11 +++++++++++
 .../v1_0/type/messaging/MessageAnnotationsSection.java  | 11 +++++++++++
 .../protocol/v1_0/type/messaging/PropertiesSection.java | 11 +++++++++++
 .../v1_0/type/messaging/codec/EncodingRetaining.java    |  1 +
 13 files changed, 120 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f18fe94f/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0.java
b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0.java
index 41a3fbc..a016a75 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/ConsumerTarget_1_0.java
@@ -142,11 +142,11 @@ class ConsumerTarget_1_0 extends AbstractConsumerTarget<ConsumerTarget_1_0>
                     header.setDurable(oldHeader.getDurable());
                     header.setPriority(oldHeader.getPriority());
                     header.setTtl(oldHeader.getTtl());
+                    headerSection.dispose();
                 }
                 header.setDeliveryCount(UnsignedInteger.valueOf(entry.getDeliveryCount()));
 
                 QpidByteBuffer headerPayload = _sectionEncoder.encodeObject(header);
-
                 headerSection = new HeaderSection(_typeRegistry);
                 headerSection.setEncodedForm(Collections.singletonList(headerPayload));
                 headerPayload.dispose();
@@ -155,26 +155,31 @@ class ConsumerTarget_1_0 extends AbstractConsumerTarget<ConsumerTarget_1_0>
             if(headerSection != null)
             {
                 payload.addAll(headerSection.getEncodedForm());
+                headerSection.dispose();
             }
             EncodingRetainingSection<?> section;
             if((section = message.getDeliveryAnnotationsSection()) != null)
             {
                 payload.addAll(section.getEncodedForm());
+                section.dispose();
             }
 
             if((section = message.getMessageAnnotationsSection()) != null)
             {
                 payload.addAll(section.getEncodedForm());
+                section.dispose();
             }
 
             if((section = message.getPropertiesSection()) != null)
             {
                 payload.addAll(section.getEncodedForm());
+                section.dispose();
             }
 
             if((section = message.getApplicationPropertiesSection()) != null)
             {
                 payload.addAll(section.getEncodedForm());
+                section.dispose();
             }
 
             payload.addAll(bodyContent);
@@ -182,6 +187,7 @@ class ConsumerTarget_1_0 extends AbstractConsumerTarget<ConsumerTarget_1_0>
             if((section = message.getFooterSection()) != null)
             {
                 payload.addAll(section.getEncodedForm());
+                section.dispose();
             }
 
 

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f18fe94f/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java
b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java
index 2055b0d..eed785d 100755
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/MessageMetaData_1_0.java
@@ -182,7 +182,7 @@ public class MessageMetaData_1_0 implements StorableMessageMetaData
 
     public PropertiesSection getPropertiesSection()
     {
-        return _propertiesSection;
+        return _propertiesSection == null ? null : _propertiesSection.copy();
     }
 
 
@@ -342,27 +342,27 @@ public class MessageMetaData_1_0 implements StorableMessageMetaData
 
     public HeaderSection getHeaderSection()
     {
-        return _headerSection;
+        return _headerSection == null ? null : _headerSection.copy();
     }
 
     public DeliveryAnnotationsSection getDeliveryAnnotationsSection()
     {
-        return _deliveryAnnotationsSection;
+        return _deliveryAnnotationsSection == null ? null : _deliveryAnnotationsSection.copy();
     }
 
     public MessageAnnotationsSection getMessageAnnotationsSection()
     {
-        return _messageAnnotationsSection;
+        return _messageAnnotationsSection == null ? null : _messageAnnotationsSection.copy();
     }
 
     public ApplicationPropertiesSection getApplicationPropertiesSection()
     {
-        return _applicationPropertiesSection;
+        return _applicationPropertiesSection == null ? null : _applicationPropertiesSection.copy();
     }
 
     public FooterSection getFooterSection()
     {
-        return _footerSection;
+        return _footerSection == null ? null : _footerSection.copy();
     }
 
     public int getVersion()

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f18fe94f/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AbstractSection.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AbstractSection.java
b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AbstractSection.java
index 81a0853..8eb46e0 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AbstractSection.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AbstractSection.java
@@ -51,6 +51,13 @@ public abstract class AbstractSection<T, S extends NonEncodingRetainingSection<T
         _encodedForm = Collections.singletonList(encoder.encodeObject(section));
     }
 
+    protected AbstractSection(final AbstractSection<T, S> otherAbstractSection)
+    {
+        _value = otherAbstractSection.getValue();
+        _typeRegistry = otherAbstractSection._typeRegistry;
+        _encodedForm = otherAbstractSection.getEncodedForm();
+    }
+
     @Override
     public synchronized T getValue()
     {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f18fe94f/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpSequenceSection.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpSequenceSection.java
b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpSequenceSection.java
index 7de8d36..79df8e8 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpSequenceSection.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpSequenceSection.java
@@ -40,6 +40,17 @@ public class AmqpSequenceSection extends AbstractSection<List, AmqpSequence>
         super(sequence, sectionEncoder);
     }
 
+    AmqpSequenceSection(final AmqpSequenceSection amqpSequenceSection)
+    {
+        super(amqpSequenceSection);
+    }
+
+    @Override
+    public AmqpSequenceSection copy()
+    {
+        return new AmqpSequenceSection(this);
+    }
+
     @Override
     protected AbstractDescribedTypeConstructor<AmqpSequence> createNonEncodingRetainingSectionConstructor()
     {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f18fe94f/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpValueSection.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpValueSection.java
b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpValueSection.java
index 423052c..40ea3e1 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpValueSection.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/AmqpValueSection.java
@@ -38,6 +38,17 @@ public class AmqpValueSection extends AbstractSection<Object, AmqpValue>
         super(amqpValue, sectionEncoder);
     }
 
+    AmqpValueSection(final AmqpValueSection amqpValueSection)
+    {
+        super(amqpValueSection);
+    }
+
+    @Override
+    public AmqpValueSection copy()
+    {
+        return new AmqpValueSection(this);
+    }
+
     @Override
     protected AbstractDescribedTypeConstructor<AmqpValue> createNonEncodingRetainingSectionConstructor()
     {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f18fe94f/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/ApplicationPropertiesSection.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/ApplicationPropertiesSection.java
b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/ApplicationPropertiesSection.java
index cd75019..2c9ca92 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/ApplicationPropertiesSection.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/ApplicationPropertiesSection.java
@@ -41,6 +41,17 @@ public class ApplicationPropertiesSection extends AbstractSection<Map<String,Obj
         super(section, encoder);
     }
 
+    ApplicationPropertiesSection(final ApplicationPropertiesSection applicationPropertiesSection)
+    {
+        super(applicationPropertiesSection);
+    }
+
+    @Override
+    public ApplicationPropertiesSection copy()
+    {
+        return new ApplicationPropertiesSection(this);
+    }
+
     @Override
     protected AbstractDescribedTypeConstructor<ApplicationProperties> createNonEncodingRetainingSectionConstructor()
     {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f18fe94f/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DataSection.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DataSection.java
b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DataSection.java
index 754f306..d10f90a 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DataSection.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DataSection.java
@@ -39,6 +39,17 @@ public class DataSection extends AbstractSection<Binary, Data>
         super(data, sectionEncoder);
     }
 
+    DataSection(final DataSection dataSection)
+    {
+        super(dataSection);
+    }
+
+    @Override
+    public DataSection copy()
+    {
+        return new DataSection(this);
+    }
+
     @Override
     protected AbstractDescribedTypeConstructor<Data> createNonEncodingRetainingSectionConstructor()
     {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f18fe94f/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DeliveryAnnotationsSection.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DeliveryAnnotationsSection.java
b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DeliveryAnnotationsSection.java
index 6c1fc40..3c4b550 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DeliveryAnnotationsSection.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/DeliveryAnnotationsSection.java
@@ -41,6 +41,17 @@ public class DeliveryAnnotationsSection extends AbstractSection<Map<Symbol,Objec
         super(deliveryAnnotations, sectionEncoder);
     }
 
+    DeliveryAnnotationsSection(final DeliveryAnnotationsSection deliveryAnnotationsSection)
+    {
+        super(deliveryAnnotationsSection);
+    }
+
+    @Override
+    public DeliveryAnnotationsSection copy()
+    {
+        return new DeliveryAnnotationsSection(this);
+    }
+
     @Override
     protected AbstractDescribedTypeConstructor<DeliveryAnnotations> createNonEncodingRetainingSectionConstructor()
     {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f18fe94f/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/FooterSection.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/FooterSection.java
b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/FooterSection.java
index 4d343f2..b41de4b 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/FooterSection.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/FooterSection.java
@@ -41,6 +41,17 @@ public class FooterSection extends AbstractSection<Map<Symbol,Object>,
Footer>
         super(footer, sectionEncoder);
     }
 
+    FooterSection(final FooterSection footerSection)
+    {
+        super(footerSection);
+    }
+
+    @Override
+    public FooterSection copy()
+    {
+        return new FooterSection(this);
+    }
+
     @Override
     protected AbstractDescribedTypeConstructor<Footer> createNonEncodingRetainingSectionConstructor()
     {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f18fe94f/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/HeaderSection.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/HeaderSection.java
b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/HeaderSection.java
index 801ea4d..9ffab93 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/HeaderSection.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/HeaderSection.java
@@ -38,6 +38,17 @@ public class HeaderSection extends AbstractSection<Header, Header>
         super(header, sectionEncoder);
     }
 
+    HeaderSection(final HeaderSection headerSection)
+    {
+        super(headerSection);
+    }
+
+    @Override
+    public HeaderSection copy()
+    {
+        return new HeaderSection(this);
+    }
+
     @Override
     protected AbstractDescribedTypeConstructor<Header> createNonEncodingRetainingSectionConstructor()
     {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f18fe94f/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/MessageAnnotationsSection.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/MessageAnnotationsSection.java
b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/MessageAnnotationsSection.java
index 90952ce..6719787 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/MessageAnnotationsSection.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/MessageAnnotationsSection.java
@@ -41,6 +41,17 @@ public class MessageAnnotationsSection extends AbstractSection<Map<Symbol,Object
         super(messageAnnotations, sectionEncoder);
     }
 
+    MessageAnnotationsSection(final MessageAnnotationsSection messageAnnotationsSection)
+    {
+        super(messageAnnotationsSection);
+    }
+
+    @Override
+    public MessageAnnotationsSection copy()
+    {
+        return new MessageAnnotationsSection(this);
+    }
+
     @Override
     protected AbstractDescribedTypeConstructor<MessageAnnotations> createNonEncodingRetainingSectionConstructor()
     {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f18fe94f/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/PropertiesSection.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/PropertiesSection.java
b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/PropertiesSection.java
index a6b482f..bf58f1b 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/PropertiesSection.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/PropertiesSection.java
@@ -39,6 +39,17 @@ public class PropertiesSection extends AbstractSection<Properties, Properties>
        super(properties, sectionEncoder);
     }
 
+    PropertiesSection(final PropertiesSection propertiesSection)
+    {
+        super(propertiesSection);
+    }
+
+    @Override
+    public PropertiesSection copy()
+    {
+        return new PropertiesSection(this);
+    }
+
     @Override
     protected AbstractDescribedTypeConstructor<Properties> createNonEncodingRetainingSectionConstructor()
     {

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/f18fe94f/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/EncodingRetaining.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/EncodingRetaining.java
b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/EncodingRetaining.java
index 2b7c918..f20b0ba 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/EncodingRetaining.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/type/messaging/codec/EncodingRetaining.java
@@ -32,6 +32,7 @@ public interface EncodingRetaining
     void reallocate();
     long getEncodedSize();
     void writeTo(QpidByteBuffer dest);
+    EncodingRetaining copy();
 
 
 }


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


Mime
View raw message