activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/8] activemq-artemis git commit: for and while loop to foreach conversions
Date Thu, 25 Aug 2016 18:22:44 GMT
for and while loop to foreach conversions


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/d5242978
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/d5242978
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/d5242978

Branch: refs/heads/master
Commit: d5242978d55051ddf5b0ef245e48f851f5147f28
Parents: e1728f0
Author: Ville Skyttä <ville.skytta@iki.fi>
Authored: Thu Aug 25 13:51:18 2016 +0300
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Thu Aug 25 14:22:32 2016 -0400

----------------------------------------------------------------------
 .../activemq/artemis/utils/uri/URISchema.java   | 12 +++++------
 .../activemq/artemis/utils/uri/URISupport.java  | 10 +++++-----
 .../core/remoting/impl/ssl/SSLSupport.java      |  4 ++--
 .../artemis/utils/SecurityFormatter.java        |  4 ++--
 .../apache/activemq/artemis/utils/XMLUtil.java  |  4 ++--
 .../artemis/jms/bridge/impl/JMSBridgeImpl.java  |  5 +----
 .../core/io/mapped/MappedByteBufferCache.java   | 10 +++-------
 .../protocol/openwire/OpenWireConnection.java   | 10 +++-------
 .../openwire/OpenWireMessageConverter.java      | 10 ++--------
 .../core/protocol/stomp/StompSession.java       |  4 +---
 .../ra/ActiveMQRAManagedConnectionFactory.java  |  7 +------
 .../ra/inflow/ActiveMQActivationSpec.java       |  5 ++---
 .../selector/filter/UnaryExpression.java        |  4 +---
 .../config/ClusterConnectionConfiguration.java  |  4 ++--
 .../core/config/impl/SecurityConfiguration.java |  9 ++-------
 .../core/messagecounter/MessageCounter.java     |  4 +---
 .../impl/MessageCounterManagerImpl.java         | 19 +++---------------
 .../core/remoting/impl/netty/NettyAcceptor.java |  9 ++-------
 .../cluster/impl/ClusterConnectionBridge.java   |  8 ++++----
 .../core/security/jaas/JaasCallbackHandler.java |  3 +--
 .../spi/core/security/jaas/LDAPLoginModule.java | 14 ++++++-------
 .../amqp/client/sasl/CramMD5Mechanism.java      |  4 ++--
 .../amqp/client/util/PropertyUtil.java          | 21 +++++++++-----------
 23 files changed, 64 insertions(+), 120 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java
