Merge pull request #1260 from levrun/enhanced_for_loop_transport_connection

for loop can be replaced with enhanced for
This commit is contained in:
JB Onofré 2024-07-13 06:50:30 +02:00 committed by GitHub
commit 95af27c512
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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();