-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Description
pendingRPC 这个ConcurrentHashMap可能会有内存溢出的风险
比如client 请求异常,或者Server返回Response异常,这个pendingRPC内的对象都无法回收
public class DefaultClientHandler extends SimpleChannelInboundHandler<RPCContext>{
private ConcurrentHashMap<Long, RPCFuture> pendingRPC = new ConcurrentHashMap<Long, RPCFuture>();
@Override
protected void channelRead0(ChannelHandlerContext arg0, RPCContext rpcCtx)
throws Exception {
RPCFuture rpcFuture = pendingRPC.get(rpcCtx.getResponse().getSeqNum());
if(rpcFuture != null){
pendingRPC.remove(rpcCtx.getResponse().getSeqNum());
rpcFuture.done(rpcCtx.getResponse());
}
}
public RPCFuture doRPC(RPCContext rpcCtx){
RPCFuture rpcFuture = new RPCFuture(rpcCtx, this);
pendingRPC.put(rpcCtx.getRequest().getSeqNum(), rpcFuture);
channel.writeAndFlush(rpcCtx);
return rpcFuture;
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels