Skip to content

Commit b727493

Browse files
kexianjunkhanimteyaz
authored andcommitted
optimize ReconnectTimerTask's log output (apache#3162)
* optimize log output * Separate logs for reconnect and close * remove reconnect exception log
1 parent 77dbfbe commit b727493

File tree

1 file changed

+17
-15
lines changed
  • dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header

1 file changed

+17
-15
lines changed

dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/ReconnectTimerTask.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,26 @@ public class ReconnectTimerTask extends AbstractTimerTask {
3838

3939
@Override
4040
protected void doTask(Channel channel) {
41-
try {
42-
Long lastRead = lastRead(channel);
43-
Long now = now();
44-
if (lastRead != null && now - lastRead > heartbeatTimeout) {
45-
logger.warn("Close channel " + channel + ", because heartbeat read idle time out: "
46-
+ heartbeatTimeout + "ms");
47-
if (channel instanceof Client) {
48-
try {
49-
((Client) channel).reconnect();
50-
} catch (Exception e) {
51-
//do nothing
52-
}
53-
} else {
41+
Long lastRead = lastRead(channel);
42+
Long now = now();
43+
if (lastRead != null && now - lastRead > heartbeatTimeout) {
44+
if (channel instanceof Client) {
45+
try {
46+
logger.warn("Reconnect to remote channel " + channel.getRemoteAddress() + ", because heartbeat read idle time out: "
47+
+ heartbeatTimeout + "ms");
48+
((Client) channel).reconnect();
49+
} catch (Throwable t) {
50+
// do nothing
51+
}
52+
} else {
53+
try {
54+
logger.warn("Close channel " + channel + ", because heartbeat read idle time out: "
55+
+ heartbeatTimeout + "ms");
5456
channel.close();
57+
} catch (Throwable t) {
58+
logger.warn("Exception when close channel " + channel, t);
5559
}
5660
}
57-
} catch (Throwable t) {
58-
logger.warn("Exception when reconnect to remote channel " + channel.getRemoteAddress(), t);
5961
}
6062
}
6163
}

0 commit comments

Comments
 (0)