From 905f1a8753ec8eadea753cf663e1e709568a33fc Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Wed, 22 Jun 2011 03:40:03 +0000 Subject: QPID-3270 A new enumeration is created off a static list for each invocation of asEnumeration(). git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1138296 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/client/CustomJMSXProperty.java | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java b/qpid/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java index 7cc548915c..e81e754da2 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/CustomJMSXProperty.java @@ -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 _names; + + static + { + CustomJMSXProperty[] properties = values(); + _names = new ArrayList(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 nameList = new ArrayList(properties.length); - for(CustomJMSXProperty property : properties) - { - nameList.add(property.toString()); - } - _names = Collections.enumeration(nameList); - } - return _names; + return Collections.enumeration(_names); } } -- cgit v1.2.1