qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgr...@apache.org
Subject svn commit: r487627 - /incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java
Date Fri, 15 Dec 2006 19:22:21 GMT
Author: rgreig
Date: Fri Dec 15 11:22:20 2006
New Revision: 487627

URL: http://svn.apache.org/viewvc?view=rev&rev=487627
Log:
QPID-199 Patch supplied by Rob Godfrey

Modified:
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java?view=diff&rev=487627&r1=487626&r2=487627
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java
(original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java
Fri Dec 15 11:22:20 2006
@@ -57,10 +57,6 @@
     private static final String BYTES_CLOSE_XML = "</" + BYTES + ">";
     private static final String BYTES_OPEN_XML_START = "<" + BYTES;
 
-    private LinkedHashMap<String, Object> _properties;
-    private LinkedHashMap<String, Prefix> _propertyNamesTypeMap;
-    private long _encodedSize = 0;
-
     public static enum Prefix
     {
         //AMQP FieldTable Wire Types
@@ -93,7 +89,7 @@
         Prefix(char identifier)
         {
             _identifier = identifier;
-            _reverseTypeMap.put(identifier, this);
+            //_reverseTypeMap.put(identifier, this);
         }
 
         public final char identifier()
@@ -105,6 +101,18 @@
 
     public static Map<Character, Prefix> _reverseTypeMap = new HashMap<Character,
Prefix>();
 
+    static
+    {
+        for (Prefix p : Prefix.values())
+        {
+            _reverseTypeMap.put(p.identifier(), p);
+        }
+    }
+
+    private LinkedHashMap<String, Object> _properties;
+    private LinkedHashMap<String, Prefix> _propertyNamesTypeMap;
+    private long _encodedSize = 0;
+
     public PropertyFieldTable()
     {
         super();
@@ -1159,8 +1167,16 @@
 
             byte iType = buffer.get();
 
-            Prefix type = _reverseTypeMap.get((char) iType);
+            Character mapKey = new Character((char) iType);
+            Prefix type = _reverseTypeMap.get(mapKey);
 
+            if (type == null)
+            {
+                String msg = "Field '" + key + "' - unsupported field table type: " + type
+ ".";
+                    //some extra trace information...
+                    msg += " (" + iType + "), length=" + length + ", sizeRead=" + sizeRead
+ ", sizeRemaining=" + sizeRemaining;
+                    throw new AMQFrameDecodingException(msg);
+            }
             Object value;
 
             switch (type)
@@ -1204,9 +1220,7 @@
                     value = EncodingUtils.readBytes(buffer);
                     break;
                 default:
-                    String msg = "Field '" + key + "' - unsupported field table type: " +
type + ".";
-                    //some extra trace information...
-                    msg += " (" + iType + "), length=" + length + ", sizeRead=" + sizeRead
+ ", sizeRemaining=" + sizeRemaining;
+                    String msg = "Internal error, the following type identifier is not handled:
" + type;                                        
                     throw new AMQFrameDecodingException(msg);
             }
 



Mime
View raw message