Coder Social home page Coder Social logo

Comments (4)

AlbumenJ avatar AlbumenJ commented on September 23, 2024

@icodening @EarthChen PTAL

from dubbo.

iJIAJIA avatar iJIAJIA commented on September 23, 2024

@AlbumenJ
我断点看了下, 3.2.9在初始化NettyConnectionClient时, 新增了

private void initBootstrap() {
        ...
        nettyBootstrap.handler(new ChannelInitializer<SocketChannel>() {
            @Override
            protected void initChannel(SocketChannel ch) {
                ...
                ch.closeFuture().addListener(channelFuture -> doClose());
                // TODO support Socks5
            }
        });
        this.bootstrap = nettyBootstrap;
    }

image
consumer接收到实例下线时通知时, 会触发一次Invoker#destory方法, 此时会执行一次 AbstractConnectionClient#release, 这里会执行第一次NettyConnectionClient#close方法.
之后释放连接时, 会由Netty的closeFuture触发第二次#close方法.

可以加个判断修复

@Override
    protected void doClose() {
        // AbstractPeer close can set closed true.
        if (isClosed()) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug(String.format("Connection:%s freed ", this));
            }
            final io.netty.channel.Channel current = getNettyChannel();
            if (current != null) {
                current.close();
            }
            this.channel.set(null);
           // 已经触发过一次close通知, 不需要再执行
            if(!closePromise.isSuccess()) {
                closePromise.setSuccess(null);
            }
        }
    }

from dubbo.

AlbumenJ avatar AlbumenJ commented on September 23, 2024

Can you please submit a PR?

from dubbo.

icodening avatar icodening commented on September 23, 2024

@AlbumenJ 我断点看了下, 3.2.9在初始化NettyConnectionClient时, 新增了

private void initBootstrap() {
        ...
        nettyBootstrap.handler(new ChannelInitializer<SocketChannel>() {
            @Override
            protected void initChannel(SocketChannel ch) {
                ...
                ch.closeFuture().addListener(channelFuture -> doClose());
                // TODO support Socks5
            }
        });
        this.bootstrap = nettyBootstrap;
    }

修改成ch.closeFuture().addListener(channelFuture -> close());就好了呗,预期结果应该是不会进入两次doClose的逻辑

from dubbo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.