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
This commit is contained in:
Trustin Lee 2009-12-29 02:29:41 +00:00
parent 0314234a41
commit a07d24ec3e
2 changed files with 10 additions and 10 deletions

View File

@ -19,8 +19,8 @@ import java.net.SocketAddress;
import java.util.AbstractSet; import java.util.AbstractSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -181,7 +181,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
public ChannelGroupFuture close() { public ChannelGroupFuture close() {
Map<Integer, ChannelFuture> futures = Map<Integer, ChannelFuture> futures =
new HashMap<Integer, ChannelFuture>(size()); new LinkedHashMap<Integer, ChannelFuture>(size());
for (Channel c: serverChannels.values()) { for (Channel c: serverChannels.values()) {
futures.put(c.getId(), c.close().awaitUninterruptibly()); futures.put(c.getId(), c.close().awaitUninterruptibly());
@ -195,7 +195,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
public ChannelGroupFuture disconnect() { public ChannelGroupFuture disconnect() {
Map<Integer, ChannelFuture> futures = Map<Integer, ChannelFuture> futures =
new HashMap<Integer, ChannelFuture>(size()); new LinkedHashMap<Integer, ChannelFuture>(size());
for (Channel c: serverChannels.values()) { for (Channel c: serverChannels.values()) {
futures.put(c.getId(), c.disconnect().awaitUninterruptibly()); futures.put(c.getId(), c.disconnect().awaitUninterruptibly());
@ -209,7 +209,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
public ChannelGroupFuture setInterestOps(int interestOps) { public ChannelGroupFuture setInterestOps(int interestOps) {
Map<Integer, ChannelFuture> futures = Map<Integer, ChannelFuture> futures =
new HashMap<Integer, ChannelFuture>(size()); new LinkedHashMap<Integer, ChannelFuture>(size());
for (Channel c: serverChannels.values()) { for (Channel c: serverChannels.values()) {
futures.put(c.getId(), c.setInterestOps(interestOps).awaitUninterruptibly()); futures.put(c.getId(), c.setInterestOps(interestOps).awaitUninterruptibly());
@ -223,7 +223,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
public ChannelGroupFuture setReadable(boolean readable) { public ChannelGroupFuture setReadable(boolean readable) {
Map<Integer, ChannelFuture> futures = Map<Integer, ChannelFuture> futures =
new HashMap<Integer, ChannelFuture>(size()); new LinkedHashMap<Integer, ChannelFuture>(size());
for (Channel c: serverChannels.values()) { for (Channel c: serverChannels.values()) {
futures.put(c.getId(), c.setReadable(readable).awaitUninterruptibly()); futures.put(c.getId(), c.setReadable(readable).awaitUninterruptibly());
@ -237,7 +237,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
public ChannelGroupFuture unbind() { public ChannelGroupFuture unbind() {
Map<Integer, ChannelFuture> futures = Map<Integer, ChannelFuture> futures =
new HashMap<Integer, ChannelFuture>(size()); new LinkedHashMap<Integer, ChannelFuture>(size());
for (Channel c: serverChannels.values()) { for (Channel c: serverChannels.values()) {
futures.put(c.getId(), c.unbind().awaitUninterruptibly()); futures.put(c.getId(), c.unbind().awaitUninterruptibly());
@ -251,7 +251,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
public ChannelGroupFuture write(Object message) { public ChannelGroupFuture write(Object message) {
Map<Integer, ChannelFuture> futures = Map<Integer, ChannelFuture> futures =
new HashMap<Integer, ChannelFuture>(size()); new LinkedHashMap<Integer, ChannelFuture>(size());
if (message instanceof ChannelBuffer) { if (message instanceof ChannelBuffer) {
ChannelBuffer buf = (ChannelBuffer) message; ChannelBuffer buf = (ChannelBuffer) message;
for (Channel c: this) { for (Channel c: this) {
@ -267,7 +267,7 @@ public class DefaultChannelGroup extends AbstractSet<Channel> implements Channel
public ChannelGroupFuture write(Object message, SocketAddress remoteAddress) { public ChannelGroupFuture write(Object message, SocketAddress remoteAddress) {
Map<Integer, ChannelFuture> futures = Map<Integer, ChannelFuture> futures =
new HashMap<Integer, ChannelFuture>(size()); new LinkedHashMap<Integer, ChannelFuture>(size());
if (message instanceof ChannelBuffer) { if (message instanceof ChannelBuffer) {
ChannelBuffer buf = (ChannelBuffer) message; ChannelBuffer buf = (ChannelBuffer) message;
for (Channel c: this) { for (Channel c: this) {

View File

@ -20,8 +20,8 @@ import static java.util.concurrent.TimeUnit.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -89,7 +89,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
this.group = group; this.group = group;
Map<Integer, ChannelFuture> futureMap = new HashMap<Integer, ChannelFuture>(); Map<Integer, ChannelFuture> futureMap = new LinkedHashMap<Integer, ChannelFuture>();
for (ChannelFuture f: futures) { for (ChannelFuture f: futures) {
futureMap.put(f.getChannel().getId(), f); futureMap.put(f.getChannel().getId(), f);
} }