You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by ho...@apache.org on 2021/09/12 05:37:27 UTC

[dubbo] branch 3.0 updated: fix issue-8695:DefaultFuture turn off logging optimization for Channel (#8775)

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

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


The following commit(s) were added to refs/heads/3.0 by this push:
     new 26152d8  fix issue-8695:DefaultFuture turn off logging optimization for Channel (#8775)
26152d8 is described below

commit 26152d83b28d8363ff5ffc60d0ceb679a7ee4632
Author: candy <35...@users.noreply.github.com>
AuthorDate: Sun Sep 12 13:37:06 2021 +0800

    fix issue-8695:DefaultFuture turn off logging optimization for Channel (#8775)
    
    * fix issue-8695:DefaultFuture turn off exception logging optimization for Channel
    
    * fix issue-8695:Remove the getRequestWithoutData method from DefaultFuture
---
 .../main/java/org/apache/dubbo/remoting/exchange/Request.java    | 9 +++++++++
 .../apache/dubbo/remoting/exchange/support/DefaultFuture.java    | 9 ++-------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Request.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Request.java
index 6eea6b0..f115de2 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Request.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/Request.java
@@ -137,6 +137,15 @@ public class Request {
         return copy;
     }
 
+    public Request copyWithoutData(){
+        Request copy = new Request(mId);
+        copy.mVersion = this.mVersion;
+        copy.mTwoWay = this.mTwoWay;
+        copy.mEvent = this.mEvent;
+        copy.mBroken = this.mBroken;
+        return copy;
+    }
+
     @Override
     public String toString() {
         return "Request [id=" + mId + ", version=" + mVersion + ", twoway=" + mTwoWay + ", event=" + mEvent
diff --git a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/DefaultFuture.java b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/DefaultFuture.java
index ffd8a9e..5a12d62 100644
--- a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/DefaultFuture.java
+++ b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/DefaultFuture.java
@@ -147,7 +147,7 @@ public class DefaultFuture extends CompletableFuture<Object> {
                     disconnectResponse.setErrorMessage("Channel " +
                             channel +
                             " is inactive. Directly return the unFinished request : " +
-                            future.getRequest());
+                            (logger.isDebugEnabled() ? future.getRequest() : future.getRequest().copyWithoutData()));
                     DefaultFuture.received(channel, disconnectResponse);
                 }
             }
@@ -251,15 +251,10 @@ public class DefaultFuture extends CompletableFuture<Object> {
                 + (sent > 0 ? " client elapsed: " + (sent - start)
                 + " ms, server elapsed: " + (nowTimestamp - sent)
                 : " elapsed: " + (nowTimestamp - start)) + " ms, timeout: "
-                + timeout + " ms, request: " + (logger.isDebugEnabled() ? request : getRequestWithoutData()) + ", channel: " + channel.getLocalAddress()
+                + timeout + " ms, request: " + (logger.isDebugEnabled() ? request : request.copyWithoutData()) + ", channel: " + channel.getLocalAddress()
                 + " -> " + channel.getRemoteAddress();
     }
 
-    private Request getRequestWithoutData() {
-        Request newRequest = request.copy();
-        newRequest.setData(null);
-        return newRequest;
-    }
 
     private static class TimeoutCheckTask implements TimerTask {