Fixed a bug where DefaultChannelGroupFuture is never completed when the specified future map is empty

This commit is contained in:
Trustin Lee 2008-12-17 09:35:42 +00:00
parent c3e72364ce
commit 6602f13329

View File

@ -102,9 +102,15 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
} }
this.futures = Collections.unmodifiableMap(futureMap); this.futures = Collections.unmodifiableMap(futureMap);
for (ChannelFuture f: this.futures.values()) { for (ChannelFuture f: this.futures.values()) {
f.addListener(childListener); f.addListener(childListener);
} }
// Done on arrival?
if (this.futures.isEmpty()) {
setDone();
}
} }
DefaultChannelGroupFuture(ChannelGroup group, Map<UUID, ChannelFuture> futures) { DefaultChannelGroupFuture(ChannelGroup group, Map<UUID, ChannelFuture> futures) {
@ -113,6 +119,11 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
for (ChannelFuture f: this.futures.values()) { for (ChannelFuture f: this.futures.values()) {
f.addListener(childListener); f.addListener(childListener);
} }
// Done on arrival?
if (this.futures.isEmpty()) {
setDone();
}
} }
public ChannelGroup getGroup() { public ChannelGroup getGroup() {
@ -140,11 +151,11 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
} }
public synchronized boolean isPartialSuccess() { public synchronized boolean isPartialSuccess() {
return successCount != 0; return !futures.isEmpty() && successCount != 0;
} }
public synchronized boolean isPartialFailure() { public synchronized boolean isPartialFailure() {
return failureCount != 0; return !futures.isEmpty() && failureCount != 0;
} }
public synchronized boolean isCompleteFailure() { public synchronized boolean isCompleteFailure() {