b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java
index 3120292..9751659 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISchema.java
@@ -106,16 +106,16 @@ public abstract class URISchema<T, P> {
          Map<String, String> rc = new HashMap<>();
          if (uri != null && !uri.isEmpty()) {
             String[] parameters = uri.split("&");
-            for (int i = 0; i < parameters.length; i++) {
-               int p = parameters[i].indexOf("=");
+            for (String parameter : parameters) {
+               int p = parameter.indexOf("=");
                if (p >= 0) {
-                  String name = BeanSupport.decodeURI(parameters[i].substring(0, p));
-                  String value = BeanSupport.decodeURI(parameters[i].substring(p + 1));
+                  String name = BeanSupport.decodeURI(parameter.substring(0, p));
+                  String value = BeanSupport.decodeURI(parameter.substring(p + 1));
                   rc.put(name, value);
                }
                else {
-                  if (!parameters[i].trim().isEmpty()) {
-                     rc.put(parameters[i], null);
+                  if (!parameter.trim().isEmpty()) {
+                     rc.put(parameter, null);
                   }
                }
             }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISupport.java
----------------------------------------------------------------------
diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISupport.java
b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISupport.java
index f3744f1..a95f810 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISupport.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/URISupport.java
@@ -135,15 +135,15 @@ public class URISupport {
 
    private static void parseParameters(Map<String, String> rc,
                                        String[] parameters) throws UnsupportedEncodingException
{
-      for (int i = 0; i < parameters.length; i++) {
-         int p = parameters[i].indexOf("=");
+      for (String parameter : parameters) {
+         int p = parameter.indexOf("=");
          if (p >= 0) {
-            String name = URLDecoder.decode(parameters[i].substring(0, p), "UTF-8");
-            String value = URLDecoder.decode(parameters[i].substring(p + 1), "UTF-8");
+            String name = URLDecoder.decode(parameter.substring(0, p), "UTF-8");
+            String value = URLDecoder.decode(parameter.substring(p + 1), "UTF-8");
             rc.put(name, value);
          }
          else {
-            rc.put(parameters[i], null);
+            rc.put(parameter, null);
          }
       }
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java
index 2b97c75..d5e0fdc 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/ssl/SSLSupport.java
@@ -67,8 +67,8 @@ public class SSLSupport {
    public static String parseArrayIntoCommandSeparatedList(String[] suites) {
       StringBuilder supportedSuites = new StringBuilder();
 
-      for (int i = 0; i < suites.length; i++) {
-         supportedSuites.append(suites[i]);
+      for (String suite : suites) {
+         supportedSuites.append(suite);
          supportedSuites.append(", ");
       }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SecurityFormatter.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SecurityFormatter.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SecurityFormatter.java
index b64cc77..90994fb 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SecurityFormatter.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/SecurityFormatter.java
@@ -65,8 +65,8 @@ public class SecurityFormatter {
          return list;
       }
       String[] values = commaSeparatedString.split(",");
-      for (int i = 0; i < values.length; i++) {
-         list.add(values[i].trim());
+      for (String value : values) {
+         list.add(value.trim());
       }
       return list;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java
index ca51c08..7a492c4 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java
@@ -366,8 +366,8 @@ public final class XMLUtil {
       for (int i = 0; i < nl.getLength(); i++) {
          Node n = nl.item(i);
          short type = n.getNodeType();
-         for (int j = 0; j < typesToFilter.length; j++) {
-            if (typesToFilter[j] == type) {
+         for (short typeToFilter : typesToFilter) {
+            if (typeToFilter == type) {
                continue outer;
             }
          }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java
----------------------------------------------------------------------
diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java
b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java
index c363651..339ebcf 100644
--- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java
+++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java
@@ -1602,11 +1602,8 @@ public final class JMSBridgeImpl implements JMSBridge {
       msg.clearProperties();
 
       if (oldProps != null) {
-         Iterator<Entry<String, Object>> oldPropsIter = oldProps.entrySet().iterator();
-
-         while (oldPropsIter.hasNext()) {
-            Entry<String, Object> entry = oldPropsIter.next();
 
+         for (Entry<String, Object> entry : oldProps.entrySet()) {
             String propName = entry.getKey();
 
             Object val = entry.getValue();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedByteBufferCache.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedByteBufferCache.java
b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedByteBufferCache.java
index d097055..5bba391 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedByteBufferCache.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedByteBufferCache.java
@@ -140,9 +140,7 @@ final class MappedByteBufferCache implements AutoCloseable {
    public void closeAndResize(long length) {
       if (!closed) {
          //TO_FIX: unmap in this way is not portable BUT required on Windows that can't resize
a memmory mapped file!
-         final int mappedBuffers = this.byteBuffers.size();
-         for (int i = 0; i < mappedBuffers; i++) {
-            final WeakReference<MappedByteBuffer> mbbRef = byteBuffers.get(i);
+         for (final WeakReference<MappedByteBuffer> mbbRef : this.byteBuffers) {
             if (mbbRef != null) {
                final MappedByteBuffer mbb = mbbRef.get();
                if (mbb != null) {
@@ -204,9 +202,7 @@ final class MappedByteBufferCache implements AutoCloseable {
    public void close() {
       if (!closed) {
          //TO_FIX: unmap in this way is not portable BUT required on Windows that can't resize
a memory mapped file!
-         final int mappedBuffers = this.byteBuffers.size();
-         for (int i = 0; i < mappedBuffers; i++) {
-            final WeakReference<MappedByteBuffer> mbbRef = byteBuffers.get(i);
+         for (final WeakReference<MappedByteBuffer> mbbRef : this.byteBuffers) {
             if (mbbRef != null) {
                final MappedByteBuffer mbb = mbbRef.get();
                if (mbb != null) {
@@ -237,4 +233,4 @@ final class MappedByteBufferCache implements AutoCloseable {
          closed = true;
       }
    }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index 8f53bdb..aeb0f2b 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -25,7 +25,6 @@ import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
@@ -764,9 +763,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements
Se
    }
 
    public void addSessions(Set<SessionId> sessionSet) {
-      Iterator<SessionId> iter = sessionSet.iterator();
-      while (iter.hasNext()) {
-         SessionId sid = iter.next();
+      for (SessionId sid : sessionSet) {
          addSession(getState().getSessionState(sid).getInfo(), true);
       }
    }
@@ -805,10 +802,9 @@ public class OpenWireConnection extends AbstractRemotingConnection implements
Se
       }
       else {
          Bindings bindings = server.getPostOffice().getBindingsForAddress(OpenWireUtil.toCoreAddress(dest));
-         Iterator<Binding> iterator = bindings.getBindings().iterator();
 
-         while (iterator.hasNext()) {
-            Queue b = (Queue) iterator.next().getBindable();
+         for (Binding binding : bindings.getBindings()) {
+            Queue b = (Queue) binding.getBindable();
             if (b.getConsumerCount() > 0) {
                throw new Exception("Destination still has an active subscription: " + dest.getPhysicalName());
             }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
index 8096b93..fd6aef2 100644
--- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
+++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireMessageConverter.java
@@ -24,7 +24,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Arrays;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
@@ -353,10 +352,7 @@ public class OpenWireMessageConverter implements MessageConverter {
          //unmarshall properties to core so selector will work
          Map<String, Object> props = messageSend.getProperties();
          //Map<String, Object> props = MarshallingSupport.unmarshalPrimitiveMap(new
DataInputStream(new ByteArrayInputStream(propBytes)));
-         Iterator<Entry<String, Object>> iterEntries = props.entrySet().iterator();
-         while (iterEntries.hasNext()) {
-            Entry<String, Object> ent = iterEntries.next();
-
+         for (Entry<String, Object> ent : props.entrySet()) {
             Object value = ent.getValue();
             try {
                coreMessage.putObjectProperty(ent.getKey(), value);
@@ -394,9 +390,7 @@ public class OpenWireMessageConverter implements MessageConverter {
    }
 
    private static void loadMapIntoProperties(TypedProperties props, Map<String, Object>
map) {
-      Iterator<Entry<String, Object>> iter = map.entrySet().iterator();
-      while (iter.hasNext()) {
-         Entry<String, Object> entry = iter.next();
+      for (Entry<String, Object> entry : map.entrySet()) {
          SimpleString key = new SimpleString(entry.getKey());
          Object value = entry.getValue();
          if (value instanceof UTF8Buffer) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java
b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java
index 1ab7c42..ba0abbf 100644
--- a/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java
+++ b/artemis-protocols/artemis-stomp-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/stomp/StompSession.java
@@ -343,9 +343,7 @@ public class StompSession implements SessionCallback {
    }
 
    boolean containsSubscription(String subscriptionID) {
-      Iterator<Entry<Long, StompSubscription>> iterator = subscriptions.entrySet().iterator();
-      while (iterator.hasNext()) {
-         Map.Entry<Long, StompSubscription> entry = iterator.next();
+      for (Entry<Long, StompSubscription> entry : subscriptions.entrySet()) {
          StompSubscription sub = entry.getValue();
          if (sub.getID().equals(subscriptionID)) {
             return true;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnectionFactory.java
----------------------------------------------------------------------
diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnectionFactory.java
b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnectionFactory.java
index a3e5f4c..c46efca 100644
--- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnectionFactory.java
+++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnectionFactory.java
@@ -27,7 +27,6 @@ import javax.resource.spi.ResourceAdapterAssociation;
 import javax.security.auth.Subject;
 import java.io.PrintWriter;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
@@ -203,11 +202,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti
          ActiveMQRALogger.LOGGER.trace("Looking for connection matching credentials: " +
credential);
       }
 
-      Iterator<?> connections = connectionSet.iterator();
-
-      while (connections.hasNext()) {
-         Object obj = connections.next();
-
+      for (Object obj : connectionSet) {
          if (obj instanceof ActiveMQRAManagedConnection) {
             ActiveMQRAManagedConnection mc = (ActiveMQRAManagedConnection) obj;
             ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java
----------------------------------------------------------------------
diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java
b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java
index 61dc37a..4d8b18f 100644
--- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java
+++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java
@@ -28,7 +28,6 @@ import java.beans.PropertyDescriptor;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.activemq.artemis.ra.ConnectionFactoryProperties;
@@ -722,9 +721,9 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties
implemen
       if (propsNotSet.size() > 0) {
          StringBuffer b = new StringBuffer();
          b.append("Invalid settings:");
-         for (Iterator<String> iter = errorMessages.iterator(); iter.hasNext(); ) {
+         for (String errorMessage : errorMessages) {
             b.append(" ");
-            b.append(iter.next());
+            b.append(errorMessage);
          }
          InvalidPropertyException e = new InvalidPropertyException(b.toString());
          final PropertyDescriptor[] descriptors = propsNotSet.toArray(new PropertyDescriptor[propsNotSet.size()]);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/UnaryExpression.java
----------------------------------------------------------------------
diff --git a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/UnaryExpression.java
b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/UnaryExpression.java
index e0853c6..ecdcf23 100755
--- a/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/UnaryExpression.java
+++ b/artemis-selector/src/main/java/org/apache/activemq/artemis/selector/filter/UnaryExpression.java
@@ -19,7 +19,6 @@ package org.apache.activemq.artemis.selector.filter;
 import java.math.BigDecimal;
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -98,8 +97,7 @@ public abstract class UnaryExpression implements Expression {
             answer.append(" ( ");
 
             int count = 0;
-            for (Iterator<Object> i = inList.iterator(); i.hasNext(); ) {
-               Object o = i.next();
+            for (Object o : inList) {
                if (count != 0) {
                   answer.append(", ");
                }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ClusterConnectionConfiguration.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ClusterConnectionConfiguration.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ClusterConnectionConfiguration.java
index 3f57782..90c9db5 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ClusterConnectionConfiguration.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/ClusterConnectionConfiguration.java
@@ -382,8 +382,8 @@ public final class ClusterConnectionConfiguration implements Serializable
{
 
          List<TransportConfiguration> list = new LinkedList<>();
 
-         for (int i = 0; i < members.length; i++) {
-            list.addAll(connectorTransportConfigurationParser.newObject(members[i], null));
+         for (URI member : members) {
+            list.addAll(connectorTransportConfigurationParser.newObject(member, null));
          }
 
          return list.toArray(new TransportConfiguration[list.size()]);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/SecurityConfiguration.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/SecurityConfiguration.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/SecurityConfiguration.java
index 3325d5d..76b814d 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/SecurityConfiguration.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/SecurityConfiguration.java
@@ -25,7 +25,6 @@ import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule;
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -47,14 +46,10 @@ public class SecurityConfiguration extends Configuration {
    }
 
    public SecurityConfiguration(Map<String, String> users, Map<String, List<String>>
roles) {
-      Iterator<Map.Entry<String, String>> iter = users.entrySet().iterator();
-      while (iter.hasNext()) {
-         Map.Entry<String, String> entry = iter.next();
+      for (Map.Entry<String, String> entry : users.entrySet()) {
          addUser(entry.getKey(), entry.getValue());
       }
-      Iterator<Map.Entry<String, List<String>>> iter1 = roles.entrySet().iterator();
-      while (iter1.hasNext()) {
-         Map.Entry<String, List<String>> entry = iter1.next();
+      for (Map.Entry<String, List<String>> entry : roles.entrySet()) {
          for (String role : entry.getValue()) {
             addRole(entry.getKey(), role);
          }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java
index 1d91279..9ceb8ea 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/MessageCounter.java
@@ -288,9 +288,7 @@ public class MessageCounter {
          ret.append(dayCounters.size() + "\n");
 
          // following lines: day counter data
-         for (int i = 0; i < dayCounters.size(); i++) {
-            DayCounter counter = dayCounters.get(i);
-
+         for (DayCounter counter : dayCounters) {
             ret.append(counter.getDayCounterAsString() + "\n");
          }
       }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterManagerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterManagerImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterManagerImpl.java
index 1183ce5..0f60cf6 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterManagerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/messagecounter/impl/MessageCounterManagerImpl.java
@@ -18,7 +18,6 @@ package org.apache.activemq.artemis.core.messagecounter.impl;
 
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Future;
@@ -141,11 +140,7 @@ public class MessageCounterManagerImpl implements MessageCounterManager
{
    @Override
    public void resetAllCounters() {
       synchronized (messageCounters) {
-         Iterator<MessageCounter> iter = messageCounters.values().iterator();
-
-         while (iter.hasNext()) {
-            MessageCounter counter = iter.next();
-
+         for (MessageCounter counter : messageCounters.values()) {
             counter.resetCounter();
          }
       }
@@ -154,11 +149,7 @@ public class MessageCounterManagerImpl implements MessageCounterManager
{
    @Override
    public void resetAllCounterHistories() {
       synchronized (messageCounters) {
-         Iterator<MessageCounter> iter = messageCounters.values().iterator();
-
-         while (iter.hasNext()) {
-            MessageCounter counter = iter.next();
-
+         for (MessageCounter counter : messageCounters.values()) {
             counter.resetHistory();
          }
       }
@@ -177,11 +168,7 @@ public class MessageCounterManagerImpl implements MessageCounterManager
{
          }
 
          synchronized (messageCounters) {
-            Iterator<MessageCounter> iter = messageCounters.values().iterator();
-
-            while (iter.hasNext()) {
-               MessageCounter counter = iter.next();
-
+            for (MessageCounter counter : messageCounters.values()) {
                counter.onTimer();
             }
          }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
index 783f4ac..8cff70b 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
@@ -26,7 +26,6 @@ import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -513,9 +512,7 @@ public class NettyAcceptor extends AbstractAcceptor {
 
          if (!future.isSuccess()) {
             ActiveMQServerLogger.LOGGER.nettyChannelGroupError();
-            Iterator<Channel> iterator = future.group().iterator();
-            while (iterator.hasNext()) {
-               Channel channel = iterator.next();
+            for (Channel channel : future.group()) {
                if (channel.isActive()) {
                   ActiveMQServerLogger.LOGGER.nettyChannelStillOpen(channel, channel.remoteAddress());
                }
@@ -573,9 +570,7 @@ public class NettyAcceptor extends AbstractAcceptor {
          ChannelGroupFuture future = serverChannelGroup.close().awaitUninterruptibly();
          if (!future.isSuccess()) {
             ActiveMQServerLogger.LOGGER.nettyChannelGroupBindError();
-            Iterator<Channel> iterator = future.group().iterator();
-            while (iterator.hasNext()) {
-               Channel channel = iterator.next();
+            for (Channel channel : future.group()) {
                if (channel.isActive()) {
                   ActiveMQServerLogger.LOGGER.nettyChannelStillBound(channel, channel.remoteAddress());
                }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java
index a8c87b9..425e26a 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java
@@ -295,12 +295,12 @@ public class ClusterConnectionBridge extends BridgeImpl {
       List<String> excludes = new ArrayList<>();
 
       // Split the list into addresses to match and addresses to exclude.
-      for (int i = 0; i < list.length; i++) {
-         if (list[i].startsWith("!")) {
-            excludes.add(list[i].substring(1, list[i].length()));
+      for (String s : list) {
+         if (s.startsWith("!")) {
+            excludes.add(s.substring(1, s.length()));
          }
          else {
-            includes.add(list[i]);
+            includes.add(s);
          }
       }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/JaasCallbackHandler.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/JaasCallbackHandler.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/JaasCallbackHandler.java
index 71a6172..97beffa 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/JaasCallbackHandler.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/JaasCallbackHandler.java
@@ -41,8 +41,7 @@ public class JaasCallbackHandler implements CallbackHandler {
 
    @Override
    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
-      for (int i = 0; i < callbacks.length; i++) {
-         Callback callback = callbacks[i];
+      for (Callback callback : callbacks) {
          if (callback instanceof PasswordCallback) {
             PasswordCallback passwordCallback = (PasswordCallback) callback;
             if (password == null) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java
index 8bb5405..942b328 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java
@@ -274,8 +274,8 @@ public class LDAPLoginModule implements LoginModule {
             if (logger.isDebugEnabled()) {
                logger.debug("Roles " + roles + " for user " + username);
             }
-            for (int i = 0; i < roles.size(); i++) {
-               groups.add(new RolePrincipal(roles.get(i)));
+            for (String role : roles) {
+               groups.add(new RolePrincipal(role));
             }
          }
          else {
@@ -488,15 +488,15 @@ public class LDAPLoginModule implements LoginModule {
    }
 
    private String getLDAPPropertyValue(String propertyName) {
-      for (int i = 0; i < config.length; i++)
-         if (config[i].getPropertyName().equals(propertyName))
-            return config[i].getPropertyValue();
+      for (LDAPLoginProperty conf : config)
+         if (conf.getPropertyName().equals(propertyName))
+            return conf.getPropertyValue();
       return null;
    }
 
    private boolean isLoginPropertySet(String propertyName) {
-      for (int i = 0; i < config.length; i++) {
-         if (config[i].getPropertyName().equals(propertyName) && (config[i].getPropertyValue()
!= null && !"".equals(config[i].getPropertyValue())))
+      for (LDAPLoginProperty conf : config) {
+         if (conf.getPropertyName().equals(propertyName) && (conf.getPropertyValue()
!= null && !"".equals(conf.getPropertyValue())))
             return true;
       }
       return false;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/CramMD5Mechanism.java
----------------------------------------------------------------------
diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/CramMD5Mechanism.java
b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/CramMD5Mechanism.java
index 4821314..a7c8858 100644
--- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/CramMD5Mechanism.java
+++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/sasl/CramMD5Mechanism.java
@@ -61,8 +61,8 @@ public class CramMD5Mechanism extends AbstractMechanism {
 
             StringBuffer hash = new StringBuffer(getUsername());
             hash.append(' ');
-            for (int i = 0; i < bytes.length; i++) {
-               String hex = Integer.toHexString(0xFF & bytes[i]);
+            for (byte b : bytes) {
+               String hex = Integer.toHexString(0xFF & b);
                if (hex.length() == 1) {
                   hash.append('0');
                }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d5242978/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/PropertyUtil.java
----------------------------------------------------------------------
diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/PropertyUtil.java
b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/PropertyUtil.java
index 1285a0f..20979a8 100644
--- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/PropertyUtil.java
+++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/PropertyUtil.java
@@ -172,15 +172,15 @@ public class PropertyUtil {
       if (queryString != null && !queryString.isEmpty()) {
          Map<String, String> rc = new HashMap<>();
          String[] parameters = queryString.split("&");
-         for (int i = 0; i < parameters.length; i++) {
-            int p = parameters[i].indexOf("=");
+         for (String parameter : parameters) {
+            int p = parameter.indexOf("=");
             if (p >= 0) {
-               String name = URLDecoder.decode(parameters[i].substring(0, p), "UTF-8");
-               String value = URLDecoder.decode(parameters[i].substring(p + 1), "UTF-8");
+               String name = URLDecoder.decode(parameter.substring(0, p), "UTF-8");
+               String value = URLDecoder.decode(parameter.substring(p + 1), "UTF-8");
                rc.put(name, value);
             }
             else {
-               rc.put(parameters[i], null);
+               rc.put(parameter, null);
             }
          }
          return rc;
@@ -352,8 +352,7 @@ public class PropertyUtil {
       Object[] NULL_ARG = {};
       PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
       if (propertyDescriptors != null) {
-         for (int i = 0; i < propertyDescriptors.length; i++) {
-            PropertyDescriptor pd = propertyDescriptors[i];
+         for (PropertyDescriptor pd : propertyDescriptors) {
             if (pd.getReadMethod() != null && !pd.getName().equals("class") &&
!pd.getName().equals("properties") && !pd.getName().equals("reference")) {
                Object value = pd.getReadMethod().invoke(object, NULL_ARG);
                if (value != null) {
@@ -365,7 +364,7 @@ public class PropertyUtil {
                   }
                   else {
                      Map<String, String> inner = getProperties(value);
-                     for (Map.Entry<String, String> entry : inner.entrySet()) {
+                     for (Entry<String, String> entry : inner.entrySet()) {
                         properties.put(pd.getName() + "." + entry.getKey(), entry.getValue());
                      }
                   }
@@ -389,8 +388,7 @@ public class PropertyUtil {
       BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass());
       PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
       if (propertyDescriptors != null) {
-         for (int i = 0; i < propertyDescriptors.length; i++) {
-            PropertyDescriptor pd = propertyDescriptors[i];
+         for (PropertyDescriptor pd : propertyDescriptors) {
             if (pd.getReadMethod() != null && pd.getName().equals(name)) {
                return pd.getReadMethod().invoke(object);
             }
@@ -497,8 +495,7 @@ public class PropertyUtil {
       // Build the method name.
       name = "set" + name.substring(0, 1).toUpperCase() + name.substring(1);
       Method[] methods = clazz.getMethods();
-      for (int i = 0; i < methods.length; i++) {
-         Method method = methods[i];
+      for (Method method : methods) {
          Class<?>[] params = method.getParameterTypes();
          if (method.getName().equals(name) && params.length == 1) {
             return method;


Mime
View raw message