Fix memory leaks
This commit is contained in:
parent
f178b8d421
commit
7eb0f6105d
@ -584,5 +584,6 @@ public class UnpooledTest {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
assertEquals((byte) i, wrapped.readByte());
|
||||
}
|
||||
wrapped.release();
|
||||
}
|
||||
}
|
||||
|
@ -100,14 +100,14 @@ public abstract class ByteToMessageDecoder extends ChannelInboundHandlerAdapter
|
||||
}
|
||||
buf.clear();
|
||||
}
|
||||
handlerRemoved0();
|
||||
handlerRemoved0(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets called after the {@link ByteToMessageDecoder} was removed from the actual context and it doesn't handle
|
||||
* events anymore.
|
||||
*/
|
||||
protected void handlerRemoved0() throws Exception { }
|
||||
protected void handlerRemoved0(ChannelHandlerContext ctx) throws Exception { }
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, MessageList<Object> msgs) throws Exception {
|
||||
|
@ -95,8 +95,12 @@ public abstract class MessageToByteEncoder<I> extends ChannelOutboundHandlerAdap
|
||||
}
|
||||
}
|
||||
|
||||
if (buf != null && buf.isReadable()) {
|
||||
if (buf != null) {
|
||||
if (buf.isReadable()) {
|
||||
out.add(buf);
|
||||
} else {
|
||||
buf.release();
|
||||
}
|
||||
}
|
||||
|
||||
success = true;
|
||||
|
@ -342,6 +342,13 @@ public class SslHandler
|
||||
return sslCloseFuture;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlerRemoved0(ChannelHandlerContext ctx) throws Exception {
|
||||
if (decodeOut != null) {
|
||||
decodeOut.release();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception {
|
||||
ctx.bind(localAddress, promise);
|
||||
@ -843,8 +850,9 @@ public class SslHandler
|
||||
throw e;
|
||||
} finally {
|
||||
if (bytesProduced > 0) {
|
||||
ByteBuf decodeOut = this.decodeOut;
|
||||
this.decodeOut = null;
|
||||
ctx.fireMessageReceived(decodeOut);
|
||||
decodeOut = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user