Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复NettyClient在创建连接异常时可能导致连接泄露的问题 #670

Merged
merged 1 commit into from
Mar 23, 2018

Conversation

lion2luo
Copy link
Collaborator

@lion2luo lion2luo commented Mar 21, 2018

在netty的io线程中启动新阻塞式io操作时会触发死锁检测异常。此时如果这个io操作为创建客户端连接,可能造成连接已经创建但是由于抛出了异常导致新建的连接成了一个游离的连接无法释放。
image

通过以下类似的代码可以还原

ExecutorService executorService = Executors.newSingleThreadExecutor();
nettyClient = new NettyClient(url);
nettyClient.resetErrorCount();
nettyClient.open();
DeadLockProofWorker.start(executorService, new Runnable() {
    @Override
    public void run() {
        try {
            nettyClient.request(request);
        } catch (Exception e) {
        }
    }
});

@rayzhang0603
Copy link
Collaborator

LGTM

@rayzhang0603 rayzhang0603 merged commit 9724ff3 into weibocom:master Mar 23, 2018
@lion2luo lion2luo deleted the fix_connection_leak branch April 2, 2018 11:01
sunnights added a commit to sunnights/motan that referenced this pull request Apr 26, 2018
rayzhang0603 added a commit that referenced this pull request Apr 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants