tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r937322 - in /tomcat/trunk/java/org/apache/catalina: connector/ core/ ha/authenticator/ ha/session/ startup/
Date Fri, 23 Apr 2010 15:03:28 GMT
Author: markt
Date: Fri Apr 23 15:03:28 2010
New Revision: 937322

URL: http://svn.apache.org/viewvc?rev=937322&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49140
Use appropriate iterators and for-each where possible

Modified:
    tomcat/trunk/java/org/apache/catalina/connector/Request.java
    tomcat/trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java
    tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
    tomcat/trunk/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOnListener.java
    tomcat/trunk/java/org/apache/catalina/ha/session/ClusterSessionListener.java
    tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.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=937322&r1=937321&r2=937322&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Request.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Request.java Fri Apr 23 15:03:28 2010
@@ -2962,13 +2962,8 @@ public class Request
 
         // Process the quality values in highest->lowest order (due to
         // negating the Double value when creating the key)
-        Iterator<Double> keys = locales.keySet().iterator();
-        while (keys.hasNext()) {
-            Double key = keys.next();
-            ArrayList<Locale> list = locales.get(key);
-            Iterator<Locale> values = list.iterator();
-            while (values.hasNext()) {
-                Locale locale = values.next();
+        for (ArrayList<Locale> list : locales.values()) {
+            for (Locale locale : list) {
                 addLocale(locale);
             }
         }

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=937322&r1=937321&r2=937322&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationHttpRequest.java Fri Apr 23 15:03:28
2010
@@ -649,11 +649,11 @@ class ApplicationHttpRequest extends Htt
         if (orig == null)
             return (new HashMap<String, String[]>());
         HashMap<String, String[]> dest = new HashMap<String, String[]>();
-        Iterator<String> keys = orig.keySet().iterator();
-        while (keys.hasNext()) {
-            String key = keys.next();
-            dest.put(key, orig.get(key));
+        
+        for (Map.Entry<String, String[]> entry : orig.entrySet()) {
+            dest.put(entry.getKey(), entry.getValue());
         }
+
         return (dest);
 
     }

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContext.java?rev=937322&r1=937321&r2=937322&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardContext.java Fri Apr 23 15:03:28 2010
@@ -38,7 +38,6 @@ import java.util.TreeMap;
 import javax.management.AttributeNotFoundException;
 import javax.management.ListenerNotFoundException;
 import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanRegistrationException;
 import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
 import javax.management.Notification;
@@ -4461,13 +4460,8 @@ public class StandardContext
         }
 
         // Load the collected "load on startup" servlets
-        Iterator<Integer> keys = map.keySet().iterator();
-        while (keys.hasNext()) {
-            Integer key = keys.next();
-            ArrayList<Wrapper> list = map.get(key);
-            Iterator<Wrapper> wrappers = list.iterator();
-            while (wrappers.hasNext()) {
-                Wrapper wrapper = wrappers.next();
+        for (ArrayList<Wrapper> list : map.values()) {
+            for (Wrapper wrapper : list) {
                 try {
                     wrapper.load();
                 } catch (ServletException e) {

Modified: tomcat/trunk/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOnListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOnListener.java?rev=937322&r1=937321&r2=937322&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOnListener.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/ha/authenticator/ClusterSingleSignOnListener.java
Fri Apr 23 15:03:28 2010
@@ -144,13 +144,10 @@ public class ClusterSingleSignOnListener
         Session session = null;
 
         if (ctxname == null) {
-            java.util.Iterator<String> i = managers.keySet().iterator();
-            while (i.hasNext()) {
-                String key = i.next();
-                ClusterManager mgr = managers.get(key);
-                if (mgr != null) {
+            for (Map.Entry<String, ClusterManager> entry : managers.entrySet()) {
+                if (entry.getValue() != null) {
                     try {
-                        session = mgr.findSession(sessionId);
+                        session = entry.getValue().findSession(sessionId);
                     } catch (IOException io) {
                         log.error("Session doesn't exist:" + io);
                     }
@@ -160,7 +157,7 @@ public class ClusterSingleSignOnListener
                     // up
                     if (log.isDebugEnabled())
                         log.debug("Context manager doesn't exist:"
-                                  + key);
+                                  + entry.getKey());
                 }
             }
         } else {

Modified: tomcat/trunk/java/org/apache/catalina/ha/session/ClusterSessionListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/session/ClusterSessionListener.java?rev=937322&r1=937321&r2=937322&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/session/ClusterSessionListener.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/session/ClusterSessionListener.java Fri Apr 23
15:03:28 2010
@@ -17,7 +17,6 @@
 
 package org.apache.catalina.ha.session;
 
-import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.catalina.ha.*;
@@ -67,18 +66,16 @@ public class ClusterSessionListener exte
             //if so, wait until we are fully started up
             Map<String,ClusterManager> managers = cluster.getManagers() ;
             if (ctxname == null) {
-                Iterator<String> i = managers.keySet().iterator();
-                while (i.hasNext()) {
-                    String key = i.next();
-                    ClusterManager mgr = managers.get(key);
-                    if (mgr != null)
-                        mgr.messageDataReceived(msg);
+                for (Map.Entry<String, ClusterManager> entry :
+                        managers.entrySet()) {
+                    if (entry.getValue() != null)
+                        entry.getValue().messageDataReceived(msg);
                     else {
                         //this happens a lot before the system has started
                         // up
                         if (log.isDebugEnabled())
                             log.debug("Context manager doesn't exist:"
-                                    + key);
+                                    + entry.getKey());
                     }
                 }
             } else {

Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=937322&r1=937321&r2=937322&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Fri Apr 23 15:03:28 2010
@@ -1926,9 +1926,9 @@ public class ContextConfig
             } else if ("initParams".equals(name)) {
                 Map<String,String> initParams =
                     processAnnotationWebInitParams(evp.getValue());
-                for (String paramName : initParams.keySet()) {
-                    servletDef.addInitParameter(paramName,
-                            initParams.get(paramName));
+                for (Map.Entry<String, String> entry : initParams.entrySet()) {
+                    servletDef.addInitParameter(entry.getKey(),
+                            entry.getValue());
                 }
             } else {
                 // Ignore
@@ -1996,9 +1996,9 @@ public class ContextConfig
             } else if ("initParams".equals(name)) {
                 Map<String,String> initParams =
                     processAnnotationWebInitParams(evp.getValue());
-                for (String paramName : initParams.keySet()) {
-                    filterDef.addInitParameter(paramName,
-                            initParams.get(paramName));
+                for (Map.Entry<String, String> entry : initParams.entrySet()) {
+                    filterDef.addInitParameter(entry.getKey(),
+                            entry.getValue());
                 }
             } else {
                 // Ignore



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


Mime
View raw message