@@ -47,7 +47,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha |
47 | 47 | private final Channel parent; |
48 | 48 | private final ChannelId id; |
49 | 49 | private final Unsafe unsafe; |
50 | | - private final DefaultChannelPipeline pipeline; |
| 50 | + private final ChannelPipeline pipeline; |
51 | 51 | private final CloseFuture closeFuture = new CloseFuture(this); |
52 | 52 | private final EventLoop eventLoop; |
53 | 53 |
|
@@ -123,9 +123,9 @@ public final ChannelId id() { |
123 | 123 | } |
124 | 124 |
|
125 | 125 | /** |
126 | | - * Returns a new {@link DefaultChannelPipeline} instance. |
| 126 | + * Returns a new {@link ChannelPipeline} instance. |
127 | 127 | */ |
128 | | - protected DefaultChannelPipeline newChannelPipeline() { |
| 128 | + protected ChannelPipeline newChannelPipeline() { |
129 | 129 | return new DefaultChannelPipeline(this); |
130 | 130 | } |
131 | 131 |
|
@@ -295,6 +295,8 @@ protected abstract class AbstractUnsafe implements Unsafe { |
295 | 295 |
|
296 | 296 | private volatile ChannelOutboundBuffer outboundBuffer = new ChannelOutboundBuffer(AbstractChannel.this); |
297 | 297 | private RecvByteBufAllocator.Handle recvHandle; |
| 298 | + private MessageSizeEstimator.Handle estimatorHandle; |
| 299 | + |
298 | 300 | private boolean inFlush0; |
299 | 301 | /** true if the channel has never been registered, false otherwise */ |
300 | 302 | private boolean neverRegistered = true; |
@@ -303,6 +305,13 @@ private void assertEventLoop() { |
303 | 305 | assert !registered || eventLoop.inEventLoop(); |
304 | 306 | } |
305 | 307 |
|
| 308 | + MessageSizeEstimator.Handle estimatorHandle() { |
| 309 | + if (estimatorHandle == null) { |
| 310 | + estimatorHandle = config().getMessageSizeEstimator().newHandle(); |
| 311 | + } |
| 312 | + return estimatorHandle; |
| 313 | + } |
| 314 | + |
306 | 315 | @Override |
307 | 316 | public RecvByteBufAllocator.Handle recvBufAllocHandle() { |
308 | 317 | if (recvHandle == null) { |
@@ -333,13 +342,6 @@ public final void register(final ChannelPromise promise) { |
333 | 342 | return; |
334 | 343 | } |
335 | 344 |
|
336 | | - // Clear any cached executors from prior event loop registrations. |
337 | | - AbstractChannelHandlerContext context = pipeline.tail; |
338 | | - do { |
339 | | - context.contextExecutor = null; |
340 | | - context = context.prev; |
341 | | - } while (context != null); |
342 | | - |
343 | 345 | if (eventLoop.inEventLoop()) { |
344 | 346 | register0(promise); |
345 | 347 | } else { |
@@ -376,10 +378,6 @@ public void operationComplete(ChannelFuture future) throws Exception { |
376 | 378 | neverRegistered = false; |
377 | 379 | registered = true; |
378 | 380 |
|
379 | | - // Ensure we call handlerAdded(...) before we actually notify the promise. This is needed as the |
380 | | - // user may already fire events through the pipeline in the ChannelFutureListener. |
381 | | - pipeline.invokeHandlerAddedIfNeeded(); |
382 | | - |
383 | 381 | safeSetSuccess(promise); |
384 | 382 | pipeline.fireChannelRegistered(); |
385 | 383 | // Only fire a channelActive if the channel has never been registered. This prevents firing |
@@ -735,7 +733,7 @@ public final void write(Object msg, ChannelPromise promise) { |
735 | 733 | int size; |
736 | 734 | try { |
737 | 735 | msg = filterOutboundMessage(msg); |
738 | | - size = pipeline.estimatorHandle().size(msg); |
| 736 | + size = estimatorHandle().size(msg); |
739 | 737 | if (size < 0) { |
740 | 738 | size = 0; |
741 | 739 | } |
|