From a07d24ec3ecb9d5d43e7f329bdd772a381f90fa3 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 29 Dec 2009 02:29:41 +0000 Subject: [PATCH] Fixed issue: NETTY-267 ChannelGroupFuture.iterator() should iterate in the order where the I/O actually occurred. * Replaced HashMap with LinkedHashMap in DefaultChannelGroup and DefaultChannelGroupFuture --- .../netty/channel/group/DefaultChannelGroup.java | 16 ++++++++-------- .../channel/group/DefaultChannelGroupFuture.java | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroup.java b/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroup.java index 93bf7dcd4f..cd88b48ad5 100644 --- a/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroup.java +++ b/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroup.java @@ -19,8 +19,8 @@ import java.net.SocketAddress; import java.util.AbstractSet; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.Map; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicInteger; @@ -181,7 +181,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel public ChannelGroupFuture close() { Map futures = - new HashMap(size()); + new LinkedHashMap(size()); for (Channel c: serverChannels.values()) { futures.put(c.getId(), c.close().awaitUninterruptibly()); @@ -195,7 +195,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel public ChannelGroupFuture disconnect() { Map futures = - new HashMap(size()); + new LinkedHashMap(size()); for (Channel c: serverChannels.values()) { futures.put(c.getId(), c.disconnect().awaitUninterruptibly()); @@ -209,7 +209,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel public ChannelGroupFuture setInterestOps(int interestOps) { Map futures = - new HashMap(size()); + new LinkedHashMap(size()); for (Channel c: serverChannels.values()) { futures.put(c.getId(), c.setInterestOps(interestOps).awaitUninterruptibly()); @@ -223,7 +223,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel public ChannelGroupFuture setReadable(boolean readable) { Map futures = - new HashMap(size()); + new LinkedHashMap(size()); for (Channel c: serverChannels.values()) { futures.put(c.getId(), c.setReadable(readable).awaitUninterruptibly()); @@ -237,7 +237,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel public ChannelGroupFuture unbind() { Map futures = - new HashMap(size()); + new LinkedHashMap(size()); for (Channel c: serverChannels.values()) { futures.put(c.getId(), c.unbind().awaitUninterruptibly()); @@ -251,7 +251,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel public ChannelGroupFuture write(Object message) { Map futures = - new HashMap(size()); + new LinkedHashMap(size()); if (message instanceof ChannelBuffer) { ChannelBuffer buf = (ChannelBuffer) message; for (Channel c: this) { @@ -267,7 +267,7 @@ public class DefaultChannelGroup extends AbstractSet implements Channel public ChannelGroupFuture write(Object message, SocketAddress remoteAddress) { Map futures = - new HashMap(size()); + new LinkedHashMap(size()); if (message instanceof ChannelBuffer) { ChannelBuffer buf = (ChannelBuffer) message; for (Channel c: this) { diff --git a/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroupFuture.java b/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroupFuture.java index 148210886e..9927717bf4 100644 --- a/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroupFuture.java +++ b/src/main/java/org/jboss/netty/channel/group/DefaultChannelGroupFuture.java @@ -20,8 +20,8 @@ import static java.util.concurrent.TimeUnit.*; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -89,7 +89,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture { this.group = group; - Map futureMap = new HashMap(); + Map futureMap = new LinkedHashMap(); for (ChannelFuture f: futures) { futureMap.put(f.getChannel().getId(), f); }