From d00cbe5b5cd21acb3ac31e54f70db9fd44039c40 Mon Sep 17 00:00:00 2001 From: Aleksei Eraskin Date: Fri, 12 Jul 2024 16:44:09 -0700 Subject: [PATCH] for loop can be replaced with enhanced for --- .../org/apache/activemq/broker/TransportConnection.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java b/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java index cc745c48fc..9079e24d67 100644 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java @@ -1214,8 +1214,7 @@ public class TransportConnection implements Connection, Task, CommandVisitor { // Run the MessageDispatch callbacks so that message references get // cleaned up. synchronized (dispatchQueue) { - for (Iterator iter = dispatchQueue.iterator(); iter.hasNext(); ) { - Command command = iter.next(); + for (Command command : dispatchQueue) { if (command.isMessageDispatch()) { MessageDispatch md = (MessageDispatch) command; TransmitCallback sub = md.getTransmitCallback(); @@ -1421,8 +1420,7 @@ public class TransportConnection implements Connection, Task, CommandVisitor { String duplexNetworkConnectorId = config.getName() + "@" + info.getBrokerId(); CopyOnWriteArrayList connections = this.connector.getConnections(); synchronized (connections) { - for (Iterator iter = connections.iterator(); iter.hasNext(); ) { - TransportConnection c = iter.next(); + for (TransportConnection c : connections) { if ((c != this) && (duplexNetworkConnectorId.equals(c.getDuplexNetworkConnectorId()))) { LOG.warn("Stopping an existing active duplex connection [{}] for network connector ({}).", c, duplexNetworkConnectorId); c.stopAsync();