This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch 3.0.5-release
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0.5-release by this push:
new 10aaa0f save url attributes on initialization (#9467)
10aaa0f is described below
commit 10aaa0f4c68a34f421276939f15641746ddc1719
Author: ken.lj <[email protected]>
AuthorDate: Thu Dec 23 17:42:07 2021 +0800
save url attributes on initialization (#9467)
---
.../rpc/protocol/dubbo/ReferenceCountExchangeClient.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git
a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java
b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java
index db72065..9fc09f9 100644
---
a/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java
+++
b/dubbo-rpc/dubbo-rpc-dubbo/src/main/java/org/apache/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java
@@ -27,6 +27,7 @@ import org.apache.dubbo.remoting.exchange.ExchangeClient;
import org.apache.dubbo.remoting.exchange.ExchangeHandler;
import java.net.InetSocketAddress;
+import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicInteger;
@@ -44,6 +45,7 @@ final class ReferenceCountExchangeClient implements
ExchangeClient {
private final static Logger logger =
LoggerFactory.getLogger(ReferenceCountExchangeClient.class);
private final URL url;
private final String codec;
+ private final Map<String, String> attributes;
private final AtomicInteger referenceCount = new AtomicInteger(0);
private final AtomicInteger disconnectCount = new AtomicInteger(0);
private final Integer warningPeriod = 50;
@@ -55,6 +57,7 @@ final class ReferenceCountExchangeClient implements
ExchangeClient {
this.referenceCount.incrementAndGet();
this.url = client.getUrl();
this.codec = codec;
+ this.attributes = url.getParameters();
}
@Override
@@ -212,10 +215,16 @@ final class ReferenceCountExchangeClient implements
ExchangeClient {
if (!(client instanceof LazyConnectExchangeClient)) {
// this is a defensive operation to avoid client is closed by
accident, the initial state of the client is false
URL lazyUrl = url.addParameter(LAZY_CONNECT_INITIAL_STATE_KEY,
Boolean.TRUE)
- //.addParameter(RECONNECT_KEY, Boolean.FALSE)
- .addParameter(SEND_RECONNECT_KEY, Boolean.TRUE.toString());
+ //.addParameter(RECONNECT_KEY, Boolean.FALSE)
+ .addParameter(SEND_RECONNECT_KEY, Boolean.TRUE.toString());
//.addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true);
- client = new LazyConnectExchangeClient(lazyUrl,
client.getExchangeHandler(), codec, lazyUrl.getParameters());
+
+ // uncomment this snippet when replacing lazyUrl in the futrue
+// Map<String, String> lazyAttributes = new HashMap<>(attributes);
+// lazyAttributes.put(LAZY_CONNECT_INITIAL_STATE_KEY,
Boolean.TRUE.toString());
+// lazyAttributes.put(SEND_RECONNECT_KEY, Boolean.TRUE.toString());
+
+ client = new LazyConnectExchangeClient(lazyUrl,
client.getExchangeHandler(), codec, attributes);
}
}