You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by lq...@apache.org on 2017/05/23 09:03:38 UTC

[1/4] qpid-broker-j git commit: QPID-7796: [Java Broker] Guard against NPE in 0-10 when storing messages without header

Repository: qpid-broker-j
Updated Branches:
  refs/heads/6.1.x 400e7ec70 -> a08d66310


QPID-7796: [Java Broker] Guard against NPE in 0-10 when storing messages without header


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/a08d6631
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/a08d6631
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/a08d6631

Branch: refs/heads/6.1.x
Commit: a08d663102f20e7d3e19718e811466af75b9c5cf
Parents: 7cf5eb3
Author: Lorenz Quack <lq...@apache.org>
Authored: Tue May 23 09:52:24 2017 +0100
Committer: Lorenz Quack <lq...@apache.org>
Committed: Tue May 23 09:55:10 2017 +0100

----------------------------------------------------------------------
 .../protocol/v0_10/MessageMetaData_0_10.java    | 49 +++++++++++---------
 1 file changed, 27 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/a08d6631/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java b/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java
index b308435..6cf17f4 100755
--- a/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java
+++ b/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java
@@ -103,37 +103,42 @@ public class MessageMetaData_0_10 implements StorableMessageMetaData
         encoder.writeInt64(_arrivalTime);
         encoder.writeInt32(_bodySize);
         int headersLength = 0;
-        if(_header.getDeliveryProperties() != null)
+        if (_header != null)
         {
-            headersLength++;
-        }
-        if(_header.getMessageProperties() != null)
-        {
-            headersLength++;
-        }
-        if(_header.getNonStandardProperties() != null)
-        {
-            headersLength += _header.getNonStandardProperties().size();
+            if (_header.getDeliveryProperties() != null)
+            {
+                headersLength++;
+            }
+            if (_header.getMessageProperties() != null)
+            {
+                headersLength++;
+            }
+            if (_header.getNonStandardProperties() != null)
+            {
+                headersLength += _header.getNonStandardProperties().size();
+            }
         }
 
         encoder.writeInt32(headersLength);
 
-        if(_header.getDeliveryProperties() != null)
+        if (_header != null)
         {
-            encoder.writeStruct32(_header.getDeliveryProperties());
-        }
-        if(_header.getMessageProperties() != null)
-        {
-            encoder.writeStruct32(_header.getMessageProperties());
-        }
-        if(_header.getNonStandardProperties() != null)
-        {
-
-            for(Struct header : _header.getNonStandardProperties())
+            if (_header.getDeliveryProperties() != null)
+            {
+                encoder.writeStruct32(_header.getDeliveryProperties());
+            }
+            if (_header.getMessageProperties() != null)
             {
-                encoder.writeStruct32(header);
+                encoder.writeStruct32(_header.getMessageProperties());
             }
+            if (_header.getNonStandardProperties() != null)
+            {
 
+                for (Struct header : _header.getNonStandardProperties())
+                {
+                    encoder.writeStruct32(header);
+                }
+            }
         }
         QpidByteBuffer buf = encoder.getBuffer();
         encoder.close();


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


[2/4] qpid-broker-j git commit: Revert "QPID-7723: Optimize evaluation of metadata storable size for AMQP 0-10"

Posted by lq...@apache.org.
Revert "QPID-7723: Optimize evaluation of metadata storable size for AMQP 0-10"

This reverts commit 7772251c1534c5c6ac1d168ee16f019206d60355.


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/1172f862
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/1172f862
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/1172f862

Branch: refs/heads/6.1.x
Commit: 1172f8629f5b781044ba9e78a4a5ec0f7b2becd7
Parents: 18bd89e
Author: Lorenz Quack <lq...@apache.org>
Authored: Tue May 23 09:40:04 2017 +0100
Committer: Lorenz Quack <lq...@apache.org>
Committed: Tue May 23 09:55:10 2017 +0100

----------------------------------------------------------------------
 .../protocol/v0_10/MessageMetaData_0_10.java    |  28 +-
 .../org/apache/qpid/transport/Acquired.java     |   6 +-
 .../qpid/transport/DeliveryProperties.java      |  48 +--
 .../qpid/transport/ExchangeBoundResult.java     |   5 -
 .../qpid/transport/ExchangeQueryResult.java     |   5 -
 .../qpid/transport/FragmentProperties.java      |   6 -
 .../apache/qpid/transport/GetTimeoutResult.java |   6 -
 .../qpid/transport/MessageProperties.java       |  47 ---
 .../qpid/transport/MessageResumeResult.java     |   5 -
 .../java/org/apache/qpid/transport/Method.java  |   6 -
 .../apache/qpid/transport/QueueQueryResult.java |   6 -
 .../apache/qpid/transport/RecoverResult.java    |   6 -
 .../java/org/apache/qpid/transport/ReplyTo.java |  19 -
 .../qpid/transport/SessionCommandFragment.java  |   5 -
 .../apache/qpid/transport/SessionHeader.java    |   6 -
 .../java/org/apache/qpid/transport/Struct.java  |   2 -
 .../org/apache/qpid/transport/XaResult.java     |   7 -
 .../java/org/apache/qpid/transport/Xid.java     |   5 -
 .../qpid/transport/codec/AbstractEncoder.java   |  78 ++++-
 .../apache/qpid/transport/codec/Encoder.java    |   1 +
 .../qpid/transport/codec/EncoderUtils.java      | 343 -------------------
 .../qpid/transport/codec/BBEncoderTest.java     |  72 +---
 22 files changed, 90 insertions(+), 622 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java b/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java
