Skip to content

Commit

Permalink
Backport 2.7, lazy connection warn log (#8329)
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenlj authored Jul 23, 2021
1 parent 3f1e3f4 commit 5e68e43
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ public void destroy() {
}
}
}
// put here to reduce the chance of accepting new invocation after client closed.
// close invoker and then client.
super.destroy();

for (String key : new ArrayList<String>(referenceClientMap.keySet())) {
ExchangeClient client = referenceClientMap.remove(key);
Expand Down Expand Up @@ -466,6 +469,5 @@ public void destroy() {
}
}
stubServiceMethodsMap.clear();
super.destroy();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public ResponseFuture request(Object request, int timeout) throws RemotingExcept
private void warning(Object request) {
if (requestWithWarning) {
if (warningcount.get() % 5000 == 0) {
logger.warn(new IllegalStateException("safe guard client , should not be called ,must have a bug."));
logger.warn(url.getAddress() + " " + url.getServiceKey() + " safe guard client get called after real client closed, recreating connection...");
}
warningcount.incrementAndGet();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,9 @@ public void startClose() {
private LazyConnectExchangeClient replaceWithLazyClient() {
// this is a defensive operation to avoid client is closed by accident, the initial state of the client is false
URL lazyUrl = url.addParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY, Boolean.TRUE)
.addParameter(Constants.RECONNECT_KEY, Boolean.FALSE)
.addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString())
.addParameter("warning", Boolean.TRUE.toString())
.addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true)
.addParameter("_client_memo", "referencecounthandler.replacewithlazyclient");
.addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true);


String key = url.getAddress();
// in worst case there's only one ghost connection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.alibaba.dubbo.rpc.Exporter;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.ProxyFactory;

import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
Expand All @@ -46,7 +45,7 @@ public class ReferenceCountExchangeClientTest {
IHelloService helloService;
ExchangeClient demoClient;
ExchangeClient helloClient;
String errorMsg = "safe guard client , should not be called ,must have a bug";
String errorMsg = "safe guard client";

@BeforeClass
public static void setUpBeforeClass() throws Exception {
Expand Down

0 comments on commit 5e68e43

Please sign in to comment.