You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/03/18 15:06:40 UTC

[dubbo] branch master updated: If the channel has been closed, return directly. (#7410)

This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new b5c81d8  If the channel has been closed, return directly. (#7410)
b5c81d8 is described below

commit b5c81d85582c0cd6d7afbe040148aeed59c764d1
Author: xiaoheng1 <20...@qq.com>
AuthorDate: Thu Mar 18 23:06:15 2021 +0800

    If the channel has been closed, return directly. (#7410)
---
 .../exchange/support/header/HeaderExchangeChannel.java         | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java
index a1c7b25..3e3f6b7 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java
@@ -90,7 +90,8 @@ final class HeaderExchangeChannel implements ExchangeChannel {
     @Override
     public void send(Object message, boolean sent) throws RemotingException {
         if (closed) {
-            throw new RemotingException(this.getLocalAddress(), null, "Failed to send message " + message + ", cause: The channel " + this + " is closed!");
+            throw new RemotingException(this.getLocalAddress(), null,
+                    "Failed to send message " + message + ", cause: The channel " + this + " is closed!");
         }
         if (message instanceof Request
                 || message instanceof Response
@@ -123,7 +124,8 @@ final class HeaderExchangeChannel implements ExchangeChannel {
     @Override
     public CompletableFuture<Object> request(Object request, int timeout, ExecutorService executor) throws RemotingException {
         if (closed) {
-            throw new RemotingException(this.getLocalAddress(), null, "Failed to send request " + request + ", cause: The channel " + this + " is closed!");
+            throw new RemotingException(this.getLocalAddress(), null,
+                    "Failed to send request " + request + ", cause: The channel " + this + " is closed!");
         }
         // create request.
         Request req = new Request();
@@ -147,6 +149,10 @@ final class HeaderExchangeChannel implements ExchangeChannel {
 
     @Override
     public void close() {
+        // If the channel has been closed, return directly.
+        if (closed) {
+            return;
+        }
         try {
             // graceful close
             DefaultFuture.closeChannel(channel);
-- 
To unsubscribe, email commits-unsubscribe@dubbo.apache.org