apache / rocketmq

Apache RocketMQ is a cloud native messaging and streaming platform, making it simple to build event-driven applications.
https://rocketmq.apache.org/
Apache License 2.0
21.19k stars 11.67k forks source link

wrong remoting error message causing confusion #6263

Closed schneiderlin closed 1 year ago

schneiderlin commented 1 year ago

BUG REPORT

if NettyRemotingClient.invokeSync timeout, the following error will be thrown.

Caused by: org.apache.rocketmq.remoting.exception.RemotingTimeoutException: invokeSync call the addr[null] timeout
    at org.apache.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:563) ~[rocketmq-remoting-5.1.0.jar:5.1.0]
    at org.apache.rocketmq.client.impl.MQClientAPIImpl.getTopicRouteInfoFromNameServer(MQClientAPIImpl.java:1787) ~[rocketmq-client-5.1.0.jar:5.1.0]
    at org.apache.rocketmq.client.impl.MQClientAPIImpl.getTopicRouteInfoFromNameServer(MQClientAPIImpl.java:1778) ~[rocketmq-client-5.1.0.jar:5.1.0]
    at org.apache.rocketmq.client.impl.factory.MQClientInstance.updateTopicRouteInfoFromNameServer(MQClientInstance.java:609) ~[rocketmq-client-5.1.0.jar:5.1.0]

the error message said that addr is null, but it's not. there are some caller for example https://github.com/apache/rocketmq/blob/086f9d130ba7682533de7f449eabd4170071fa89/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java#L1785 call invokeSync method with null addr argument. but the following line would get real address if addr is null. https://github.com/apache/rocketmq/blob/2f93cbe051eb82834ee1ecba981c820a966190f3/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java#L554

suggest changing error message to use channel.remoteAddress() instead

Oliverwqcwrw commented 1 year ago

Hi @schneiderlin, Welcome to submit pr to fix it