tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r905714 - in /tomcat/trunk/java/org/apache: catalina/deploy/WebXml.java tomcat/util/buf/StringCache.java
Date Tue, 02 Feb 2010 17:21:28 GMT
Author: markt
Date: Tue Feb  2 17:21:23 2010
New Revision: 905714

URL: http://svn.apache.org/viewvc?rev=905714&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48551
Use entrySet() rather than keySet() + get()
Patch provided by sebb

Modified:
    tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java
    tomcat/trunk/java/org/apache/tomcat/util/buf/StringCache.java

Modified: tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java?rev=905714&r1=905713&r2=905714&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java (original)
+++ tomcat/trunk/java/org/apache/catalina/deploy/WebXml.java Tue Feb  2 17:21:23 2010
@@ -29,6 +29,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Map.Entry;
 
 import javax.servlet.MultipartConfigElement;
 import javax.servlet.SessionCookieConfig;
@@ -1054,8 +1055,8 @@
         context.setPublicId(publicId);
 
         // Everything else in order
-        for (String contextParam : contextParams.keySet()) {
-            context.addParameter(contextParam, contextParams.get(contextParam));
+        for (Entry<String, String> entry : contextParams.entrySet()) {
+            context.addParameter(entry.getKey(), entry.getValue());
         }
         context.setDisplayName(displayName);
         context.setDistributable(distributable);
@@ -1081,9 +1082,9 @@
         for (String listener : listeners) {
             context.addApplicationListener(listener);
         }
-        for (String locale : localeEncodingMappings.keySet()) {
-            context.addLocaleEncodingMappingParameter(locale,
-                    localeEncodingMappings.get(locale));
+        for (Entry<String, String> entry : localeEncodingMappings.entrySet()) {
+            context.addLocaleEncodingMappingParameter(entry.getKey(),
+                    entry.getValue());
         }
         // Prevents IAE
         if (loginConfig != null) {
@@ -1096,8 +1097,8 @@
         // messageDestinations were ignored in Tomcat 6, so ignore here
         
         context.setIgnoreAnnotations(metadataComplete);
-        for (String extension : mimeMappings.keySet()) {
-            context.addMimeMapping(extension, mimeMappings.get(extension));
+        for (Entry<String, String> entry : mimeMappings.entrySet()) {
+            context.addMimeMapping(entry.getKey(), entry.getValue());
         }
         // Name is just used for ordering
         for (ContextResourceEnvRef resource : resourceEnvRefs.values()) {
@@ -1134,8 +1135,8 @@
             }
             wrapper.setName(servlet.getServletName());
             Map<String,String> params = servlet.getParameterMap(); 
-            for (String param : params.keySet()) {
-                wrapper.addInitParameter(param, params.get(param));
+            for (Entry<String, String> entry : params.entrySet()) {
+                wrapper.addInitParameter(entry.getKey(), entry.getValue());
             }
             wrapper.setRunAs(servlet.getRunAs());
             Set<SecurityRoleRef> roleRefs = servlet.getSecurityRoleRefs();
@@ -1166,8 +1167,8 @@
             }
             context.addChild(wrapper);
         }
-        for (String pattern : servletMappings.keySet()) {
-            context.addServletMapping(pattern, servletMappings.get(pattern));
+        for (Entry<String, String> entry : servletMappings.entrySet()) {
+            context.addServletMapping(entry.getKey(), entry.getValue());
         }
         if (sessionConfig != null) {
             if (sessionConfig.getSessionTimeout() != null) {
@@ -1194,8 +1195,8 @@
                         sessionConfig.getSessionTrackingModes());
             }
         }
-        for (String uri : taglibs.keySet()) {
-            context.addTaglib(uri, taglibs.get(uri));
+        for (Entry<String, String> entry : taglibs.entrySet()) {
+            context.addTaglib(entry.getKey(), entry.getValue());
         }
         
         // Context doesn't use version directly
@@ -1735,10 +1736,11 @@
     private static <T> boolean mergeMap(Map<String,T> fragmentMap,
             Map<String,T> mainMap, Map<String,T> tempMap, WebXml fragment,
             String mapName) {
-        for (String key : fragmentMap.keySet()) {
+        for (Entry<String, T> entry : fragmentMap.entrySet()) {
+            final String key = entry.getKey();
             if (!mainMap.containsKey(key)) {
                 // Not defined in main web.xml
-                T value = fragmentMap.get(key);
+                T value = entry.getValue();
                 if (tempMap.containsKey(key)) {
                     if (value != null && !value.equals(
                             tempMap.get(key))) {
@@ -1942,9 +1944,9 @@
             for (String requestedName : requestedOrder) {
                 if (WebXml.ORDER_OTHERS.equals(requestedName)) {
                     // Add all fragments not named explicitly at this point
-                    for (String name : fragments.keySet()) {
-                        if (!requestedOrder.contains(name)) {
-                            WebXml fragment = fragments.get(name);
+                    for (Entry<String, WebXml> entry : fragments.entrySet()) {
+                        if (!requestedOrder.contains(entry.getKey())) {
+                            WebXml fragment = entry.getValue();
                             if (fragment != null) {
                                 orderedFragments.add(fragment);
                             }

Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/StringCache.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/StringCache.java?rev=905714&r1=905713&r2=905714&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/buf/StringCache.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/StringCache.java Tue Feb  2 17:21:23 2010
@@ -19,8 +19,8 @@
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.TreeMap;
+import java.util.Map.Entry;
 
 /**
  * This class implements a String cache for ByteChunk and CharChunk.
@@ -233,11 +233,9 @@
                         // Sort the entries according to occurrence
                         TreeMap<Integer,ArrayList<ByteEntry>> tempMap =
                             new TreeMap<Integer,ArrayList<ByteEntry>>();
-                        Iterator<ByteEntry> entries =
-                            bcStats.keySet().iterator();
-                        while (entries.hasNext()) {
-                            ByteEntry entry = entries.next();
-                            int[] countA = bcStats.get(entry);
+                        for (Entry<ByteEntry, int[]> item : bcStats.entrySet()) {
+                            ByteEntry entry = item.getKey();
+                            int[] countA = item.getValue();
                             Integer count = new Integer(countA[0]);
                             // Add to the list for that count
                             ArrayList<ByteEntry> list = tempMap.get(count);
@@ -347,10 +345,9 @@
                         // Sort the entries according to occurrence
                         TreeMap<Integer,ArrayList<CharEntry>> tempMap =
                             new TreeMap<Integer,ArrayList<CharEntry>>();
-                        Iterator<CharEntry> entries = ccStats.keySet().iterator();
-                        while (entries.hasNext()) {
-                            CharEntry entry = entries.next();
-                            int[] countA = ccStats.get(entry);
+                        for (Entry<CharEntry, int[]> item : ccStats.entrySet()) {
+                            CharEntry entry = item.getKey();
+                            int[] countA = item.getValue();
                             Integer count = new Integer(countA[0]);
                             // Add to the list for that count
                             ArrayList<CharEntry> list = tempMap.get(count);



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


Mime
View raw message