Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confuse logic? #10014

Closed
Arvinaa opened this issue Feb 27, 2023 · 4 comments · Fixed by #10023
Closed

Confuse logic? #10014

Arvinaa opened this issue Feb 27, 2023 · 4 comments · Fixed by #10023
Assignees
Labels
kind/bug Category issues or prs related to bug.

Comments

@Arvinaa
Copy link

Arvinaa commented Feb 27, 2023

This class file: https://github.com/alibaba/nacos/blob/2.2.0/client/src/main/java/com/alibaba/nacos/client/naming/utils/InitUtils.java
In method initNamespaceForNaming, I cant understand always use properties.getProperty(PropertyKeyConst.NAMESPACE);`, only for priint log? there are really confiuse for me, please answer...

tmpNamespace = TemplateUtils.stringEmptyAndThenExecute(tmpNamespace, () -> {
            String namespace = properties.getProperty(PropertyKeyConst.NAMESPACE);
            LogUtils.NAMING_LOGGER.info("initializer namespace from System Property :" + namespace);
            return namespace;
        });
        
        if (StringUtils.isEmpty(tmpNamespace)) {
            tmpNamespace = properties.getProperty(PropertyKeyConst.NAMESPACE);
        }
@lipeishen
Copy link

in my opinion, when "tmpNamespace" is empty, "String namespace = properties.getProperty(PropertyKeyConst.NAMESPACE) " is to get the value of "namespace" and assign it to "tmpNamespace" , not just to print log.

@Arvinaa
Copy link
Author

Arvinaa commented Feb 27, 2023

in my opinion, when "tmpNamespace" is empty, "String namespace = properties.getProperty(PropertyKeyConst.NAMESPACE) " is to get the value of "namespace" and assign it to "tmpNamespace" , not just to print log.

but two lines code always assign value to variable tpmNamespace, and twice are from properties.getProperty(PropertyKeyConst.NAMESPACE);

@Arvinaa Arvinaa closed this as completed Feb 27, 2023
@Arvinaa Arvinaa reopened this Feb 27, 2023
@KomachiSion
Copy link
Collaborator

The original logic is get NAMESPACE from JVM, if JVM has no value, get from user properties.

and After some refactor for properties, all properties is merged into NacosProperties, it makes the confuse.

@KomachiSion KomachiSion added the kind/bug Category issues or prs related to bug. label Mar 1, 2023
@onewe
Copy link
Collaborator

onewe commented Mar 1, 2023

@i will resolve it@

@onewe onewe self-assigned this Mar 1, 2023
onewe added a commit to onewe/nacos that referenced this issue Mar 8, 2023
- add getPropertyFrom method
- optimize some code logic

Close alibaba#10014
KomachiSion pushed a commit that referenced this issue Mar 9, 2023
* [ISSUES #10014] clear confused logic about namespace properties

- add getPropertyFrom method
- optimize some code logic

Close #10014

* fix ci error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Category issues or prs related to bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants