for loop can be replaced with enhanced for

This commit is contained in:
Aleksei Eraskin 2024-07-12 16:44:09 -07:00
parent 4e3084d9bb
commit d00cbe5b5c
1 changed files with 2 additions and 4 deletions

View File

@ -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<Command> 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<TransportConnection> connections = this.connector.getConnections();
synchronized (connections) {
for (Iterator<TransportConnection> 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();