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 2016/01/25 16:32:07 UTC
qpid-proton git commit: PROTON-1107: only create the attachments
Record on a Delivery if it actually gets used
Repository: qpid-proton
Updated Branches:
refs/heads/master 490cc0d5b -> 0845878ee
PROTON-1107: only create the attachments Record on a Delivery if it actually gets used
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/0845878e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/0845878e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/0845878e
Branch: refs/heads/master
Commit: 0845878ee03935f2097f89e147c88b9c68d3b3b2
Parents: 490cc0d
Author: Robert Gemmell <ro...@apache.org>
Authored: Mon Jan 25 15:24:12 2016 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Mon Jan 25 15:24:12 2016 +0000
----------------------------------------------------------------------
.../qpid/proton/engine/impl/DeliveryImpl.java | 7 ++++++-
.../proton/engine/impl/DeliveryImplTest.java | 21 ++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0845878e/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 491e888..20fe4fe 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
@@ -42,7 +42,7 @@ public class DeliveryImpl implements Delivery
private DeliveryImpl _transportWorkPrev;
boolean _transportWork;
- private Record _attachments = new RecordImpl();
+ private Record _attachments;
private Object _context;
private final byte[] _tag;
@@ -411,6 +411,11 @@ public class DeliveryImpl implements Delivery
public Record attachments()
{
+ if(_attachments == null)
+ {
+ _attachments = new RecordImpl();
+ }
+
return _attachments;
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0845878e/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/DeliveryImplTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/DeliveryImplTest.java b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/DeliveryImplTest.java
index 20daa80..a063265 100644
--- a/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/DeliveryImplTest.java
+++ b/proton-j/src/test/java/org/apache/qpid/proton/engine/impl/DeliveryImplTest.java
@@ -20,7 +20,10 @@
package org.apache.qpid.proton.engine.impl;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import org.apache.qpid.proton.engine.Record;
import org.junit.Test;
import org.mockito.Mockito;
@@ -53,4 +56,22 @@ public class DeliveryImplTest
delivery.setMessageFormat(newFormat);
assertEquals("Unexpected message format", newFormat, delivery.getMessageFormat());
}
+
+ @Test
+ public void testAttachmentsNonNull() throws Exception
+ {
+ DeliveryImpl delivery = new DeliveryImpl(null, Mockito.mock(LinkImpl.class), null);
+
+ assertNotNull("Expected attachments to be non-null", delivery.attachments());
+ }
+
+ @Test
+ public void testAttachmentsReturnsSameRecordOnSuccessiveCalls() throws Exception
+ {
+ DeliveryImpl delivery = new DeliveryImpl(null, Mockito.mock(LinkImpl.class), null);
+
+ Record attachments = delivery.attachments();
+ Record attachments2 = delivery.attachments();
+ assertSame("Expected to get the same attachments", attachments, attachments2);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org