index 403c554..b308435 100755
--- a/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java
+++ b/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java
@@ -27,7 +27,6 @@ import java.util.List;
 import org.apache.qpid.bytebuffer.QpidByteBuffer;
 import org.apache.qpid.server.message.AMQMessageHeader;
 import org.apache.qpid.server.plugin.MessageMetaDataType;
-import org.apache.qpid.transport.codec.EncoderUtils;
 import org.apache.qpid.server.store.StorableMessageMetaData;
 import org.apache.qpid.transport.DeliveryProperties;
 import org.apache.qpid.transport.Header;
@@ -84,32 +83,17 @@ public class MessageMetaData_0_10 implements StorableMessageMetaData
         return TYPE;
     }
 
-
-    public int getStorableSize()
+    public synchronized int getStorableSize()
     {
-        int len = 0;
-
-        len += 8; // arrival time
-        len += 4; // body size
-        len += 4; // headers length
+        QpidByteBuffer buf = _encoded;
 
-        if(_header.getDeliveryProperties() != null)
-        {
-            len += EncoderUtils.getStruct32Length(_header.getDeliveryProperties());
-        }
-        if(_header.getMessageProperties() != null)
+        if(buf == null)
         {
-            len += EncoderUtils.getStruct32Length(_header.getMessageProperties());
+            buf = encodeAsBuffer();
+            _encoded = buf;
         }
-        if(_header.getNonStandardProperties() != null)
-        {
-            for(Struct header : _header.getNonStandardProperties())
-            {
-                len += EncoderUtils.getStruct32Length(header);
-            }
 
-        }
-        return len;
+        return buf.limit();
     }
 
     private QpidByteBuffer encodeAsBuffer()

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/Acquired.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/Acquired.java b/common/src/main/java/org/apache/qpid/transport/Acquired.java
index 20c366c..28e6e4c 100644
--- a/common/src/main/java/org/apache/qpid/transport/Acquired.java
+++ b/common/src/main/java/org/apache/qpid/transport/Acquired.java
@@ -137,9 +137,5 @@ public final class Acquired extends Struct {
         return result;
     }
 
-    @Override
-    public int getEncodedLength()
-    {
-        throw new UnsupportedOperationException();
-    }
+
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/DeliveryProperties.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/DeliveryProperties.java b/common/src/main/java/org/apache/qpid/transport/DeliveryProperties.java
index ee9c13a..94e8d06 100644
--- a/common/src/main/java/org/apache/qpid/transport/DeliveryProperties.java
+++ b/common/src/main/java/org/apache/qpid/transport/DeliveryProperties.java
@@ -520,51 +520,6 @@ public final class DeliveryProperties extends Struct {
 
     }
 
-    public int getEncodedLength()
-    {
-        int len = 0;
-
-        len += 2; // packing_flags
-
-        if ((packing_flags & 2048) != 0)
-        {
-            len += 1; // priority
-        }
-        if ((packing_flags & 4096) != 0)
-        {
-            len += 1; // deliveryMode
-        }
-        if ((packing_flags & 8192) != 0)
-        {
-            len += 8; // ttl
-        }
-        if ((packing_flags & 16384) != 0)
-        {
-            len += 8; // timestamp
-        }
-        if ((packing_flags & 32768) != 0)
-        {
-            len += 8; // expiration
-        }
-        if ((packing_flags & 1) != 0)
-        {
-            len += EncoderUtils.getStr8Length(this.exchange);
-        }
-        if ((packing_flags & 2) != 0)
-        {
-            len += EncoderUtils.getStr8Length(this.routingKey);
-        }
-        if ((packing_flags & 4) != 0)
-        {
-            len += EncoderUtils.getStr16Length(this.resumeId);
-        }
-        if ((packing_flags & 8) != 0)
-        {
-            len += 8; // resumeTtl
-        }
-        return len;
-    }
-
     public void read(Decoder dec)
     {
         packing_flags = (short) dec.readUint16();
@@ -607,7 +562,6 @@ public final class DeliveryProperties extends Struct {
 
     }
 
-
     public Map<String,Object> getFields()
     {
         Map<String,Object> result = new LinkedHashMap<String,Object>();
@@ -664,4 +618,6 @@ public final class DeliveryProperties extends Struct {
 
         return result;
     }
+
+
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/ExchangeBoundResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/ExchangeBoundResult.java b/common/src/main/java/org/apache/qpid/transport/ExchangeBoundResult.java
index 9348a64..04d944e 100644
--- a/common/src/main/java/org/apache/qpid/transport/ExchangeBoundResult.java
+++ b/common/src/main/java/org/apache/qpid/transport/ExchangeBoundResult.java
@@ -297,10 +297,5 @@ public final class ExchangeBoundResult extends Struct {
         return result;
     }
 
-    @Override
-    public int getEncodedLength()
-    {
-        throw new UnsupportedOperationException();
-    }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/ExchangeQueryResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/ExchangeQueryResult.java b/common/src/main/java/org/apache/qpid/transport/ExchangeQueryResult.java
index 1a4c90c..9f83a4a 100644
--- a/common/src/main/java/org/apache/qpid/transport/ExchangeQueryResult.java
+++ b/common/src/main/java/org/apache/qpid/transport/ExchangeQueryResult.java
@@ -264,10 +264,5 @@ public final class ExchangeQueryResult extends Struct {
         return result;
     }
 
-    @Override
-    public int getEncodedLength()
-    {
-        throw new UnsupportedOperationException();
-    }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/FragmentProperties.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/FragmentProperties.java b/common/src/main/java/org/apache/qpid/transport/FragmentProperties.java
index d9fffa1..0b97743 100644
--- a/common/src/main/java/org/apache/qpid/transport/FragmentProperties.java
+++ b/common/src/main/java/org/apache/qpid/transport/FragmentProperties.java
@@ -220,11 +220,5 @@ public final class FragmentProperties extends Struct {
         return result;
     }
 
-    @Override
-    public int getEncodedLength()
-    {
-        throw new UnsupportedOperationException();
-    }
-
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/GetTimeoutResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/GetTimeoutResult.java b/common/src/main/java/org/apache/qpid/transport/GetTimeoutResult.java
index dce8b4d..ebff105 100644
--- a/common/src/main/java/org/apache/qpid/transport/GetTimeoutResult.java
+++ b/common/src/main/java/org/apache/qpid/transport/GetTimeoutResult.java
@@ -135,11 +135,5 @@ public final class GetTimeoutResult extends Struct {
         return result;
     }
 
-    @Override
-    public int getEncodedLength()
-    {
-        throw new UnsupportedOperationException();
-    }
-
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/MessageProperties.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/MessageProperties.java b/common/src/main/java/org/apache/qpid/transport/MessageProperties.java
index 825d049..1ddbae8 100644
--- a/common/src/main/java/org/apache/qpid/transport/MessageProperties.java
+++ b/common/src/main/java/org/apache/qpid/transport/MessageProperties.java
@@ -392,52 +392,6 @@ public final class MessageProperties extends Struct {
 
     }
 
-    @Override
-    public int getEncodedLength()
-    {
-        int len = 0;
-
-        len += 2; // packing_flags
-
-        if ((packing_flags & 256) != 0)
-        {
-            len += 8; // contentLength
-        }
-        if ((packing_flags & 512) != 0)
-        {
-            len += 16; // messageId
-        }
-        if ((packing_flags & 1024) != 0)
-        {
-            len += EncoderUtils.getVbin16Length(this.correlationId);
-        }
-        if ((packing_flags & 2048) != 0)
-        {
-            len += EncoderUtils.getStructLength(ReplyTo.TYPE, this.replyTo);
-        }
-        if ((packing_flags & 4096) != 0)
-        {
-            len += EncoderUtils.getStr8Length(this.contentType);
-        }
-        if ((packing_flags & 8192) != 0)
-        {
-            len += EncoderUtils.getStr8Length(this.contentEncoding);
-        }
-        if ((packing_flags & 16384) != 0)
-        {
-            len += EncoderUtils.getVbin16Length(this.userId);
-        }
-        if ((packing_flags & 32768) != 0)
-        {
-            len += EncoderUtils.getVbin16Length(this.appId);
-        }
-        if ((packing_flags & 1) != 0)
-        {
-            len += EncoderUtils.getMapLength(this.applicationHeaders);
-        }
-        return len;
-    }
-
     public void read(Decoder dec)
     {
         packing_flags = (short) dec.readUint16();
@@ -526,5 +480,4 @@ public final class MessageProperties extends Struct {
     }
 
 
-
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/MessageResumeResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/MessageResumeResult.java b/common/src/main/java/org/apache/qpid/transport/MessageResumeResult.java
index 93e8d26..1524b09 100644
--- a/common/src/main/java/org/apache/qpid/transport/MessageResumeResult.java
+++ b/common/src/main/java/org/apache/qpid/transport/MessageResumeResult.java
@@ -135,10 +135,5 @@ public final class MessageResumeResult extends Struct {
         return result;
     }
 
-    @Override
-    public int getEncodedLength()
-    {
-        throw new UnsupportedOperationException();
-    }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/Method.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/Method.java b/common/src/main/java/org/apache/qpid/transport/Method.java
index b42c22f..d23ce72 100644
--- a/common/src/main/java/org/apache/qpid/transport/Method.java
+++ b/common/src/main/java/org/apache/qpid/transport/Method.java
@@ -178,12 +178,6 @@ public abstract class Method extends Struct implements ProtocolEvent
         return completionListener != null;
     }
 
-    @Override
-    public final int getEncodedLength()
-    {
-        throw new UnsupportedOperationException();
-    }
-
     public String toString()
     {
         StringBuilder str = new StringBuilder();

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/QueueQueryResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/QueueQueryResult.java b/common/src/main/java/org/apache/qpid/transport/QueueQueryResult.java
index ee8042b..ca0c027 100644
--- a/common/src/main/java/org/apache/qpid/transport/QueueQueryResult.java
+++ b/common/src/main/java/org/apache/qpid/transport/QueueQueryResult.java
@@ -425,11 +425,5 @@ public final class QueueQueryResult extends Struct {
         return result;
     }
 
-    @Override
-    public int getEncodedLength()
-    {
-        throw new UnsupportedOperationException();
-    }
-
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/RecoverResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/RecoverResult.java b/common/src/main/java/org/apache/qpid/transport/RecoverResult.java
index 6dcd4cf..7a78f37 100644
--- a/common/src/main/java/org/apache/qpid/transport/RecoverResult.java
+++ b/common/src/main/java/org/apache/qpid/transport/RecoverResult.java
@@ -137,11 +137,5 @@ public final class RecoverResult extends Struct {
         return result;
     }
 
-    @Override
-    public int getEncodedLength()
-    {
-        throw new UnsupportedOperationException();
-    }
-
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/ReplyTo.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/ReplyTo.java b/common/src/main/java/org/apache/qpid/transport/ReplyTo.java
index 3800fd1..38340db 100644
--- a/common/src/main/java/org/apache/qpid/transport/ReplyTo.java
+++ b/common/src/main/java/org/apache/qpid/transport/ReplyTo.java
@@ -148,25 +148,6 @@ public final class ReplyTo extends Struct {
 
     }
 
-    @Override
-    public int getEncodedLength()
-    {
-        int len = 0;
-
-        len += 2; // packing_flags
-
-        if ((packing_flags & 256) != 0)
-        {
-            len += EncoderUtils.getStr8Length(this.exchange);
-        }
-        if ((packing_flags & 512) != 0)
-        {
-            len += EncoderUtils.getStr8Length(this.routingKey);
-        }
-        return len;
-    }
-
-
     public void read(Decoder dec)
     {
         packing_flags = (short) dec.readUint16();

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/SessionCommandFragment.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/SessionCommandFragment.java b/common/src/main/java/org/apache/qpid/transport/SessionCommandFragment.java
index 4647606..6ae2d45 100644
--- a/common/src/main/java/org/apache/qpid/transport/SessionCommandFragment.java
+++ b/common/src/main/java/org/apache/qpid/transport/SessionCommandFragment.java
@@ -134,10 +134,5 @@ public final class SessionCommandFragment extends Struct {
         return result;
     }
 
-    @Override
-    public int getEncodedLength()
-    {
-        throw new UnsupportedOperationException();
-    }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/SessionHeader.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/SessionHeader.java b/common/src/main/java/org/apache/qpid/transport/SessionHeader.java
index e5915d1..9287d59 100644
--- a/common/src/main/java/org/apache/qpid/transport/SessionHeader.java
+++ b/common/src/main/java/org/apache/qpid/transport/SessionHeader.java
@@ -141,11 +141,5 @@ public final class SessionHeader extends Struct {
         return result;
     }
 
-    @Override
-    public int getEncodedLength()
-    {
-        throw new UnsupportedOperationException();
-    }
-
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/Struct.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/Struct.java b/common/src/main/java/org/apache/qpid/transport/Struct.java
index bf48c77..045939e 100644
--- a/common/src/main/java/org/apache/qpid/transport/Struct.java
+++ b/common/src/main/java/org/apache/qpid/transport/Struct.java
@@ -114,8 +114,6 @@ public abstract class Struct implements Encodable
 
     public abstract Map<String,Object> getFields();
 
-    public abstract int getEncodedLength();
-
     public String toString()
     {
         StringBuilder str = new StringBuilder();

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/XaResult.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/XaResult.java b/common/src/main/java/org/apache/qpid/transport/XaResult.java
index 596390d..c9d502f 100644
--- a/common/src/main/java/org/apache/qpid/transport/XaResult.java
+++ b/common/src/main/java/org/apache/qpid/transport/XaResult.java
@@ -137,12 +137,5 @@ public final class XaResult extends Struct {
         return result;
     }
 
-    @Override
-    public int getEncodedLength()
-    {
-        throw new UnsupportedOperationException();
-    }
-
-
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/Xid.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/Xid.java b/common/src/main/java/org/apache/qpid/transport/Xid.java
index 57d4418..4e14207 100644
--- a/common/src/main/java/org/apache/qpid/transport/Xid.java
+++ b/common/src/main/java/org/apache/qpid/transport/Xid.java
@@ -219,10 +219,5 @@ public final class Xid extends Struct {
         return result;
     }
 
-    @Override
-    public int getEncodedLength()
-    {
-        throw new UnsupportedOperationException();
-    }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/codec/AbstractEncoder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/codec/AbstractEncoder.java b/common/src/main/java/org/apache/qpid/transport/codec/AbstractEncoder.java
index a3947a0..070621d 100644
--- a/common/src/main/java/org/apache/qpid/transport/codec/AbstractEncoder.java
+++ b/common/src/main/java/org/apache/qpid/transport/codec/AbstractEncoder.java
@@ -24,6 +24,7 @@ import static org.apache.qpid.transport.util.Functions.lsb;
 
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -33,6 +34,7 @@ import org.apache.qpid.transport.Range;
 import org.apache.qpid.transport.RangeSet;
 import org.apache.qpid.transport.Struct;
 import org.apache.qpid.transport.Type;
+import org.apache.qpid.transport.Xid;
 
 
 /**
@@ -44,6 +46,24 @@ import org.apache.qpid.transport.Type;
 public abstract class AbstractEncoder implements Encoder
 {
 
+    private static Map<Class<?>,Type> ENCODINGS = new HashMap<Class<?>,Type>();
+    static
+    {
+        ENCODINGS.put(Boolean.class, Type.BOOLEAN);
+        ENCODINGS.put(String.class, Type.STR16);
+        ENCODINGS.put(Long.class, Type.INT64);
+        ENCODINGS.put(Integer.class, Type.INT32);
+        ENCODINGS.put(Short.class, Type.INT16);
+        ENCODINGS.put(Byte.class, Type.INT8);
+        ENCODINGS.put(Map.class, Type.MAP);
+        ENCODINGS.put(List.class, Type.LIST);
+        ENCODINGS.put(Float.class, Type.FLOAT);
+        ENCODINGS.put(Double.class, Type.DOUBLE);
+        ENCODINGS.put(Character.class, Type.CHAR);
+        ENCODINGS.put(byte[].class, Type.VBIN32);
+        ENCODINGS.put(UUID.class, Type.UUID);
+        ENCODINGS.put(Xid.class, Type.STRUCT32);
+    }
 
     private final Map<String,byte[]> str8cache = new LinkedHashMap<String,byte[]>()
     {
@@ -270,6 +290,58 @@ public abstract class AbstractEncoder implements Encoder
         }
     }
 
+    private Type encoding(Object value)
+    {
+        if (value == null)
+        {
+            return Type.VOID;
+        }
+
+        Class klass = value.getClass();
+        Type type = resolve(klass);
+
+        if (type == null)
+        {
+            throw new IllegalArgumentException
+                ("unable to resolve type: " + klass + ", " + value);
+        }
+        else
+        {
+            return type;
+        }
+    }
+
+    static final Type resolve(Class klass)
+    {
+        Type type = ENCODINGS.get(klass);
+        if (type != null)
+        {
+            return type;
+        }
+
+        Class sup = klass.getSuperclass();
+        if (sup != null)
+        {
+            type = resolve(klass.getSuperclass());
+
+            if (type != null)
+            {
+                return type;
+            }
+        }
+
+        for (Class iface : klass.getInterfaces())
+        {
+            type = resolve(iface);
+            if (type != null)
+            {
+                return type;
+            }
+        }
+
+        return null;
+    }
+
     public void writeMap(Map<String,Object> map)
     {
         int pos = beginSize32();
@@ -287,7 +359,7 @@ public abstract class AbstractEncoder implements Encoder
         {
             String key = entry.getKey();
             Object value = entry.getValue();
-            Type type = EncoderUtils.getEncodingType(value);
+            Type type = encoding(value);
             writeStr8(key);
             put(type.getCode());
             write(type, value);
@@ -309,7 +381,7 @@ public abstract class AbstractEncoder implements Encoder
     {
         for (Object value : list)
         {
-            Type type = EncoderUtils.getEncodingType(value);
+            Type type = encoding(value);
             put(type.getCode());
             write(type, value);
         }
@@ -335,7 +407,7 @@ public abstract class AbstractEncoder implements Encoder
         }
         else
         {
-            type = EncoderUtils.getEncodingType(array.get(0));
+            type = encoding(array.get(0));
         }
 
         put(type.getCode());

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java b/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java
index 86c0ece..b2ca829 100644
--- a/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java
+++ b/common/src/main/java/org/apache/qpid/transport/codec/Encoder.java
@@ -27,6 +27,7 @@ import java.util.UUID;
 import org.apache.qpid.transport.RangeSet;
 import org.apache.qpid.transport.Struct;
 
+
 /**
  * Encoder interface.
  * Each concrete implementor must specify how to encode given values.

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/main/java/org/apache/qpid/transport/codec/EncoderUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/qpid/transport/codec/EncoderUtils.java b/common/src/main/java/org/apache/qpid/transport/codec/EncoderUtils.java
deleted file mode 100644
index ea06175..0000000
--- a/common/src/main/java/org/apache/qpid/transport/codec/EncoderUtils.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * 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.transport.codec;
-
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.qpid.transport.Struct;
-import org.apache.qpid.transport.Type;
-import org.apache.qpid.transport.Xid;
-
-public class EncoderUtils
-{
-    private static final Map<Class<?>, Type> ENCODINGS = new HashMap<>();
-    static
-    {
-        ENCODINGS.put(Boolean.class, Type.BOOLEAN);
-        ENCODINGS.put(String.class, Type.STR16);
-        ENCODINGS.put(Long.class, Type.INT64);
-        ENCODINGS.put(Integer.class, Type.INT32);
-        ENCODINGS.put(Short.class, Type.INT16);
-        ENCODINGS.put(Byte.class, Type.INT8);
-        ENCODINGS.put(Map.class, Type.MAP);
-        ENCODINGS.put(List.class, Type.LIST);
-        ENCODINGS.put(Float.class, Type.FLOAT);
-        ENCODINGS.put(Double.class, Type.DOUBLE);
-        ENCODINGS.put(Character.class, Type.CHAR);
-        ENCODINGS.put(byte[].class, Type.VBIN32);
-        ENCODINGS.put(UUID.class, Type.UUID);
-        ENCODINGS.put(Xid.class, Type.STRUCT32);
-    }
-
-    public static Type getEncodingType(Object value)
-    {
-        if (value == null)
-        {
-            return Type.VOID;
-        }
-
-        Class klass = value.getClass();
-        Type type = resolve(klass);
-
-        if (type == null)
-        {
-            throw new IllegalArgumentException
-                    ("unable to resolve type: " + klass + ", " + value);
-        }
-        else
-        {
-            return type;
-        }
-    }
-
-    public static int getStruct32Length(Struct s)
-    {
-        if (s == null)
-        {
-            return 4;
-        }
-        else
-        {
-            int len = 0;
-            len += 4; // size
-            len += 2; // encoded type
-            len += s.getEncodedLength();
-
-            return len;
-        }
-    }
-
-    public static int getArrayLength(List<Object> value)
-    {
-        int len = 0;
-        len += 4; // size
-        if (value != null && !value.isEmpty())
-        {
-            len += 1; // type
-            len += 4; // array size
-
-            final Type type = getEncodingType(value.get(0));
-            for (Object v : value)
-            {
-                len += getTypeLength(type, v);
-            }
-
-        }
-
-        return len;
-
-    }
-
-    public static int getListLength(List<Object> value)
-    {
-        int len = 0;
-        len += 4; // size
-        if (value != null && !value.isEmpty())
-        {
-            len += 4; // list size
-            for (Object v : value)
-            {
-                final Type type = getEncodingType(v);
-                len += 1; // type code
-                len += getTypeLength(type, v);
-            }
-        }
-        return len;
-    }
-
-    public static int getStr8Length(String s)
-    {
-        if (s == null)
-        {
-            return 1;
-        }
-        else
-        {
-            int length = s.getBytes(StandardCharsets.UTF_8).length;
-            if (length > 255)
-            {
-                throw new IllegalArgumentException(String.format("String too long (%d) for str8", length));
-            }
-            return 1 + length;
-        }
-    }
-
-    public static int getStr16Length(String s)
-    {
-        if (s == null)
-        {
-            return 2;
-        }
-        else
-        {
-            int length = s.getBytes(StandardCharsets.UTF_8).length;
-            if (length > 65535)
-            {
-                throw new IllegalArgumentException(String.format("String too long (%d) for str16", length));
-            }
-            return 2 + length;
-        }
-    }
-
-    public static int getVbin16Length(byte[] bytes)
-    {
-        if (bytes == null)
-        {
-            return 2;
-        }
-        else
-        {
-            return 2 + bytes.length;
-        }
-    }
-
-    public static int getStructLength(int type, Struct s)
-    {
-        int len = 0;
-
-        if (s == null)
-        {
-            s = Struct.create(type);
-        }
-
-        int width = s.getSizeWidth();
-
-        if (width > 0)
-        {
-            switch (width)
-            {
-                case 1:
-                case 2:
-                case 4:
-                    len += width;
-                    break;
-                default:
-                    throw new IllegalStateException("illegal width: " + width);
-            }
-        }
-
-        if (type > 0)
-        {
-            len += 2; // type
-        }
-
-        len += s.getEncodedLength();
-
-        return len;
-
-
-    }
-
-    public static int getMapLength(Map<String, Object> map)
-    {
-        int len = 0;
-
-        len += 4; // size
-        if (map != null)
-        {
-            len += 4; // map size
-            for (Map.Entry<String,Object> entry : map.entrySet())
-            {
-                String key = entry.getKey();
-                Object value = entry.getValue();
-                len += getStr8Length(key);
-                len += 1; // type code
-                Type type = getEncodingType(value);
-                len += getTypeLength(type, value);
-            }
-        }
-
-        return len;
-    }
-
-    private static Type resolve(Class klass)
-    {
-        Type type = ENCODINGS.get(klass);
-        if (type != null)
-        {
-            return type;
-        }
-
-        Class sup = klass.getSuperclass();
-        if (sup != null)
-        {
-            type = resolve(klass.getSuperclass());
-
-            if (type != null)
-            {
-                return type;
-            }
-        }
-
-        for (Class iface : klass.getInterfaces())
-        {
-            type = resolve(iface);
-            if (type != null)
-            {
-                return type;
-            }
-        }
-
-        return null;
-    }
-
-    private static int getTypeLength(Type t, Object value)
-    {
-        switch (t)
-        {
-            case VOID:
-                return 0;
-
-            case BIN8:
-            case UINT8:
-            case INT8:
-            case CHAR:
-            case BOOLEAN:
-                return 1;
-
-            case BIN16:
-            case UINT16:
-            case INT16:
-                return 2;
-
-            case BIN32:
-            case UINT32:
-            case CHAR_UTF32:
-            case INT32:
-            case FLOAT:
-                return 4;
-
-            case BIN64:
-            case UINT64:
-            case INT64:
-            case DATETIME:
-            case DOUBLE:
-                return 8;
-
-            case UUID:
-                return 16;
-
-            case STR8:
-                return getStr8Length((String) value);
-
-            case STR16:
-                return getStr16Length((String) value);
-
-            case STR8_LATIN:
-            case STR8_UTF16:
-            case STR16_LATIN:
-            case STR16_UTF16:
-                String str = (String) value;
-                return t.getWidth() + (str == null ? 0 : str.getBytes(StandardCharsets.UTF_8).length);
-
-            case MAP:
-                return getMapLength((Map<String, Object>) value);
-
-            case LIST:
-                return getListLength((List<Object>) value);
-
-            case ARRAY:
-                return getArrayLength((List<Object>) value);
-
-            case STRUCT32:
-                return getStruct32Length((Struct) value);
-
-            case BIN40:
-            case DEC32:
-            case BIN72:
-            case DEC64:
-                return t.getWidth() + (value == null ? 0 : ((byte[])value).length);
-
-            default:
-                if (!(value instanceof byte[]))
-                {
-                    throw new IllegalArgumentException("Expecting byte array was " + (value == null
-                            ? "null"
-                            : value.getClass()));
-                }
-                return t.getWidth() + (value == null ? 0 : ((byte[])value).length);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1172f862/common/src/test/java/org/apache/qpid/transport/codec/BBEncoderTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/qpid/transport/codec/BBEncoderTest.java b/common/src/test/java/org/apache/qpid/transport/codec/BBEncoderTest.java
index f4cedc4..5d6d406 100644
--- a/common/src/test/java/org/apache/qpid/transport/codec/BBEncoderTest.java
+++ b/common/src/test/java/org/apache/qpid/transport/codec/BBEncoderTest.java
@@ -20,17 +20,14 @@
  */
 package org.apache.qpid.transport.codec;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.junit.Assert.assertArrayEquals;
+import org.apache.qpid.test.utils.QpidTestCase;
 
 import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
 
-import org.apache.qpid.test.utils.QpidTestCase;
+/**
+ * BBEncoderTest
+ *
+ */
 
 public class BBEncoderTest extends QpidTestCase
 {
@@ -47,63 +44,4 @@ public class BBEncoderTest extends QpidTestCase
         assertEquals(0xBEEFDEAD, buf.getInt(4));
     }
 
-
-    public void testReadWriteStruct()
-    {
-        BBEncoder encoder = new BBEncoder(4);
-
-        ReplyTo replyTo = new ReplyTo("amq.direct", "test");
-        encoder.writeStruct(ReplyTo.TYPE, replyTo);
-
-        ByteBuffer buffer = encoder.buffer();
-
-        assertEquals("Unexpected size", EncoderUtils.getStructLength(ReplyTo.TYPE, replyTo), buffer.remaining());
-
-        BBDecoder decoder = new BBDecoder();
-        decoder.init(buffer);
-
-        ReplyTo decoded = (ReplyTo)decoder.readStruct(ReplyTo.TYPE);
-
-        assertEquals("Unexpected exchange", replyTo.getExchange(), decoded.getExchange());
-        assertEquals("Unexpected routing key", replyTo.getRoutingKey(), decoded.getRoutingKey());
-    }
-
-    public void testReadWriteStruct32()
-    {
-        BBEncoder encoder = new BBEncoder(4);
-        Map<String, Object> applicationHeaders = new HashMap<>();
-        applicationHeaders.put("testProperty", "testValue");
-        applicationHeaders.put("list", Arrays.asList("a", 1, 2.0));
-        applicationHeaders.put("map", Collections.singletonMap("mapKey", "mapValue"));
-        MessageProperties messageProperties = new MessageProperties(10,
-                                                                    UUID.randomUUID(),
-                                                                    "abc".getBytes(UTF_8),
-                                                                    new ReplyTo("amq.direct", "test"),
-                                                                    "text/plain",
-                                                                    "identity",
-                                                                    "cba".getBytes(UTF_8),
-                                                                    "app".getBytes(UTF_8),
-                                                                    applicationHeaders);
-
-        encoder.writeStruct32(messageProperties);
-
-        ByteBuffer buffer = encoder.buffer();
-
-        assertEquals("Unexpected size", EncoderUtils.getStruct32Length(messageProperties), buffer.remaining());
-
-        BBDecoder decoder = new BBDecoder();
-        decoder.init(buffer);
-
-        MessageProperties decoded = (MessageProperties)decoder.readStruct32();
-
-        assertEquals("Unexpected content length", messageProperties.getContentLength(), decoded.getContentLength());
-        assertEquals("Unexpected message id", messageProperties.getMessageId(), decoded.getMessageId());
-        assertArrayEquals("Unexpected correlation id", messageProperties.getCorrelationId(), decoded.getCorrelationId());
-        assertEquals("Unexpected reply to", messageProperties.getReplyTo(), decoded.getReplyTo());
-        assertEquals("Unexpected content type", messageProperties.getContentType(), decoded.getContentType());
-        assertEquals("Unexpected content encoding", messageProperties.getContentEncoding(), decoded.getContentEncoding());
-        assertArrayEquals("Unexpected user id", messageProperties.getUserId(), decoded.getUserId());
-        assertArrayEquals("Unexpected application id", messageProperties.getAppId(), decoded.getAppId());
-        assertEquals("Unexpected application headers", messageProperties.getApplicationHeaders(), decoded.getApplicationHeaders());
-    }
 }


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


[4/4] qpid-broker-j git commit: Revert "QPID-7723: [0-10] Allow header to be optional when computing the encoded size"

Posted by lq...@apache.org.
Revert "QPID-7723: [0-10] Allow header to be optional when computing the encoded size"

This reverts commit 400e7ec7090fd2135996a43343e885889adfd78d.


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/18bd89e7
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/18bd89e7
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/18bd89e7

Branch: refs/heads/6.1.x
Commit: 18bd89e753d7b4759dfcdb1d118e6a07af6940bf
Parents: 400e7ec
Author: Lorenz Quack <lq...@apache.org>
Authored: Tue May 23 09:39:55 2017 +0100
Committer: Lorenz Quack <lq...@apache.org>
Committed: Tue May 23 09:55:10 2017 +0100

----------------------------------------------------------------------
 .../protocol/v0_10/MessageMetaData_0_10.java    | 29 +++++++++-----------
 1 file changed, 13 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/18bd89e7/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java b/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java
index 80e8a51..403c554 100755
--- a/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java
+++ b/broker-plugins/amqp-0-10-protocol/src/main/java/org/apache/qpid/server/protocol/v0_10/MessageMetaData_0_10.java
@@ -38,7 +38,7 @@ import org.apache.qpid.transport.Struct;
 
 public class MessageMetaData_0_10 implements StorableMessageMetaData
 {
-    private final Header _header;
+    private Header _header;
     private DeliveryProperties _deliveryProps;
     private MessageProperties _messageProps;
     private MessageTransferHeader _messageHeader;
@@ -85,7 +85,6 @@ public class MessageMetaData_0_10 implements StorableMessageMetaData
     }
 
 
-    @Override
     public int getStorableSize()
     {
         int len = 0;
@@ -94,23 +93,21 @@ public class MessageMetaData_0_10 implements StorableMessageMetaData
         len += 4; // body size
         len += 4; // headers length
 
-        if (_header != null)
+        if(_header.getDeliveryProperties() != null)
         {
-            if(_header.getDeliveryProperties() != null)
-            {
-                len += EncoderUtils.getStruct32Length(_header.getDeliveryProperties());
-            }
-            if(_header.getMessageProperties() != null)
-            {
-                len += EncoderUtils.getStruct32Length(_header.getMessageProperties());
-            }
-            if(_header.getNonStandardProperties() != null)
+            len += EncoderUtils.getStruct32Length(_header.getDeliveryProperties());
+        }
+        if(_header.getMessageProperties() != null)
+        {
+            len += EncoderUtils.getStruct32Length(_header.getMessageProperties());
+        }
+        if(_header.getNonStandardProperties() != null)
+        {
+            for(Struct header : _header.getNonStandardProperties())
             {
-                for(Struct header : _header.getNonStandardProperties())
-                {
-                    len += EncoderUtils.getStruct32Length(header);
-                }
+                len += EncoderUtils.getStruct32Length(header);
             }
+
         }
         return len;
     }


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


[3/4] qpid-broker-j git commit: QPID-7794: [Java Broker] Back out unintended changes to MemoryMessageStore

Posted by lq...@apache.org.
QPID-7794: [Java Broker] Back out unintended changes to MemoryMessageStore


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/7cf5eb39
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/7cf5eb39
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/7cf5eb39

Branch: refs/heads/6.1.x
Commit: 7cf5eb3951ee063e08dbc40e9220661b2837ce5b
Parents: 1172f86
Author: Lorenz Quack <lq...@apache.org>
Authored: Tue May 23 09:43:36 2017 +0100
Committer: Lorenz Quack <lq...@apache.org>
Committed: Tue May 23 09:55:10 2017 +0100

----------------------------------------------------------------------
 .../apache/qpid/server/store/MemoryMessageStore.java  | 14 --------------
 1 file changed, 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/7cf5eb39/broker-core/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java b/broker-core/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java
index 2264b9a..8983619 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/store/MemoryMessageStore.java
@@ -51,7 +51,6 @@ public class MemoryMessageStore implements MessageStore
     private final Object _transactionLock = new Object();
     private final Map<UUID, Set<Long>> _messageInstances = new HashMap<UUID, Set<Long>>();
     private final Map<Xid, DistributedTransactionRecords> _distributedTransactions = new HashMap<Xid, DistributedTransactionRecords>();
-    private final AtomicLong _inMemorySize = new AtomicLong();
 
 
     private final class MemoryMessageStoreTransaction implements Transaction
@@ -287,25 +286,13 @@ public class MemoryMessageStore implements MessageStore
 
         StoredMemoryMessage<T> storedMemoryMessage = new StoredMemoryMessage<T>(id, metaData)
         {
-
-            @Override
-            public synchronized StoredMessage<T> allContentAdded()
-            {
-                final StoredMessage<T> storedMessage = super.allContentAdded();
-                _inMemorySize.addAndGet(getContentSize());
-                return storedMessage;
-            }
-
             @Override
             public void remove()
             {
                 _messages.remove(getMessageNumber());
-                int bytesCleared = metaData.getStorableSize() + metaData.getContentSize();
                 super.remove();
-                _inMemorySize.addAndGet(-bytesCleared);
             }
         };
-        _inMemorySize.addAndGet(metaData.getStorableSize());
 
         return storedMemoryMessage;
 
@@ -343,7 +330,6 @@ public class MemoryMessageStore implements MessageStore
             storedMemoryMessage.clear();
         }
         _messages.clear();
-        _inMemorySize.set(0);
         synchronized (_transactionLock)
         {
             _messageInstances.clear();


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