Deprecate CombinedChannelDuplexHandler in favor of ChannelHandlerAppender
- Fixes #2233
This commit is contained in:
parent
dea5c688fd
commit
7e1db4feb7
@ -17,8 +17,8 @@ package io.netty.handler.codec.http;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerAppender;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.CombinedChannelDuplexHandler;
|
||||
import io.netty.handler.codec.PrematureChannelClosureException;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
@ -40,8 +40,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
*
|
||||
* @see HttpServerCodec
|
||||
*/
|
||||
public final class HttpClientCodec
|
||||
extends CombinedChannelDuplexHandler<HttpResponseDecoder, HttpRequestEncoder> {
|
||||
public final class HttpClientCodec extends ChannelHandlerAppender {
|
||||
|
||||
/** A queue that is used for correlating a request and a response. */
|
||||
private final Queue<HttpMethod> queue = new ArrayDeque<HttpMethod>();
|
||||
@ -61,14 +60,6 @@ public final class HttpClientCodec
|
||||
this(4096, 8192, 8192, false);
|
||||
}
|
||||
|
||||
public void setSingleDecode(boolean singleDecode) {
|
||||
inboundHandler().setSingleDecode(singleDecode);
|
||||
}
|
||||
|
||||
public boolean isSingleDecode() {
|
||||
return inboundHandler().isSingleDecode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance with the specified decoder options.
|
||||
*/
|
||||
@ -90,10 +81,23 @@ public final class HttpClientCodec
|
||||
public HttpClientCodec(
|
||||
int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean failOnMissingResponse,
|
||||
boolean validateHeaders) {
|
||||
init(new Decoder(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders), new Encoder());
|
||||
add(new Decoder(maxInitialLineLength, maxHeaderSize, maxChunkSize, validateHeaders));
|
||||
add(new Encoder());
|
||||
this.failOnMissingResponse = failOnMissingResponse;
|
||||
}
|
||||
|
||||
private Decoder decoder() {
|
||||
return handlerAt(0);
|
||||
}
|
||||
|
||||
public void setSingleDecode(boolean singleDecode) {
|
||||
decoder().setSingleDecode(singleDecode);
|
||||
}
|
||||
|
||||
public boolean isSingleDecode() {
|
||||
return decoder().isSingleDecode();
|
||||
}
|
||||
|
||||
private final class Encoder extends HttpRequestEncoder {
|
||||
|
||||
@Override
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.handler.codec.http;
|
||||
|
||||
import io.netty.channel.CombinedChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerAppender;
|
||||
|
||||
|
||||
/**
|
||||
@ -24,8 +24,7 @@ import io.netty.channel.CombinedChannelDuplexHandler;
|
||||
*
|
||||
* @see HttpClientCodec
|
||||
*/
|
||||
public final class HttpServerCodec
|
||||
extends CombinedChannelDuplexHandler<HttpRequestDecoder, HttpResponseEncoder> {
|
||||
public final class HttpServerCodec extends ChannelHandlerAppender {
|
||||
|
||||
/**
|
||||
* Creates a new instance with the default decoder options
|
||||
|
@ -15,12 +15,12 @@
|
||||
*/
|
||||
package io.netty.handler.codec.spdy;
|
||||
|
||||
import io.netty.channel.CombinedChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerAppender;
|
||||
|
||||
/**
|
||||
* A combination of {@link SpdyFrameDecoder} and {@link SpdyFrameEncoder}.
|
||||
*/
|
||||
public final class SpdyFrameCodec extends CombinedChannelDuplexHandler<SpdyFrameDecoder, SpdyFrameEncoder> {
|
||||
public final class SpdyFrameCodec extends ChannelHandlerAppender {
|
||||
/**
|
||||
* Creates a new instance with the specified {@code version} and
|
||||
* the default decoder and encoder options
|
||||
|
@ -15,13 +15,12 @@
|
||||
*/
|
||||
package io.netty.handler.codec.spdy;
|
||||
|
||||
import io.netty.channel.CombinedChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerAppender;
|
||||
|
||||
/**
|
||||
* A combination of {@link SpdyHttpDecoder} and {@link SpdyHttpEncoder}
|
||||
*/
|
||||
public final class SpdyHttpCodec
|
||||
extends CombinedChannelDuplexHandler<SpdyHttpDecoder, SpdyHttpEncoder> {
|
||||
public final class SpdyHttpCodec extends ChannelHandlerAppender {
|
||||
/**
|
||||
* Creates a new instance with the specified decoder options.
|
||||
*/
|
||||
|
@ -16,8 +16,8 @@
|
||||
package io.netty.handler.codec.memcache.binary;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerAppender;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.CombinedChannelDuplexHandler;
|
||||
import io.netty.handler.codec.PrematureChannelClosureException;
|
||||
import io.netty.handler.codec.memcache.LastMemcacheContent;
|
||||
|
||||
@ -35,8 +35,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
* content, which defaults to 8192. This chunk size is the maximum, so if smaller chunks arrive they
|
||||
* will be passed up the pipeline and not queued up to the chunk size.
|
||||
*/
|
||||
public final class BinaryMemcacheClientCodec
|
||||
extends CombinedChannelDuplexHandler<BinaryMemcacheResponseDecoder, BinaryMemcacheRequestEncoder> {
|
||||
public final class BinaryMemcacheClientCodec extends ChannelHandlerAppender {
|
||||
|
||||
private final boolean failOnMissingResponse;
|
||||
private final AtomicLong requestResponseCounter = new AtomicLong();
|
||||
@ -65,7 +64,8 @@ public final class BinaryMemcacheClientCodec
|
||||
*/
|
||||
public BinaryMemcacheClientCodec(int decodeChunkSize, boolean failOnMissingResponse) {
|
||||
this.failOnMissingResponse = failOnMissingResponse;
|
||||
init(new Decoder(decodeChunkSize), new Encoder());
|
||||
add(new Decoder(decodeChunkSize));
|
||||
add(new Encoder());
|
||||
}
|
||||
|
||||
private final class Encoder extends BinaryMemcacheRequestEncoder {
|
||||
@ -82,7 +82,7 @@ public final class BinaryMemcacheClientCodec
|
||||
|
||||
private final class Decoder extends BinaryMemcacheResponseDecoder {
|
||||
|
||||
public Decoder(int chunkSize) {
|
||||
Decoder(int chunkSize) {
|
||||
super(chunkSize);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.netty.handler.codec.memcache.binary;
|
||||
|
||||
import io.netty.channel.CombinedChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerAppender;
|
||||
|
||||
/**
|
||||
* The full server codec that combines the correct encoder and decoder.
|
||||
@ -24,14 +24,14 @@ import io.netty.channel.CombinedChannelDuplexHandler;
|
||||
* Internally, it combines the {@link BinaryMemcacheRequestDecoder} and the
|
||||
* {@link BinaryMemcacheResponseEncoder} to request decoding and response encoding.
|
||||
*/
|
||||
public class BinaryMemcacheServerCodec
|
||||
extends CombinedChannelDuplexHandler<BinaryMemcacheRequestDecoder, BinaryMemcacheResponseEncoder> {
|
||||
public class BinaryMemcacheServerCodec extends ChannelHandlerAppender {
|
||||
|
||||
public BinaryMemcacheServerCodec() {
|
||||
this(AbstractBinaryMemcacheDecoder.DEFAULT_MAX_CHUNK_SIZE);
|
||||
}
|
||||
|
||||
public BinaryMemcacheServerCodec(int decodeChunkSize) {
|
||||
init(new BinaryMemcacheRequestDecoder(decodeChunkSize), new BinaryMemcacheResponseEncoder());
|
||||
add(new BinaryMemcacheRequestDecoder(decodeChunkSize));
|
||||
add(new BinaryMemcacheResponseEncoder());
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,9 @@ package io.netty.channel;
|
||||
import java.net.SocketAddress;
|
||||
|
||||
/**
|
||||
* Combines a {@link ChannelInboundHandler} and a {@link ChannelOutboundHandler} into one {@link ChannelHandler}.
|
||||
*
|
||||
* @deprecated Use {@link ChannelHandlerAppender} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class CombinedChannelDuplexHandler<I extends ChannelInboundHandler, O extends ChannelOutboundHandler>
|
||||
extends ChannelDuplexHandler {
|
||||
|
||||
|
@ -66,7 +66,7 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
||||
final Map<EventExecutorGroup, EventExecutor> childExecutors =
|
||||
new IdentityHashMap<EventExecutorGroup, EventExecutor>();
|
||||
|
||||
public DefaultChannelPipeline(AbstractChannel channel) {
|
||||
DefaultChannelPipeline(AbstractChannel channel) {
|
||||
if (channel == null) {
|
||||
throw new NullPointerException("channel");
|
||||
}
|
||||
@ -261,7 +261,7 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
||||
return this;
|
||||
}
|
||||
|
||||
private String generateName(ChannelHandler handler) {
|
||||
String generateName(ChannelHandler handler) {
|
||||
WeakHashMap<Class<?>, String> cache = nameCaches[(int) (Thread.currentThread().getId() % nameCaches.length)];
|
||||
Class<?> handlerType = handler.getClass();
|
||||
String name;
|
||||
@ -977,9 +977,9 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
||||
|
||||
static final class HeadHandler implements ChannelOutboundHandler {
|
||||
|
||||
protected final Unsafe unsafe;
|
||||
private final Unsafe unsafe;
|
||||
|
||||
protected HeadHandler(Unsafe unsafe) {
|
||||
HeadHandler(Unsafe unsafe) {
|
||||
this.unsafe = unsafe;
|
||||
}
|
||||
|
||||
@ -1019,6 +1019,7 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
unsafe.deregister(promise);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user