AMQ-9550 for loop can be replaced with enhanced for connection manager adapter

This commit is contained in:
Aleksei Eraskin 2024-08-16 21:37:40 -07:00
parent e45ee4aae5
commit f4c5b9dfb3
1 changed files with 2 additions and 5 deletions

View File

@ -17,7 +17,6 @@
package org.apache.activemq.ra; package org.apache.activemq.ra;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import jakarta.resource.ResourceException; import jakarta.resource.ResourceException;
import jakarta.resource.spi.ConnectionEvent; import jakarta.resource.spi.ConnectionEvent;
@ -50,8 +49,7 @@ public class ConnectionManagerAdapter implements ConnectionManager, ConnectionEv
* @param l * @param l
*/ */
public void addConnectionEventListener(ConnectionEventListener l) { public void addConnectionEventListener(ConnectionEventListener l) {
for (Iterator<ManagedConnection> iter = connections.iterator(); iter.hasNext();) { for (ManagedConnection c : connections) {
ManagedConnection c = iter.next();
c.addConnectionEventListener(l); c.addConnectionEventListener(l);
} }
listners.add(l); listners.add(l);
@ -66,8 +64,7 @@ public class ConnectionManagerAdapter implements ConnectionManager, ConnectionEv
Subject subject = null; Subject subject = null;
ManagedConnection connection = connectionFactory.createManagedConnection(subject, info); ManagedConnection connection = connectionFactory.createManagedConnection(subject, info);
connection.addConnectionEventListener(this); connection.addConnectionEventListener(this);
for (Iterator<ConnectionEventListener> iter = listners.iterator(); iter.hasNext();) { for (ConnectionEventListener l : listners) {
ConnectionEventListener l = iter.next();
connection.addConnectionEventListener(l); connection.addConnectionEventListener(l);
} }
connections.add(connection); connections.add(connection);