From b9039eaa82e5651a4eeb444954cacbe64fff8b73 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 25 Apr 2014 14:00:04 +0900 Subject: [PATCH] Synchronized between 4.1 and master again (part 2) Motivation: 4 and 5 were diverged long time ago and we recently reverted some of the early commits in master. We must make sure 4.1 and master are not very different now. Modification: Remove ChannelHandlerInvoker.writeAndFlush(...) and the related implementations. Result: 4.1 and master got closer. --- .../netty/util/concurrent/EventExecutor.java | 4 +- .../io/netty/example/uptime/UptimeClient.java | 2 +- .../netty/handler/traffic/package-info.java | 2 +- .../channel/epoll/EpollSocketChannel.java | 2 +- .../netty/channel/rxtx/RxtxChannelOption.java | 1 - .../netty/channel/sctp/SctpChannelConfig.java | 5 +- .../nio/NioUdtMessageRendezvousChannel.java | 4 +- .../netty/channel/udt/nio/NioUdtProvider.java | 57 +++++++++---------- .../main/java/io/netty/channel/Channel.java | 1 + .../netty/channel/ChannelHandlerAppender.java | 3 + .../netty/channel/ChannelHandlerContext.java | 54 +++++++++--------- .../netty/channel/ChannelHandlerInvoker.java | 2 +- .../channel/embedded/EmbeddedEventLoop.java | 10 ++-- .../socket/DefaultDatagramChannelConfig.java | 1 + .../channel/socket/nio/NioSocketChannel.java | 2 +- .../channel/SingleThreadEventLoopTest.java | 3 +- .../local/LocalTransportThreadModelTest.java | 15 ++++- 17 files changed, 90 insertions(+), 78 deletions(-) diff --git a/common/src/main/java/io/netty/util/concurrent/EventExecutor.java b/common/src/main/java/io/netty/util/concurrent/EventExecutor.java index f5a4341689..96fb747987 100644 --- a/common/src/main/java/io/netty/util/concurrent/EventExecutor.java +++ b/common/src/main/java/io/netty/util/concurrent/EventExecutor.java @@ -65,14 +65,14 @@ public interface EventExecutor extends EventExecutorGroup { ProgressivePromise newProgressivePromise(); /** - * Create a new {@link Future} which is marked as successes already. So {@link Future#isSuccess()} + * Create a new {@link Future} which is marked as succeeded already. So {@link Future#isSuccess()} * will return {@code true}. All {@link FutureListener} added to it will be notified directly. Also * every call of blocking methods will just return without blocking. */ Future newSucceededFuture(V result); /** - * Create a new {@link Future} which is marked as fakued already. So {@link Future#isSuccess()} + * Create a new {@link Future} which is marked as failed already. So {@link Future#isSuccess()} * will return {@code false}. All {@link FutureListener} added to it will be notified directly. Also * every call of blocking methods will just return without blocking. */ diff --git a/example/src/main/java/io/netty/example/uptime/UptimeClient.java b/example/src/main/java/io/netty/example/uptime/UptimeClient.java index ddcca409d2..97db6116d8 100644 --- a/example/src/main/java/io/netty/example/uptime/UptimeClient.java +++ b/example/src/main/java/io/netty/example/uptime/UptimeClient.java @@ -18,8 +18,8 @@ package io.netty.example.uptime; import io.netty.bootstrap.Bootstrap; import io.netty.channel.ChannelInitializer; import io.netty.channel.EventLoopGroup; -import io.netty.channel.socket.SocketChannel; import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.handler.timeout.IdleStateHandler; diff --git a/handler/src/main/java/io/netty/handler/traffic/package-info.java b/handler/src/main/java/io/netty/handler/traffic/package-info.java index 9ef1c58a1f..86bac786dd 100644 --- a/handler/src/main/java/io/netty/handler/traffic/package-info.java +++ b/handler/src/main/java/io/netty/handler/traffic/package-info.java @@ -30,7 +30,7 @@ *
  • {@link io.netty.handler.traffic.AbstractTrafficShapingHandler}: this abstract class implements * the kernel of traffic shaping. It could be extended to fit your needs. Two classes are proposed as default * implementations: see {@link io.netty.handler.traffic.ChannelTrafficShapingHandler} and - * see {@link io.netty.handler.traffic.GlobalTrafficShapingHandler} respectively for Channel traffic shaping and + * {@link io.netty.handler.traffic.GlobalTrafficShapingHandler} respectively for Channel traffic shaping and * global traffic shaping.
  • *

    * diff --git a/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollSocketChannel.java b/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollSocketChannel.java index 346d63e548..7ff6c2bac1 100644 --- a/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollSocketChannel.java +++ b/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollSocketChannel.java @@ -66,7 +66,7 @@ public final class EpollSocketChannel extends AbstractEpollChannel implements So private volatile boolean inputShutdown; private volatile boolean outputShutdown; - EpollSocketChannel(Channel parent, int fd) throws IOException { + EpollSocketChannel(Channel parent, int fd) { super(parent, fd, Native.EPOLLIN, true); config = new EpollSocketChannelConfig(this); // Directly cache the remote and local addresses diff --git a/transport-rxtx/src/main/java/io/netty/channel/rxtx/RxtxChannelOption.java b/transport-rxtx/src/main/java/io/netty/channel/rxtx/RxtxChannelOption.java index 8d76822e98..3d51f13fed 100644 --- a/transport-rxtx/src/main/java/io/netty/channel/rxtx/RxtxChannelOption.java +++ b/transport-rxtx/src/main/java/io/netty/channel/rxtx/RxtxChannelOption.java @@ -25,7 +25,6 @@ import static io.netty.channel.ChannelOption.*; /** * Option for configuring a serial port connection */ - public final class RxtxChannelOption { private static final Class T = RxtxChannelOption.class; diff --git a/transport-sctp/src/main/java/io/netty/channel/sctp/SctpChannelConfig.java b/transport-sctp/src/main/java/io/netty/channel/sctp/SctpChannelConfig.java index 5602a2edc5..206f1cdc04 100644 --- a/transport-sctp/src/main/java/io/netty/channel/sctp/SctpChannelConfig.java +++ b/transport-sctp/src/main/java/io/netty/channel/sctp/SctpChannelConfig.java @@ -18,6 +18,7 @@ package io.netty.channel.sctp; import com.sun.nio.sctp.SctpStandardSocketOptions.InitMaxStreams; import io.netty.buffer.ByteBufAllocator; import io.netty.channel.ChannelConfig; +import io.netty.channel.ChannelOption; import io.netty.channel.MessageSizeEstimator; import io.netty.channel.RecvByteBufAllocator; @@ -33,9 +34,9 @@ import io.netty.channel.RecvByteBufAllocator; * * NameAssociated setter method * - * {@link io.netty.channel.ChannelOption#SO_RCVBUF}{@link #setReceiveBufferSize(int)} + * {@link ChannelOption#SO_RCVBUF}{@link #setReceiveBufferSize(int)} * - * {@link io.netty.channel.ChannelOption#SO_SNDBUF}{@link #setSendBufferSize(int)} + * {@link ChannelOption#SO_SNDBUF}{@link #setSendBufferSize(int)} * * {@link SctpChannelOption#SCTP_NODELAY}{@link #setSctpNoDelay(boolean)}} * diff --git a/transport-udt/src/main/java/io/netty/channel/udt/nio/NioUdtMessageRendezvousChannel.java b/transport-udt/src/main/java/io/netty/channel/udt/nio/NioUdtMessageRendezvousChannel.java index b16e119b9f..cade594f18 100644 --- a/transport-udt/src/main/java/io/netty/channel/udt/nio/NioUdtMessageRendezvousChannel.java +++ b/transport-udt/src/main/java/io/netty/channel/udt/nio/NioUdtMessageRendezvousChannel.java @@ -23,11 +23,9 @@ import io.netty.channel.udt.UdtMessage; *

    * Note: send/receive must use {@link UdtMessage} in the pipeline */ -public class NioUdtMessageRendezvousChannel extends - NioUdtMessageConnectorChannel { +public class NioUdtMessageRendezvousChannel extends NioUdtMessageConnectorChannel { public NioUdtMessageRendezvousChannel() { super(NioUdtProvider.newRendezvousChannelUDT(TypeUDT.DATAGRAM)); } - } diff --git a/transport-udt/src/main/java/io/netty/channel/udt/nio/NioUdtProvider.java b/transport-udt/src/main/java/io/netty/channel/udt/nio/NioUdtProvider.java index c2c8d00172..22eca7555c 100644 --- a/transport-udt/src/main/java/io/netty/channel/udt/nio/NioUdtProvider.java +++ b/transport-udt/src/main/java/io/netty/channel/udt/nio/NioUdtProvider.java @@ -201,35 +201,35 @@ public final class NioUdtProvider implements ChannelFactor @Override public T newChannel() { switch (kind) { - case ACCEPTOR: - switch (type) { - case DATAGRAM: - return (T) new NioUdtMessageAcceptorChannel(); - case STREAM: - return (T) new NioUdtByteAcceptorChannel(); + case ACCEPTOR: + switch (type) { + case DATAGRAM: + return (T) new NioUdtMessageAcceptorChannel(); + case STREAM: + return (T) new NioUdtByteAcceptorChannel(); + default: + throw new IllegalStateException("wrong type=" + type); + } + case CONNECTOR: + switch (type) { + case DATAGRAM: + return (T) new NioUdtMessageConnectorChannel(); + case STREAM: + return (T) new NioUdtByteConnectorChannel(); + default: + throw new IllegalStateException("wrong type=" + type); + } + case RENDEZVOUS: + switch (type) { + case DATAGRAM: + return (T) new NioUdtMessageRendezvousChannel(); + case STREAM: + return (T) new NioUdtByteRendezvousChannel(); + default: + throw new IllegalStateException("wrong type=" + type); + } default: - throw new IllegalStateException("wrong type=" + type); - } - case CONNECTOR: - switch (type) { - case DATAGRAM: - return (T) new NioUdtMessageConnectorChannel(); - case STREAM: - return (T) new NioUdtByteConnectorChannel(); - default: - throw new IllegalStateException("wrong type=" + type); - } - case RENDEZVOUS: - switch (type) { - case DATAGRAM: - return (T) new NioUdtMessageRendezvousChannel(); - case STREAM: - return (T) new NioUdtByteRendezvousChannel(); - default: - throw new IllegalStateException("wrong type=" + type); - } - default: - throw new IllegalStateException("wrong kind=" + kind); + throw new IllegalStateException("wrong kind=" + kind); } } @@ -239,5 +239,4 @@ public final class NioUdtProvider implements ChannelFactor public TypeUDT type() { return type; } - } diff --git a/transport/src/main/java/io/netty/channel/Channel.java b/transport/src/main/java/io/netty/channel/Channel.java index e6758dd270..ad4af39626 100644 --- a/transport/src/main/java/io/netty/channel/Channel.java +++ b/transport/src/main/java/io/netty/channel/Channel.java @@ -436,6 +436,7 @@ public interface Channel extends AttributeMap, Comparable { *

  • {@link #remoteAddress()}
  • *
  • {@link #closeForcibly()}
  • *
  • {@link #register(EventLoop, ChannelPromise)}
  • + *
  • {@link #deregister(ChannelPromise)}
  • *
  • {@link #voidPromise()}
  • * */ diff --git a/transport/src/main/java/io/netty/channel/ChannelHandlerAppender.java b/transport/src/main/java/io/netty/channel/ChannelHandlerAppender.java index 57531f37f9..a4607b7c74 100644 --- a/transport/src/main/java/io/netty/channel/ChannelHandlerAppender.java +++ b/transport/src/main/java/io/netty/channel/ChannelHandlerAppender.java @@ -192,6 +192,9 @@ public class ChannelHandlerAppender extends ChannelInboundHandlerAdapter { } else { name = e.name; } + + // Note that we do not use dctx.invoker() because it raises an IllegalStateExxception + // if the Channel is not registered yet. pipeline.addAfter(dctx.invoker, oldName, name, e.handler); } } finally { diff --git a/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java b/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java index 0fbb7e1d7c..c45c60fc1e 100644 --- a/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java +++ b/transport/src/main/java/io/netty/channel/ChannelHandlerContext.java @@ -101,7 +101,7 @@ import java.nio.channels.Channels; * a = 1; * } * - * attr.set(a * (Integer) msg)); + * attr.set(a * (Integer) msg); * } * } * @@ -161,8 +161,8 @@ public interface ChannelHandlerContext extends AttributeMap { /** * A {@link Channel} was registered to its {@link EventLoop}. * - * This will result in having the {@link ChannelInboundHandler#channelRegistered(ChannelHandlerContext)} method - * called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the + * This will result in having the {@link ChannelInboundHandler#channelRegistered(ChannelHandlerContext)} method + * called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelHandlerContext fireChannelRegistered(); @@ -170,8 +170,8 @@ public interface ChannelHandlerContext extends AttributeMap { /** * A {@link Channel} was unregistered from its {@link EventLoop}. * - * This will result in having the {@link ChannelInboundHandler#channelUnregistered(ChannelHandlerContext)} method - * called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the + * This will result in having the {@link ChannelInboundHandler#channelUnregistered(ChannelHandlerContext)} method + * called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ @Deprecated @@ -180,8 +180,8 @@ public interface ChannelHandlerContext extends AttributeMap { /** * A {@link Channel} is active now, which means it is connected. * - * This will result in having the {@link ChannelInboundHandler#channelActive(ChannelHandlerContext)} method - * called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the + * This will result in having the {@link ChannelInboundHandler#channelActive(ChannelHandlerContext)} method + * called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelHandlerContext fireChannelActive(); @@ -189,8 +189,8 @@ public interface ChannelHandlerContext extends AttributeMap { /** * A {@link Channel} is inactive now, which means it is closed. * - * This will result in having the {@link ChannelInboundHandler#channelInactive(ChannelHandlerContext)} method - * called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the + * This will result in having the {@link ChannelInboundHandler#channelInactive(ChannelHandlerContext)} method + * called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelHandlerContext fireChannelInactive(); @@ -198,8 +198,8 @@ public interface ChannelHandlerContext extends AttributeMap { /** * A {@link Channel} received an {@link Throwable} in one of its inbound operations. * - * This will result in having the {@link ChannelInboundHandler#exceptionCaught(ChannelHandlerContext, Throwable)} - * method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the + * This will result in having the {@link ChannelInboundHandler#exceptionCaught(ChannelHandlerContext, Throwable)} + * method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelHandlerContext fireExceptionCaught(Throwable cause); @@ -207,8 +207,8 @@ public interface ChannelHandlerContext extends AttributeMap { /** * A {@link Channel} received an user defined event. * - * This will result in having the {@link ChannelInboundHandler#userEventTriggered(ChannelHandlerContext, Object)} - * method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the + * This will result in having the {@link ChannelInboundHandler#userEventTriggered(ChannelHandlerContext, Object)} + * method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelHandlerContext fireUserEventTriggered(Object event); @@ -217,7 +217,7 @@ public interface ChannelHandlerContext extends AttributeMap { * A {@link Channel} received a message. * * This will result in having the {@link ChannelInboundHandler#channelRead(ChannelHandlerContext, Object)} - * method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the + * method called of the next {@link ChannelInboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelHandlerContext fireChannelRead(Object msg); @@ -240,7 +240,7 @@ public interface ChannelHandlerContext extends AttributeMap { *

    * This will result in having the * {@link ChannelOutboundHandler#bind(ChannelHandlerContext, SocketAddress, ChannelPromise)} method - * called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the + * called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelFuture bind(SocketAddress localAddress); @@ -255,7 +255,7 @@ public interface ChannelHandlerContext extends AttributeMap { *

    * This will result in having the * {@link ChannelOutboundHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)} - * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the + * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelFuture connect(SocketAddress remoteAddress); @@ -267,7 +267,7 @@ public interface ChannelHandlerContext extends AttributeMap { *

    * This will result in having the * {@link ChannelOutboundHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)} - * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the + * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress); @@ -278,7 +278,7 @@ public interface ChannelHandlerContext extends AttributeMap { *

    * This will result in having the * {@link ChannelOutboundHandler#disconnect(ChannelHandlerContext, ChannelPromise)} - * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the + * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelFuture disconnect(); @@ -292,7 +292,7 @@ public interface ChannelHandlerContext extends AttributeMap { *

    * This will result in having the * {@link ChannelOutboundHandler#close(ChannelHandlerContext, ChannelPromise)} - * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the + * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelFuture close(); @@ -304,7 +304,7 @@ public interface ChannelHandlerContext extends AttributeMap { *

    * This will result in having the * {@link ChannelOutboundHandler#deregister(ChannelHandlerContext, ChannelPromise)} - * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the + * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. * */ @@ -319,7 +319,7 @@ public interface ChannelHandlerContext extends AttributeMap { *

    * This will result in having the * {@link ChannelOutboundHandler#bind(ChannelHandlerContext, SocketAddress, ChannelPromise)} method - * called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the + * called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelFuture bind(SocketAddress localAddress, ChannelPromise promise); @@ -337,7 +337,7 @@ public interface ChannelHandlerContext extends AttributeMap { *

    * This will result in having the * {@link ChannelOutboundHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)} - * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the + * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelFuture connect(SocketAddress remoteAddress, ChannelPromise promise); @@ -351,7 +351,7 @@ public interface ChannelHandlerContext extends AttributeMap { *

    * This will result in having the * {@link ChannelOutboundHandler#connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)} - * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the + * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise); @@ -364,7 +364,7 @@ public interface ChannelHandlerContext extends AttributeMap { *

    * This will result in having the * {@link ChannelOutboundHandler#disconnect(ChannelHandlerContext, ChannelPromise)} - * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the + * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelFuture disconnect(ChannelPromise promise); @@ -379,7 +379,7 @@ public interface ChannelHandlerContext extends AttributeMap { *

    * This will result in having the * {@link ChannelOutboundHandler#close(ChannelHandlerContext, ChannelPromise)} - * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the + * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelFuture close(ChannelPromise promise); @@ -393,7 +393,7 @@ public interface ChannelHandlerContext extends AttributeMap { *

    * This will result in having the * {@link ChannelOutboundHandler#deregister(ChannelHandlerContext, ChannelPromise)} - * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the + * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ @Deprecated @@ -408,7 +408,7 @@ public interface ChannelHandlerContext extends AttributeMap { *

    * This will result in having the * {@link ChannelOutboundHandler#read(ChannelHandlerContext)} - * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the + * method called of the next {@link ChannelOutboundHandler} contained in the {@link ChannelPipeline} of the * {@link Channel}. */ ChannelHandlerContext read(); diff --git a/transport/src/main/java/io/netty/channel/ChannelHandlerInvoker.java b/transport/src/main/java/io/netty/channel/ChannelHandlerInvoker.java index 4668440835..8acdf6d2a2 100644 --- a/transport/src/main/java/io/netty/channel/ChannelHandlerInvoker.java +++ b/transport/src/main/java/io/netty/channel/ChannelHandlerInvoker.java @@ -23,7 +23,7 @@ import java.net.SocketAddress; /** * Invokes the event handler methods of {@link ChannelInboundHandler} and {@link ChannelOutboundHandler}. * A user can specify a {@link ChannelHandlerInvoker} to implement a custom thread model unsupported by the default - * implementation. + * implementation. Note that the methods in this interface are not intended to be called by a user. */ public interface ChannelHandlerInvoker { diff --git a/transport/src/main/java/io/netty/channel/embedded/EmbeddedEventLoop.java b/transport/src/main/java/io/netty/channel/embedded/EmbeddedEventLoop.java index c4c6f682f9..db8d3a0f04 100644 --- a/transport/src/main/java/io/netty/channel/embedded/EmbeddedEventLoop.java +++ b/transport/src/main/java/io/netty/channel/embedded/EmbeddedEventLoop.java @@ -126,6 +126,11 @@ final class EmbeddedEventLoop extends AbstractEventLoop implements ChannelHandle invokeChannelRegisteredNow(ctx); } + @Override + public void invokeChannelUnregistered(ChannelHandlerContext ctx) { + invokeChannelUnregisteredNow(ctx); + } + @Override public void invokeChannelActive(ChannelHandlerContext ctx) { invokeChannelActiveNow(ctx); @@ -136,11 +141,6 @@ final class EmbeddedEventLoop extends AbstractEventLoop implements ChannelHandle invokeChannelInactiveNow(ctx); } - @Override - public void invokeChannelUnregistered(ChannelHandlerContext ctx) { - invokeChannelUnregisteredNow(ctx); - } - @Override public void invokeExceptionCaught(ChannelHandlerContext ctx, Throwable cause) { invokeExceptionCaughtNow(ctx, cause); diff --git a/transport/src/main/java/io/netty/channel/socket/DefaultDatagramChannelConfig.java b/transport/src/main/java/io/netty/channel/socket/DefaultDatagramChannelConfig.java index 751ad6ec48..6e23334e29 100644 --- a/transport/src/main/java/io/netty/channel/socket/DefaultDatagramChannelConfig.java +++ b/transport/src/main/java/io/netty/channel/socket/DefaultDatagramChannelConfig.java @@ -143,6 +143,7 @@ public class DefaultDatagramChannelConfig extends DefaultChannelConfig implement } this.activeOnOpen = activeOnOpen; } + @Override public boolean isBroadcast() { try { diff --git a/transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java b/transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java index 456714e712..40a0019193 100644 --- a/transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/NioSocketChannel.java @@ -67,7 +67,7 @@ public class NioSocketChannel extends AbstractNioByteChannel implements io.netty * Create a new instance */ public NioSocketChannel() { - this(newSocket(DEFAULT_SELECTOR_PROVIDER)); + this(DEFAULT_SELECTOR_PROVIDER); } /** diff --git a/transport/src/test/java/io/netty/channel/SingleThreadEventLoopTest.java b/transport/src/test/java/io/netty/channel/SingleThreadEventLoopTest.java index 53eacaef4d..281cedc154 100644 --- a/transport/src/test/java/io/netty/channel/SingleThreadEventLoopTest.java +++ b/transport/src/test/java/io/netty/channel/SingleThreadEventLoopTest.java @@ -39,8 +39,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; public class SingleThreadEventLoopTest { diff --git a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java index 4ac3047a32..b3bb3219c9 100644 --- a/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java +++ b/transport/src/test/java/io/netty/channel/local/LocalTransportThreadModelTest.java @@ -90,7 +90,7 @@ public class LocalTransportThreadModelTest { EventExecutorGroup e2 = new DefaultEventExecutorGroup(4, new DefaultThreadFactory("e2")); ThreadNameAuditor h1 = new ThreadNameAuditor(); ThreadNameAuditor h2 = new ThreadNameAuditor(); - ThreadNameAuditor h3 = new ThreadNameAuditor(); + ThreadNameAuditor h3 = new ThreadNameAuditor(true); Channel ch = new LocalChannel(); // With no EventExecutor specified, h1 will be always invoked by EventLoop 'l'. @@ -361,6 +361,15 @@ public class LocalTransportThreadModelTest { private final Queue inboundThreadNames = new ConcurrentLinkedQueue(); private final Queue outboundThreadNames = new ConcurrentLinkedQueue(); private final Queue removalThreadNames = new ConcurrentLinkedQueue(); + private final boolean discard; + + ThreadNameAuditor() { + this(false); + } + + ThreadNameAuditor(boolean discard) { + this.discard = discard; + } @Override public void handlerRemoved(ChannelHandlerContext ctx) throws Exception { @@ -370,7 +379,9 @@ public class LocalTransportThreadModelTest { @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { inboundThreadNames.add(Thread.currentThread().getName()); - ctx.fireChannelRead(msg); + if (!discard) { + ctx.fireChannelRead(msg); + } } @Override