You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by yu...@apache.org on 2021/12/11 01:22:31 UTC
[rocketmq] branch develop updated: [ISSUE 3585] [Part E] eliminate duplicated getNamespace() call when where is no namespace (#3591)
This is an automated email from the ASF dual-hosted git repository.
yuzhou pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push:
new 67225fd [ISSUE 3585] [Part E] eliminate duplicated getNamespace() call when where is no namespace (#3591)
67225fd is described below
commit 67225fdabee62700e28f7ef911bb72daaac081e3
Author: huangli <ar...@gmail.com>
AuthorDate: Sat Dec 11 09:22:22 2021 +0800
[ISSUE 3585] [Part E] eliminate duplicated getNamespace() call when where is no namespace (#3591)
Co-authored-by: colin <39...@qq.com>
---
.../src/main/java/org/apache/rocketmq/client/ClientConfig.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java b/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
index 8d7f5a1..4452bbd 100644
--- a/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
+++ b/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java
@@ -39,6 +39,7 @@ public class ClientConfig {
private String instanceName = System.getProperty("rocketmq.client.name", "DEFAULT");
private int clientCallbackExecutorThreads = Runtime.getRuntime().availableProcessors();
protected String namespace;
+ private boolean namespaceInitialized = false;
protected AccessChannel accessChannel = AccessChannel.LOCAL;
/**
@@ -195,6 +196,7 @@ public class ClientConfig {
*/
public void setNamesrvAddr(String namesrvAddr) {
this.namesrvAddr = namesrvAddr;
+ this.namespaceInitialized = false;
}
public int getClientCallbackExecutorThreads() {
@@ -278,20 +280,26 @@ public class ClientConfig {
}
public String getNamespace() {
+ if (namespaceInitialized) {
+ return namespace;
+ }
+
if (StringUtils.isNotEmpty(namespace)) {
return namespace;
}
if (StringUtils.isNotEmpty(this.namesrvAddr)) {
if (NameServerAddressUtils.validateInstanceEndpoint(namesrvAddr)) {
- return NameServerAddressUtils.parseInstanceIdFromEndpoint(namesrvAddr);
+ namespace = NameServerAddressUtils.parseInstanceIdFromEndpoint(namesrvAddr);
}
}
+ namespaceInitialized = true;
return namespace;
}
public void setNamespace(String namespace) {
this.namespace = namespace;
+ this.namespaceInitialized = true;
}
public AccessChannel getAccessChannel() {