iJIAJIA commented on issue #13398:
URL: https://github.com/apache/dubbo/issues/13398#issuecomment-1837807458

   我断点看了下, 3.2.9在初始化NettyConnectionClient时, 新增了
   ```java
   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](https://github.com/apache/dubbo/assets/10057108/f5b31e55-58ef-4aef-8f2c-8ee6600aa67e)
   consumer接收到实例下线时通知时,  会触发一次Invoker#destory方法, 此时会执行一次 
AbstractConnectionClient#release, 这里会执行第一次NettyConnectionClient#close方法. 
   之后释放连接时, 会由Netty的closeFuture触发第二次#close方法.
   
   可以加个判断修复
   ```java
   @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);
               }
           }
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to