This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new f40872b054 Refactor - use enhanced for loops - no functional change f40872b054 is described below commit f40872b05478692752629503585f1b6ba1cc0c7e Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Feb 15 15:29:35 2023 +0000 Refactor - use enhanced for loops - no functional change --- java/org/apache/catalina/ant/jmx/JMXAccessorQueryTask.java | 5 +---- java/org/apache/catalina/loader/WebappClassLoaderBase.java | 4 +--- java/org/apache/tomcat/websocket/server/UriTemplate.java | 5 +---- .../catalina/tribes/group/TestGroupChannelSenderConnections.java | 4 ++-- test/org/apache/catalina/tribes/membership/TestMembership.java | 4 +--- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/java/org/apache/catalina/ant/jmx/JMXAccessorQueryTask.java b/java/org/apache/catalina/ant/jmx/JMXAccessorQueryTask.java index b5761fd1bd..4f8aa81b46 100644 --- a/java/org/apache/catalina/ant/jmx/JMXAccessorQueryTask.java +++ b/java/org/apache/catalina/ant/jmx/JMXAccessorQueryTask.java @@ -17,7 +17,6 @@ package org.apache.catalina.ant.jmx; -import java.util.Iterator; import java.util.Set; import javax.management.MBeanAttributeInfo; @@ -117,11 +116,9 @@ public class JMXAccessorQueryTask extends JMXAccessorTask { } if (resultproperty != null) { - Iterator<ObjectName> it = names.iterator(); int oindex = 0; String pname = null; - while (it.hasNext()) { - ObjectName oname = it.next(); + for (ObjectName oname : names) { pname = resultproperty + "." + Integer.toString(oindex) + "."; oindex++; setProperty(pname + "Name", oname.toString()); diff --git a/java/org/apache/catalina/loader/WebappClassLoaderBase.java b/java/org/apache/catalina/loader/WebappClassLoaderBase.java index 9ef7dad1d2..2addcb83c8 100644 --- a/java/org/apache/catalina/loader/WebappClassLoaderBase.java +++ b/java/org/apache/catalina/loader/WebappClassLoaderBase.java @@ -1976,10 +1976,8 @@ public abstract class WebappClassLoaderBase extends URLClassLoader } if (o instanceof Collection<?>) { - Iterator<?> iter = ((Collection<?>) o).iterator(); try { - while (iter.hasNext()) { - Object entry = iter.next(); + for (Object entry : ((Collection<?>) o)) { if (loadedByThisOrChild(entry)) { return true; } diff --git a/java/org/apache/tomcat/websocket/server/UriTemplate.java b/java/org/apache/tomcat/websocket/server/UriTemplate.java index fd33cd34ad..f8a8ec46a8 100644 --- a/java/org/apache/tomcat/websocket/server/UriTemplate.java +++ b/java/org/apache/tomcat/websocket/server/UriTemplate.java @@ -110,12 +110,9 @@ public class UriTemplate { return null; } - Iterator<Segment> candidateSegments = - candidate.getSegments().iterator(); Iterator<Segment> targetSegments = segments.iterator(); - while (candidateSegments.hasNext()) { - Segment candidateSegment = candidateSegments.next(); + for (Segment candidateSegment : candidate.getSegments()) { Segment targetSegment = targetSegments.next(); if (targetSegment.getParameterIndex() == -1) { diff --git a/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java b/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java index 62fc35f5c5..f78644756f 100644 --- a/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java +++ b/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java @@ -97,7 +97,7 @@ public class TestGroupChannelSenderConnections extends LoggingBaseTest { @Test public void testKeepAliveCount() throws Exception { log.info("Setting keep alive count to 0"); - for (int i = 0; i < channels.length; i++) { + for (ManagedChannel channel : channels) { ReplicationTransmitter t = (ReplicationTransmitter)channels[0].getChannelSender(); t.getTransport().setKeepAliveCount(0); } @@ -107,7 +107,7 @@ public class TestGroupChannelSenderConnections extends LoggingBaseTest { @Test public void testKeepAliveTime() throws Exception { log.info("Setting keep alive count to 1 second"); - for (int i = 0; i < channels.length; i++) { + for (ManagedChannel channel : channels) { ReplicationTransmitter t = (ReplicationTransmitter)channels[0].getChannelSender(); t.getTransport().setKeepAliveTime(1000); } diff --git a/test/org/apache/catalina/tribes/membership/TestMembership.java b/test/org/apache/catalina/tribes/membership/TestMembership.java index 602859ad8d..687740ceda 100644 --- a/test/org/apache/catalina/tribes/membership/TestMembership.java +++ b/test/org/apache/catalina/tribes/membership/TestMembership.java @@ -47,10 +47,8 @@ public class TestMembership { Assert.assertFalse(original.map == clone.map); Assert.assertTrue(original.map.size() == clone.map.size()); - Iterator<Entry<Member, MbrEntry>> originalEntries = original.map.entrySet().iterator(); Iterator<Entry<Member, MbrEntry>> cloneEntries = clone.map.entrySet().iterator(); - while (originalEntries.hasNext()) { - Entry<Member, MbrEntry> originalEntry = originalEntries.next(); + for (Entry<Member, MbrEntry> originalEntry : original.map.entrySet()) { Entry<Member, MbrEntry> cloneEntry = cloneEntries.next(); Assert.assertTrue(originalEntry.getKey() == cloneEntry.getKey()); Assert.assertTrue(originalEntry.getValue() == cloneEntry.getValue()); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org