Skip to content

ConfigCenterConfig's member field's key wrong #3682

Closed

Description

@tswstarplanet
  • I have searched the issues of this repository and believe that this is not a duplicate.
  • I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.1-SNAPSHOT
  • Operating System version: MacOS 10.14
  • Java version: 1.8

I find some member fields of ConfigCenterConfig are annotated by @parameter, and the 'useKeyAsProperty' property of the annotation is set 'false'.
For example, the 'check' member field is annotated by @parameter, and its key is "config.check", but the 'useKeyAsProperty' is false.
So the key of this field in URL's parameters is 'check' because the 'useKeyAsProperty' is false, but in config center configuration class like ApolloDynamicConfiguration, the class use 'config.check' to get the property from parameters of URL.
So I think we should adjust the setting.
How about set the 'useKeyAsProperty' to true ?
I want to listen others' proposals.

Steps to reproduce this issue

config

<dubbo:configcenter address:xxx check="false"/>

Expected Result

the key in url's parameters should be "config.check", because in apollo dynamic configuration class, it use the key to get the check property
What do you expected from the above steps?

Actual Result

the key in parameters is check

If there is an exception, please attach the exception trace:

Just put your stack trace here!

Activity

  1. changed the title [-]ConfigCenterConfig's check key wrong[/-] [+]ConfigCenterConfig's member field's key wrong[/+] on Mar 17, 2019
  2. chickenlj commented on Apr 11, 2019

    @chickenlj
    Contributor

    So the key of this field in URL's parameters is 'check' because the 'useKeyAsProperty' is false, but in config center configuration class like ApolloDynamicConfiguration, the class use 'config.check' to get the property from parameters of URL.

    I don't think the problem you described exists.
    To clarify the relations between check and useKeyAsProperty and also to avoid misunderstanding, I add some comments on @parameter, please help to check.

  3. slankka commented on Jul 23, 2019

    @slankka
    Contributor

    I noticed the properties of ConfigCenterConfig is not read correctly by org.apache.dubbo.configcenter.support.apollo.ApolloDynamicConfiguration

    Dubbo Version 2.7.1
    The namespace is changed to consumer, but the program still access the default namespace:dubbo

            ConfigCenterConfig configCenterConfig = new ConfigCenterConfig();
            configCenterConfig.setAddress("xxx.com");
            configCenterConfig.setProtocol("apollo");
            configCenterConfig.setNamespace("consumer");
    

    The code in ApolloDynamicConfiguration:

    //CONFIG_NAMESPACE_KEY = "config.namespace"
    //DEFAULT_GROUP = "dubbo"
    dubboConfig = ConfigService.getConfig(url.getParameter(CONFIG_NAMESPACE_KEY, DEFAULT_GROUP));
    

    And it always be "dubbo", due to the url field parameters has no config.namespace but namespace:

    ApolloDyC_20190723121050

    The namespace is set by config.namespace, then it works fine.

     @Bean
        public ConfigCenterConfig configCenterConfig() {
            ConfigCenterConfig apollo = new ConfigCenterBuilder()
                    .address("xxx.com")
                    .protocol("apollo")
                    .namespace("consumer")
                    .appendParameter("config.namespace", "consumer")
                    .build();
    
            return apollo;
        }
    
  4. slankka commented on Jul 23, 2019

    @slankka
    Contributor

    #4411 The problem has been solved. Please ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions