3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-30 23:02:15 +00:00

Fix FakeChannelSink so events are put into the queue in the right order (BEFORE running event handlers, not after).

This commit is contained in:
Mike Hearn 2012-12-06 15:01:40 +01:00
parent 7bfef81664
commit e20c35bf50

View File

@ -1,18 +1,19 @@
package com.google.bitcoin.core;
import static org.jboss.netty.channel.Channels.fireChannelConnected;
import org.jboss.netty.channel.*;
import static org.jboss.netty.channel.Channels.fireChannelConnected;
public class FakeChannelSink extends AbstractChannelSink {
public void eventSunk(ChannelPipeline pipeline, ChannelEvent e)
throws Exception {
public void eventSunk(ChannelPipeline pipeline, ChannelEvent e) throws Exception {
if (e instanceof ChannelStateEvent) {
ChannelStateEvent event = (ChannelStateEvent) e;
FakeChannel channel =
(FakeChannel) event.getChannel();
FakeChannel channel = (FakeChannel) event.getChannel();
boolean offered = channel.events.offer(event);
assert offered;
ChannelFuture future = event.getFuture();
ChannelState state = event.getState();
Object value = event.getValue();
@ -42,8 +43,6 @@ public class FakeChannelSink extends AbstractChannelSink {
future.setSuccess();
break;
}
boolean offered = channel.events.offer(event);
assert offered;
} else if (e instanceof MessageEvent) {
MessageEvent event = (MessageEvent) e;
FakeChannel channel = (FakeChannel) event.getChannel();