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 16:04:38 UTC

[dubbo] branch master updated: [master] DefaultFuture turn off logging optimization for Channel(issue #8695) (#8778)

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

horizonzy 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 2f93930  [master] DefaultFuture turn off logging optimization for Channel(issue #8695) (#8778)
2f93930 is described below

commit 2f93930c83ff576ef65d008d03325482a695a319
Author: candy <35...@users.noreply.github.com>
AuthorDate: Mon Sep 13 00:04:27 2021 +0800

    [master] DefaultFuture turn off logging optimization for Channel(issue #8695) (#8778)
---
 .../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..07dd672 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 {