diff options
author | Robert Greig <rgreig@apache.org> | 2006-12-13 18:46:26 +0000 |
---|---|---|
committer | Robert Greig <rgreig@apache.org> | 2006-12-13 18:46:26 +0000 |
commit | aefda495b3452c599ea92cdb22b1d01b7ceed11d (patch) | |
tree | 618458cb24f849cd05d3b73350a8265e64995776 /java | |
parent | 9567c8f1cf7e217442c076203263df0aac2cafe4 (diff) | |
download | qpid-python-aefda495b3452c599ea92cdb22b1d01b7ceed11d.tar.gz |
QPID-179 Patch supplied by Rob Godfrey. Field table remove was fundamentally broken.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@486793 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r-- | java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java b/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java index b6556b2468..8c9b5f3b4c 100644 --- a/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java +++ b/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java @@ -7,9 +7,9 @@ * 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 @@ -33,7 +33,7 @@ import java.util.StringTokenizer; import java.util.Vector; //extends FieldTable -public class PropertyFieldTable implements FieldTable, Map +public class PropertyFieldTable implements FieldTable { private static final Logger _logger = Logger.getLogger(PropertyFieldTable.class); @@ -597,7 +597,7 @@ public class PropertyFieldTable implements FieldTable, Map // FIXME: Should be able to short-cut this process if the old and new values are // the same object and/or type and size... - _encodedSize -= getEncodingSize(currentValue + propertyName, previous); + _encodedSize -= getEncodingSize(currentValue + propertyName, previous) + 1; } _propertyNamesTypeMap.put(propertyName, "" + propertyPrefix); @@ -1028,8 +1028,8 @@ public class PropertyFieldTable implements FieldTable, Map // This is ambiguous in the JMS spec and needs thrashing out and potentially // testing against other implementations. - //Add the size of the content - _encodedSize += getEncodingSize(key, value); + //Add the size of the content plus one for the type identifier + _encodedSize += getEncodingSize(key, value) + 1; } if (_logger.isDebugEnabled()) @@ -1044,25 +1044,18 @@ public class PropertyFieldTable implements FieldTable, Map public Object remove(Object key) { - if (key instanceof String) - { - throw new IllegalArgumentException("Property key be a string"); - } - - char propertyPrefix = ((String) key).charAt(0); - if (_properties.containsKey(key)) { final Object value = _properties.remove(key); + String typePrefix = _propertyNamesTypeMap.remove(key); // plus one for the type - _encodedSize -= EncodingUtils.encodedShortStringLength(((String) key)); + _encodedSize -= EncodingUtils.encodedShortStringLength(((String) key)) + 1; // This check is, for now, unnecessary (we don't store null values). if (value != null) { - _encodedSize -= getEncodingSize(propertyPrefix + (String) key, value); + _encodedSize -= getEncodingSize(typePrefix, value); } - return value; } else @@ -1329,7 +1322,7 @@ public class PropertyFieldTable implements FieldTable, Map */ private static int getEncodingSize(String name, Object value) { - int encodingSize = 1; // Initialy 1 to cover the char prefix + int encodingSize = 0; char propertyPrefix = name.charAt(0); |