This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new a445d54 fix: LazyConnectExchangeClient remove addParameter:
REQUEST_WITH_WARNING_KEY=true (#7737)
a445d54 is described below
commit a445d54ec984258fbf57b000d54d83e77633b897
Author: 秦宁 <[email protected]>
AuthorDate: Wed May 19 20:15:51 2021 +0800
fix: LazyConnectExchangeClient remove addParameter:
REQUEST_WITH_WARNING_KEY=true (#7737)
* LazyConnectExchangeClient REQUEST_WITH_WARNING_KEY use user side value or
default value
* add a count if disconnect more than 50 times, set
REQUEST_WITH_WARNING_KEY to true
* remove unused import
* add a count if disconnect more than 50 times, set
REQUEST_WITH_WARNING_KEY to true
* add url parameter lazyclient_request_with_warning=true
* optimize
* optimize fix #7736
* optimize fix #7736
* optimize: remove unnecessary newlines. fix #7736
Co-authored-by: qinning <[email protected]>
Co-authored-by: qinning <[email protected]>
---
.../rpc/protocol/dubbo/ReferenceCountExchangeClient.java | 14 +++++++++++---
1 file changed, 11 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 ef3e00f..0eac851 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
@@ -19,6 +19,8 @@ package org.apache.dubbo.rpc.protocol.dubbo;
import org.apache.dubbo.common.Parameters;
import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.remoting.ChannelHandler;
import org.apache.dubbo.remoting.RemotingException;
import org.apache.dubbo.remoting.exchange.ExchangeClient;
@@ -38,9 +40,11 @@ import static
org.apache.dubbo.rpc.protocol.dubbo.Constants.LAZY_CONNECT_INITIAL
@SuppressWarnings("deprecation")
final class ReferenceCountExchangeClient implements ExchangeClient {
+ private final static Logger logger =
LoggerFactory.getLogger(ReferenceCountExchangeClient.class);
private final URL url;
private final AtomicInteger referenceCount = new AtomicInteger(0);
-
+ private final AtomicInteger disconnectCount = new AtomicInteger(0);
+ private final Integer maxDisconnectCount = 50;
private ExchangeClient client;
public ReferenceCountExchangeClient(ExchangeClient client) {
@@ -181,8 +185,12 @@ final class ReferenceCountExchangeClient implements
ExchangeClient {
// 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(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true);
+ .addParameter(SEND_RECONNECT_KEY, Boolean.TRUE.toString());
+ //.addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY,
true);
+
+ if (disconnectCount.getAndIncrement() % maxDisconnectCount == 0) {
+ logger.warn(url.getAddress() + " " + url.getServiceKey() + " safe
guard client , should not be called ,must have a bug.");
+ }
/**
* the order of judgment in the if statement cannot be changed.