Use BufUtil.retain() where possible
This commit is contained in:
parent
6568cbfec4
commit
9e67cce932
@ -15,9 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.handler.codec.http;
|
package io.netty.handler.codec.http;
|
||||||
|
|
||||||
|
import io.netty.buffer.BufUtil;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.ByteBufHolder;
|
import io.netty.buffer.ByteBufHolder;
|
||||||
import io.netty.buffer.ReferenceCounted;
|
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.embedded.EmbeddedByteChannel;
|
import io.netty.channel.embedded.EmbeddedByteChannel;
|
||||||
@ -62,12 +62,8 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpMessa
|
|||||||
if (acceptedEncoding == null) {
|
if (acceptedEncoding == null) {
|
||||||
acceptedEncoding = HttpHeaders.Values.IDENTITY;
|
acceptedEncoding = HttpHeaders.Values.IDENTITY;
|
||||||
}
|
}
|
||||||
boolean offered = acceptEncodingQueue.offer(acceptedEncoding);
|
acceptEncodingQueue.add(acceptedEncoding);
|
||||||
assert offered;
|
BufUtil.retain(msg);
|
||||||
if (msg instanceof ReferenceCounted) {
|
|
||||||
// need to call retain to not free it
|
|
||||||
((ReferenceCounted) msg).retain();
|
|
||||||
}
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,10 +72,7 @@ public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpMessa
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
if (msg instanceof HttpResponse && ((HttpResponse) msg).getStatus().code() == 100) {
|
if (msg instanceof HttpResponse && ((HttpResponse) msg).getStatus().code() == 100) {
|
||||||
// 100-continue response must be passed through.
|
// 100-continue response must be passed through.
|
||||||
if (msg instanceof ReferenceCounted) {
|
BufUtil.retain(msg);
|
||||||
// need to call retain to not free it
|
|
||||||
((ReferenceCounted) msg).retain();
|
|
||||||
}
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user