Skip to content

Commit

Permalink
Create new instance of each inbound handler
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Perkins <[email protected]>
  • Loading branch information
cwperks committed Sep 28, 2023
1 parent 5188697 commit cd9e72f
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ public class Netty4HttpServerTransport extends AbstractHttpServerTransport {
private volatile ServerBootstrap serverBootstrap;
private volatile SharedGroupFactory.SharedGroup sharedGroup;

private static final HttpContentDecompressor DEFAULT_DECOMPRESSOR = new HttpContentDecompressor();
private static final ChannelInboundHandlerAdapter DEFAULT_HEADER_VERIFIER = new ChannelInboundHandlerAdapter();

public Netty4HttpServerTransport(
Settings settings,
NetworkService networkService,
Expand Down Expand Up @@ -429,8 +426,8 @@ protected void channelRead0(ChannelHandlerContext ctx, HttpMessage msg) throws E
// If this handler is hit then no upgrade has been attempted and the client is just talking HTTP
final ChannelPipeline pipeline = ctx.pipeline();
pipeline.addAfter(ctx.name(), "handler", getRequestHandler());
pipeline.replace(this, "header_verifier", transport.getHeaderVerifier());
pipeline.addAfter("header_verifier", "decompress", transport.getDecompressor());
pipeline.replace(this, "header_verifier", transport.creategetHeaderVerifier());
pipeline.addAfter("header_verifier", "decompress", transport.createDecompressor());
pipeline.addAfter("decompress", "aggregator", aggregator);
if (handlingSettings.isCompression()) {
pipeline.addAfter("aggregator", "compress", new HttpContentCompressor(handlingSettings.getCompressionLevel()));
Expand All @@ -452,8 +449,8 @@ protected void configureDefaultHttpPipeline(ChannelPipeline pipeline) {
);
decoder.setCumulator(ByteToMessageDecoder.COMPOSITE_CUMULATOR);
pipeline.addLast("decoder", decoder);
pipeline.addLast("header_verifier", transport.getHeaderVerifier());
pipeline.addLast("decompress", transport.getDecompressor());
pipeline.addLast("header_verifier", transport.creategetHeaderVerifier());
pipeline.addLast("decompress", transport.createDecompressor());
pipeline.addLast("encoder", new HttpResponseEncoder());
final HttpObjectAggregator aggregator = new HttpObjectAggregator(handlingSettings.getMaxContentLength());
aggregator.setMaxCumulationBufferComponents(transport.maxCompositeBufferComponents);
Expand Down Expand Up @@ -499,8 +496,8 @@ protected void initChannel(Channel childChannel) throws Exception {
.addLast(new Http2StreamFrameToHttpObjectCodec(true))
.addLast("byte_buf_sizer", byteBufSizer)
.addLast("read_timeout", new ReadTimeoutHandler(transport.readTimeoutMillis, TimeUnit.MILLISECONDS))
.addLast("header_verifier", transport.getHeaderVerifier())
.addLast("decompress", transport.getDecompressor());
.addLast("header_verifier", transport.creategetHeaderVerifier())
.addLast("decompress", transport.createDecompressor());

if (handlingSettings.isCompression()) {
childChannel.pipeline().addLast("compress", new HttpContentCompressor(handlingSettings.getCompressionLevel()));
Expand Down Expand Up @@ -538,12 +535,12 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
}
}

protected HttpContentDecompressor getDecompressor() {
return DEFAULT_DECOMPRESSOR;
protected HttpContentDecompressor createDecompressor() {
return new HttpContentDecompressor();
}

protected ChannelInboundHandlerAdapter getHeaderVerifier() {
protected ChannelInboundHandlerAdapter creategetHeaderVerifier() {
// pass-through
return DEFAULT_HEADER_VERIFIER;
return new ChannelInboundHandlerAdapter();
}
}

0 comments on commit cd9e72f

Please sign in to comment.