Skip to content

Commit

Permalink
Fix DefaultFuture turn off exception logging optimization for Channel (
Browse files Browse the repository at this point in the history
  • Loading branch information
shikui@tiduyun.com committed Sep 9, 2021
1 parent 13c15fd commit 1611a9e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public static void closeChannel(Channel channel) {
disconnectResponse.setErrorMessage("Channel " +
channel +
" is inactive. Directly return the unFinished request : " +
future.getRequest());
rinseRequestData(future.getRequest()));
DefaultFuture.received(channel, disconnectResponse);
}
}
Expand Down Expand Up @@ -251,11 +251,11 @@ 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 : rinseRequestData(request)) + ", channel: " + channel.getLocalAddress()
+ " -> " + channel.getRemoteAddress();
}

private Request getRequestWithoutData() {
private static Request rinseRequestData(Request request) {
Request newRequest = request.copy();
newRequest.setData(null);
return newRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.dubbo.remoting.exchange.support.header;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.remoting.Channel;
import org.apache.dubbo.remoting.RemotingException;
Expand Down Expand Up @@ -187,6 +189,17 @@ public void closeTest() {
}


@Test
public void closeExecptionMsgTest() throws RemotingException {
Object request = new Object();
CompletableFuture<Object> future = header.request(request);
header.close();
ExecutionException executionException = Assertions.assertThrows(ExecutionException.class, () -> future.get());
String message = executionException.getMessage();
Assertions.assertTrue(message.contains("data=null"));
}


@Test
public void closeWithTimeoutTest02() {
Assertions.assertFalse(channel.isClosed());
Expand Down

0 comments on commit 1611a9e

Please sign in to comment.