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