Skip to content

Commit

Permalink
bugfix: netty memory leak (apache#1333)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmonkey authored and ujjboy committed Jul 23, 2019
1 parent 2cc8f36 commit 4b7fe55
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
26 changes: 25 additions & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

<properties>
<spring.version>4.3.23.RELEASE</spring.version>
<netty4.version>4.1.24.Final</netty4.version>
<netty4.version>4.1.30.Final</netty4.version>
<dubbo.version>2.7.0</dubbo.version>
<dubbo.alibaba.version>2.6.5</dubbo.alibaba.version>
<sofa.rpc.version>5.5.3</sofa.rpc.version>
Expand Down Expand Up @@ -234,6 +234,12 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${apache-zookeeper.version}</version>
<exclusions>
<exclusion>
<artifactId>io.netty</artifactId>
<groupId>netty</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
Expand Down Expand Up @@ -307,6 +313,24 @@
<groupId>io.etcd</groupId>
<artifactId>jetcd-core</artifactId>
<version>${etcd-client-v3.version}</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http2</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-handler-proxy</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import io.seata.core.protocol.HeartbeatMessage;
import io.seata.core.protocol.ProtocolConstants;
import io.seata.core.protocol.RpcMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

Expand Down Expand Up @@ -55,6 +57,8 @@
*/
public class ProtocolV1Decoder extends LengthFieldBasedFrameDecoder {

private static final Logger LOGGER = LoggerFactory.getLogger(ProtocolV1Decoder.class);

public ProtocolV1Decoder() {
// default is 8M
this(ProtocolConstants.MAX_FRAME_LENGTH);
Expand All @@ -75,7 +79,14 @@ protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception
Object decoded = super.decode(ctx, in);
if (decoded instanceof ByteBuf) {
ByteBuf frame = (ByteBuf) decoded;
return decodeFrame(frame);
try {
return decodeFrame(frame);
}catch(Exception e){
LOGGER.error("Decode error!", e);
throw e;
}finally {
frame.release();
}
}
return decoded;
}
Expand Down

0 comments on commit 4b7fe55

Please sign in to comment.