tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1195953 - in /tomcat/trunk/java/org/apache/catalina: connector/ core/ ha/context/ session/ util/
Date Tue, 01 Nov 2011 12:23:29 GMT
Author: markt
Date: Tue Nov  1 12:23:28 2011
New Revision: 1195953

URL: http://svn.apache.org/viewvc?rev=1195953&view=rev
Log:
Deprecate o.a.catalina.util.Enumerator and switch to
Collections.enumeration

Modified:
    tomcat/trunk/java/org/apache/catalina/connector/Request.java
    tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java
    tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
    tomcat/trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java
    tomcat/trunk/java/org/apache/catalina/core/ApplicationRequest.java
    tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java
    tomcat/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java
    tomcat/trunk/java/org/apache/catalina/session/StandardSession.java
    tomcat/trunk/java/org/apache/catalina/util/Enumerator.java

Modified: tomcat/trunk/java/org/apache/catalina/connector/Request.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Request.java?rev=1195953&r1=1195952&r2=1195953&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Request.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Request.java Tue Nov  1 12:23:28 2011
@@ -29,10 +29,12 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Set;
 import java.util.TimeZone;
 import java.util.TreeMap;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -69,7 +71,6 @@ import org.apache.catalina.core.Applicat
 import org.apache.catalina.core.AsyncContextImpl;
 import org.apache.catalina.deploy.LoginConfig;
 import org.apache.catalina.realm.GenericPrincipal;
-import org.apache.catalina.util.Enumerator;
 import org.apache.catalina.util.ParameterMap;
 import org.apache.catalina.util.StringParser;
 import org.apache.coyote.ActionCode;
@@ -965,7 +966,11 @@ public class Request
         if (isSecure() && !sslAttributesParsed) {
             getAttribute(Globals.CERTIFICATES_ATTR);
         }
-        return new Enumerator<String>(attributes.keySet(), true);
+        // Take a copy to prevent ConncurrentModificationExceptions if used to
+        // remove attributes
+        Set<String> names = new HashSet<String>();
+        names.addAll(attributes.keySet());
+        return Collections.enumeration(names);
     }
 
 
@@ -1057,11 +1062,11 @@ public class Request
         }
 
         if (locales.size() > 0) {
-            return (new Enumerator<Locale>(locales));
+            return Collections.enumeration(locales);
         }
         ArrayList<Locale> results = new ArrayList<Locale>();
         results.add(defaultLocale);
-        return new Enumerator<Locale>(results);
+        return Collections.enumeration(results);
 
     }
 

Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java?rev=1195953&r1=1195952&r2=1195953&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java Tue Nov  1 12:23:28
2011
@@ -29,6 +29,7 @@ import java.util.EnumSet;
 import java.util.Enumeration;
 import java.util.EventListener;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -66,7 +67,6 @@ import org.apache.catalina.Service;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.connector.Connector;
 import org.apache.catalina.deploy.FilterDef;
-import org.apache.catalina.util.Enumerator;
 import org.apache.catalina.util.RequestUtil;
 import org.apache.catalina.util.ResourceSet;
 import org.apache.catalina.util.ServerInfo;
@@ -232,9 +232,9 @@ public class ApplicationContext
      */
     @Override
     public Enumeration<String> getAttributeNames() {
-
-        return new Enumerator<String>(attributes.keySet(), true);
-
+        Set<String> names = new HashSet<String>();
+        names.addAll(attributes.keySet());
+        return Collections.enumeration(names);
     }
 
 
@@ -316,7 +316,7 @@ public class ApplicationContext
      */
     @Override
     public Enumeration<String> getInitParameterNames() {
-        return (new Enumerator<String>(parameters.keySet()));
+        return Collections.enumeration(parameters.keySet());
     }
 
 
@@ -670,7 +670,7 @@ public class ApplicationContext
     @Override
     @Deprecated
     public Enumeration<String> getServletNames() {
-        return (new Enumerator<String>(emptyString));
+        return Collections.enumeration(emptyString);
     }
 
 
@@ -680,7 +680,7 @@ public class ApplicationContext
     @Override
     @Deprecated
     public Enumeration<Servlet> getServlets() {
-        return (new Enumerator<Servlet>(emptyServlet));
+        return Collections.enumeration(emptyServlet);
     }
 
 

Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java?rev=1195953&r1=1195952&r2=1195953&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java Tue Nov  1 12:23:28
2011
@@ -21,10 +21,10 @@ package org.apache.catalina.core;
 
 import java.io.Serializable;
 import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.management.ObjectName;
@@ -38,7 +38,6 @@ import org.apache.catalina.Context;
 import org.apache.catalina.Globals;
 import org.apache.catalina.deploy.FilterDef;
 import org.apache.catalina.security.SecurityUtil;
-import org.apache.catalina.util.Enumerator;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.InstanceManager;
 import org.apache.tomcat.util.log.SystemLogHandler;
@@ -65,6 +64,11 @@ public final class ApplicationFilterConf
     private static final org.apache.juli.logging.Log log =
         LogFactory.getLog(ApplicationFilterConfig.class);
 
+    /**
+     * Empty String collection to serve as the basis for empty enumerations.
+     */
+    private static final List<String> emptyString = Collections.emptyList();
+
     // ----------------------------------------------------------- Constructors
 
 
@@ -181,11 +185,10 @@ public final class ApplicationFilterConf
         Map<String,String> map = filterDef.getParameterMap();
 
         if (map == null) {
-            return (new Enumerator<String>(new ArrayList<String>()));
+            return Collections.enumeration(emptyString);
         }
 
-        return new Enumerator<String>(map.keySet());
-
+        return Collections.enumeration(map.keySet());
     }
 
 

Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java?rev=1195953&r1=1195952&r2=1195953&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java Tue Nov  1 12:23:28
2011
@@ -21,6 +21,7 @@ package org.apache.catalina.core;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -37,7 +38,6 @@ import org.apache.catalina.Context;
 import org.apache.catalina.Globals;
 import org.apache.catalina.Manager;
 import org.apache.catalina.Session;
-import org.apache.catalina.util.Enumerator;
 import org.apache.catalina.util.RequestUtil;
 
 
@@ -393,8 +393,7 @@ class ApplicationHttpRequest extends Htt
     public Enumeration<String> getParameterNames() {
 
         parseParameters();
-        return (new Enumerator<String>(parameters.keySet()));
-
+        return Collections.enumeration(parameters.keySet());
     }
 
 

Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationRequest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationRequest.java?rev=1195953&r1=1195952&r2=1195953&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationRequest.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationRequest.java Tue Nov  1 12:23:28
2011
@@ -19,6 +19,7 @@
 package org.apache.catalina.core;
 
 
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 
@@ -26,8 +27,6 @@ import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletRequestWrapper;
 
-import org.apache.catalina.util.Enumerator;
-
 
 /**
  * Wrapper around a <code>javax.servlet.ServletRequest</code>
@@ -120,7 +119,7 @@ class ApplicationRequest extends Servlet
     public Enumeration<String> getAttributeNames() {
 
         synchronized (attributes) {
-            return (new Enumerator<String>(attributes.keySet()));
+            return Collections.enumeration(attributes.keySet());
         }
 
     }

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java?rev=1195953&r1=1195952&r2=1195953&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java Tue Nov  1 12:23:28 2011
@@ -21,6 +21,7 @@ package org.apache.catalina.core;
 import java.io.PrintStream;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -58,7 +59,6 @@ import org.apache.catalina.LifecycleStat
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.mbeans.MBeanUtils;
 import org.apache.catalina.security.SecurityUtil;
-import org.apache.catalina.util.Enumerator;
 import org.apache.catalina.util.InstanceSupport;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -1526,7 +1526,7 @@ public class StandardWrapper extends Con
 
         try {
             parametersLock.readLock().lock();
-            return (new Enumerator<String>(parameters.keySet()));
+            return Collections.enumeration(parameters.keySet());
         } finally {
             parametersLock.readLock().unlock();
         }

Modified: tomcat/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java?rev=1195953&r1=1195952&r2=1195953&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java Tue Nov  1 12:23:28
2011
@@ -17,7 +17,10 @@
 package org.apache.catalina.ha.context;
 
 import java.util.AbstractMap;
+import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.servlet.ServletContext;
@@ -31,7 +34,6 @@ import org.apache.catalina.ha.CatalinaCl
 import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.tipis.AbstractReplicatedMap.MapOwner;
 import org.apache.catalina.tribes.tipis.ReplicatedMap;
-import org.apache.catalina.util.Enumerator;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 
@@ -175,11 +177,13 @@ public class ReplicatedContext extends S
         @SuppressWarnings("unchecked")
         @Override
         public Enumeration<String> getAttributeNames() {
+            Set<String> names = new HashSet<String>();
+            names.addAll(attributes.keySet());
+
             return new MultiEnumeration<String>(new Enumeration[] {
                     super.getAttributeNames(),
-                    new Enumerator<String>(tomcatAttributes.keySet(), true)});
+                    Collections.enumeration(names) });
         }
-
     }
 
     protected static class MultiEnumeration<T> implements Enumeration<T> {

Modified: tomcat/trunk/java/org/apache/catalina/session/StandardSession.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/session/StandardSession.java?rev=1195953&r1=1195952&r2=1195953&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/session/StandardSession.java (original)
+++ tomcat/trunk/java/org/apache/catalina/session/StandardSession.java Tue Nov  1 12:23:28
2011
@@ -29,11 +29,14 @@ import java.security.AccessController;
 import java.security.Principal;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Enumeration;
-import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -55,7 +58,6 @@ import org.apache.catalina.SessionListen
 import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.realm.GenericPrincipal;
 import org.apache.catalina.security.SecurityUtil;
-import org.apache.catalina.util.Enumerator;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 
@@ -1180,8 +1182,9 @@ public class StandardSession implements 
             throw new IllegalStateException
                 (sm.getString("standardSession.getAttributeNames.ise"));
 
-        return (new Enumerator<String>(attributes.keySet(), true));
-
+        Set<String> names = new HashSet<String>();
+        names.addAll(attributes.keySet());
+        return Collections.enumeration(names);
     }
 
 
@@ -1870,8 +1873,7 @@ public class StandardSession implements 
 final class StandardSessionContext
         implements javax.servlet.http.HttpSessionContext {
 
-
-    protected HashMap<?,String> dummy = new HashMap<String,String>();
+    private static final List<String> emptyString = Collections.emptyList();
 
     /**
      * Return the session identifiers of all sessions defined
@@ -1884,9 +1886,7 @@ final class StandardSessionContext
     @Override
     @Deprecated
     public Enumeration<String> getIds() {
-
-        return (new Enumerator<String>(dummy));
-
+        return Collections.enumeration(emptyString);
     }
 
 
@@ -1903,10 +1903,6 @@ final class StandardSessionContext
     @Override
     @Deprecated
     public HttpSession getSession(String id) {
-
         return (null);
-
     }
-
-
 }

Modified: tomcat/trunk/java/org/apache/catalina/util/Enumerator.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/util/Enumerator.java?rev=1195953&r1=1195952&r2=1195953&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/util/Enumerator.java (original)
+++ tomcat/trunk/java/org/apache/catalina/util/Enumerator.java Tue Nov  1 12:23:28 2011
@@ -37,7 +37,7 @@ import java.util.NoSuchElementException;
  * @author Craig R. McClanahan
  * @version $Id$
  */
-
+@Deprecated
 public final class Enumerator<T> implements Enumeration<T> {
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message