You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ra...@apache.org on 2011/06/22 05:40:03 UTC

svn commit: r1138296 - /qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java

Author: rajith
Date: Wed Jun 22 03:40:03 2011
New Revision: 1138296

URL: http://svn.apache.org/viewvc?rev=1138296&view=rev
Log:
QPID-3270 A new enumeration is created off a static list for each
invocation of asEnumeration().

Modified:
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java?rev=1138296&r1=1138295&r2=1138296&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java Wed Jun 22 03:40:03 2011
@@ -23,6 +23,7 @@ package org.apache.qpid.client;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.List;
 
 import org.apache.qpid.framing.AMQShortString;
 
@@ -34,6 +35,18 @@ public enum CustomJMSXProperty
     JMSXGroupSeq,
     JMSXUserID;
 
+    private static List<String> _names;
+
+    static
+    {
+        CustomJMSXProperty[] properties = values();
+        _names = new ArrayList<String>(properties.length);
+        for(CustomJMSXProperty property :  properties)
+        {
+            _names.add(property.toString());
+        }
+
+    }
 
     private final AMQShortString _nameAsShortString;
 
@@ -47,20 +60,8 @@ public enum CustomJMSXProperty
         return _nameAsShortString;
     }
 
-    private static Enumeration _names;
-
-    public static synchronized Enumeration asEnumeration()
+    public static Enumeration asEnumeration()
     {
-        if(_names == null)
-        {
-            CustomJMSXProperty[] properties = values();
-            ArrayList<String> nameList = new ArrayList<String>(properties.length);
-            for(CustomJMSXProperty property :  properties)
-            {
-                nameList.add(property.toString());
-            }
-            _names = Collections.enumeration(nameList);
-        }
-        return _names;    
+        return Collections.enumeration(_names);
     }
 }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org