Skip to content

Commit 5e68e43

Browse files
authored
Backport 2.7, lazy connection warn log (#8329)
1 parent 3f1e3f4 commit 5e68e43

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/DubboProtocol.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ public void destroy() {
437437
}
438438
}
439439
}
440+
// put here to reduce the chance of accepting new invocation after client closed.
441+
// close invoker and then client.
442+
super.destroy();
440443

441444
for (String key : new ArrayList<String>(referenceClientMap.keySet())) {
442445
ExchangeClient client = referenceClientMap.remove(key);
@@ -466,6 +469,5 @@ public void destroy() {
466469
}
467470
}
468471
stubServiceMethodsMap.clear();
469-
super.destroy();
470472
}
471473
}

dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/LazyConnectExchangeClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public ResponseFuture request(Object request, int timeout) throws RemotingExcept
115115
private void warning(Object request) {
116116
if (requestWithWarning) {
117117
if (warningcount.get() % 5000 == 0) {
118-
logger.warn(new IllegalStateException("safe guard client , should not be called ,must have a bug."));
118+
logger.warn(url.getAddress() + " " + url.getServiceKey() + " safe guard client get called after real client closed, recreating connection...");
119119
}
120120
warningcount.incrementAndGet();
121121
}

dubbo-rpc/dubbo-rpc-dubbo/src/main/java/com/alibaba/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClient.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,9 @@ public void startClose() {
167167
private LazyConnectExchangeClient replaceWithLazyClient() {
168168
// this is a defensive operation to avoid client is closed by accident, the initial state of the client is false
169169
URL lazyUrl = url.addParameter(Constants.LAZY_CONNECT_INITIAL_STATE_KEY, Boolean.TRUE)
170-
.addParameter(Constants.RECONNECT_KEY, Boolean.FALSE)
171170
.addParameter(Constants.SEND_RECONNECT_KEY, Boolean.TRUE.toString())
172-
.addParameter("warning", Boolean.TRUE.toString())
173-
.addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true)
174-
.addParameter("_client_memo", "referencecounthandler.replacewithlazyclient");
171+
.addParameter(LazyConnectExchangeClient.REQUEST_WITH_WARNING_KEY, true);
172+
175173

176174
String key = url.getAddress();
177175
// in worst case there's only one ghost connection.

dubbo-rpc/dubbo-rpc-dubbo/src/test/java/com/alibaba/dubbo/rpc/protocol/dubbo/ReferenceCountExchangeClientTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.alibaba.dubbo.rpc.Exporter;
2727
import com.alibaba.dubbo.rpc.Invoker;
2828
import com.alibaba.dubbo.rpc.ProxyFactory;
29-
3029
import org.junit.Assert;
3130
import org.junit.Before;
3231
import org.junit.BeforeClass;
@@ -46,7 +45,7 @@ public class ReferenceCountExchangeClientTest {
4645
IHelloService helloService;
4746
ExchangeClient demoClient;
4847
ExchangeClient helloClient;
49-
String errorMsg = "safe guard client , should not be called ,must have a bug";
48+
String errorMsg = "safe guard client";
5049

5150
@BeforeClass
5251
public static void setUpBeforeClass() throws Exception {

0 commit comments

Comments
 (0)