Skip to content

Commit

Permalink
Read heartbeat from util when recreate url in ExchangeClient (#12605)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ authored Jun 27, 2023
1 parent f8dfbb0 commit dce7b87
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.dubbo.remoting.exchange.Exchangers;
import org.apache.dubbo.remoting.exchange.PortUnificationExchanger;
import org.apache.dubbo.remoting.exchange.support.ExchangeHandlerAdapter;
import org.apache.dubbo.remoting.utils.UrlUtils;
import org.apache.dubbo.rpc.Exporter;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
Expand Down Expand Up @@ -514,11 +515,12 @@ private ExchangeClient initClient(URL url) {
}

try {
int heartbeat = UrlUtils.getHeartbeat(url);
// Replace InstanceAddressURL with ServiceConfigURL.
url = new ServiceConfigURL(DubboCodec.NAME, url.getUsername(), url.getPassword(), url.getHost(), url.getPort(), url.getPath(), url.getAllParameters());
url = url.addParameter(CODEC_KEY, DubboCodec.NAME);
// enable heartbeat by default
url = url.addParameterIfAbsent(HEARTBEAT_KEY, String.valueOf(DEFAULT_HEARTBEAT));
url = url.addParameterIfAbsent(HEARTBEAT_KEY, Integer.toString(heartbeat));

// connection should be lazy
return url.getParameter(LAZY_CONNECT_KEY, false)
Expand Down

0 comments on commit dce7b87

Please sign in to comment.