From 8c2527a1f6da3806bf22b74caf12d3a2810bb89a Mon Sep 17 00:00:00 2001 From: shikui <670569467@qq.com> Date: Sun, 12 Sep 2021 00:52:41 +0800 Subject: [PATCH 1/2] fix issue-8695:DefaultFuture turn off exception logging optimization for Channel --- .../org/apache/dubbo/remoting/exchange/Request.java | 9 +++++++++ .../dubbo/remoting/exchange/support/DefaultFuture.java | 10 ++++------ 2 files changed, 13 insertions(+), 6 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 6eea6b02eaa..f115de2141a 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 Request copy() { 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 ffd8a9e3656..a4c67a4bb16 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 static void closeChannel(Channel channel) { disconnectResponse.setErrorMessage("Channel " + channel + " is inactive. Directly return the unFinished request : " + - future.getRequest()); + getRequestWithoutData(future.getRequest())); DefaultFuture.received(channel, disconnectResponse); } } @@ -251,14 +251,12 @@ private String getTimeoutMessage(boolean scan) { + (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 : getRequestWithoutData(request)) + ", channel: " + channel.getLocalAddress() + " -> " + channel.getRemoteAddress(); } - private Request getRequestWithoutData() { - Request newRequest = request.copy(); - newRequest.setData(null); - return newRequest; + private static Request getRequestWithoutData(Request request) { + return request.copyWithoutData(); } private static class TimeoutCheckTask implements TimerTask { From 4af675bc2282e66c9a74615a78f070f99ebd580b Mon Sep 17 00:00:00 2001 From: shikui <670569467@qq.com> Date: Sun, 12 Sep 2021 12:03:46 +0800 Subject: [PATCH 2/2] fix issue-8695:Remove the getRequestWithoutData method from DefaultFuture --- .../dubbo/remoting/exchange/support/DefaultFuture.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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 a4c67a4bb16..5a12d62566f 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 static void closeChannel(Channel channel) { disconnectResponse.setErrorMessage("Channel " + channel + " is inactive. Directly return the unFinished request : " + - getRequestWithoutData(future.getRequest())); + (logger.isDebugEnabled() ? future.getRequest() : future.getRequest().copyWithoutData())); DefaultFuture.received(channel, disconnectResponse); } } @@ -251,13 +251,10 @@ private String getTimeoutMessage(boolean scan) { + (sent > 0 ? " client elapsed: " + (sent - start) + " ms, server elapsed: " + (nowTimestamp - sent) : " elapsed: " + (nowTimestamp - start)) + " ms, timeout: " - + timeout + " ms, request: " + (logger.isDebugEnabled() ? request : getRequestWithoutData(request)) + ", channel: " + channel.getLocalAddress() + + timeout + " ms, request: " + (logger.isDebugEnabled() ? request : request.copyWithoutData()) + ", channel: " + channel.getLocalAddress() + " -> " + channel.getRemoteAddress(); } - private static Request getRequestWithoutData(Request request) { - return request.copyWithoutData(); - } private static class TimeoutCheckTask implements TimerTask {