HTTP/2 example upgrade refcnt bug
Motivation: Http2ServerInitializer uses a SimpleChannelHandler in an attempt to ease putting an HttpObjectAggregator in the pipeline when no upgrade is attempted. However the message is double released because it is fired up the pipeline (which will be released) and also released by SimpleChannelHandler in a finally block. Modifications: - Retain the message if we fire it up the pipeline Result: HTTP/2 examples don't encounter a reference count error if no upgrade was attempted.
This commit is contained in:
parent
3c62a20519
commit
e3fbfe5641
@ -34,6 +34,7 @@ import io.netty.handler.codec.http2.Http2CodecUtil;
|
|||||||
import io.netty.handler.codec.http2.Http2ServerUpgradeCodec;
|
import io.netty.handler.codec.http2.Http2ServerUpgradeCodec;
|
||||||
import io.netty.handler.ssl.SslContext;
|
import io.netty.handler.ssl.SslContext;
|
||||||
import io.netty.util.AsciiString;
|
import io.netty.util.AsciiString;
|
||||||
|
import io.netty.util.ReferenceCountUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up the Netty pipeline for the example server. Depending on the endpoint config, sets up the
|
* Sets up the Netty pipeline for the example server. Depending on the endpoint config, sets up the
|
||||||
@ -101,7 +102,7 @@ public class Http2ServerInitializer extends ChannelInitializer<SocketChannel> {
|
|||||||
ChannelHandlerContext thisCtx = pipeline.context(this);
|
ChannelHandlerContext thisCtx = pipeline.context(this);
|
||||||
pipeline.addAfter(thisCtx.name(), null, new HelloWorldHttp1Handler("Direct. No Upgrade Attempted."));
|
pipeline.addAfter(thisCtx.name(), null, new HelloWorldHttp1Handler("Direct. No Upgrade Attempted."));
|
||||||
pipeline.replace(this, null, new HttpObjectAggregator(maxHttpContentLength));
|
pipeline.replace(this, null, new HttpObjectAggregator(maxHttpContentLength));
|
||||||
ctx.fireChannelRead(msg);
|
ctx.fireChannelRead(ReferenceCountUtil.retain(msg));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ import io.netty.handler.codec.http2.Http2CodecUtil;
|
|||||||
import io.netty.handler.codec.http2.Http2ServerUpgradeCodec;
|
import io.netty.handler.codec.http2.Http2ServerUpgradeCodec;
|
||||||
import io.netty.handler.ssl.SslContext;
|
import io.netty.handler.ssl.SslContext;
|
||||||
import io.netty.util.AsciiString;
|
import io.netty.util.AsciiString;
|
||||||
|
import io.netty.util.ReferenceCountUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up the Netty pipeline for the example server. Depending on the endpoint config, sets up the
|
* Sets up the Netty pipeline for the example server. Depending on the endpoint config, sets up the
|
||||||
@ -99,7 +100,7 @@ public class Http2ServerInitializer extends ChannelInitializer<SocketChannel> {
|
|||||||
ChannelHandlerContext thisCtx = pipeline.context(this);
|
ChannelHandlerContext thisCtx = pipeline.context(this);
|
||||||
pipeline.addAfter(thisCtx.name(), null, new HelloWorldHttp1Handler("Direct. No Upgrade Attempted."));
|
pipeline.addAfter(thisCtx.name(), null, new HelloWorldHttp1Handler("Direct. No Upgrade Attempted."));
|
||||||
pipeline.replace(this, null, new HttpObjectAggregator(maxHttpContentLength));
|
pipeline.replace(this, null, new HttpObjectAggregator(maxHttpContentLength));
|
||||||
ctx.fireChannelRead(msg);
|
ctx.fireChannelRead(ReferenceCountUtil.retain(msg));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user