apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.51k stars 26.43k forks source link

dubbo.properties占位符表达式不支持默认值 #7068

Open bq-xiao opened 3 years ago

bq-xiao commented 3 years ago

Environment

Steps to reproduce this issue

  1. org.apache.dubbo.common.utils.ConfigUtils中的replaceProperty方法不支持默认值;
  2. Run unit test always failed, defaultA and defaultB is default value.
    @Test
    public void testReplacePropertyDefault() throws Exception {
        String s = ConfigUtils.replaceProperty("1${a.b.c:defaultA}2${a.b.c:defaultB}3", Collections.<String, String>emptyMap());
        assertEquals(s, "1defaultA2defaultB3");
    }

Pls. provide [GitHub address] to reproduce this issue. https://github.com/apache/dubbo/blob/d98d48914b139d6abb2139ea36e51e536713edfe/dubbo-common/src/main/java/org/apache/dubbo/common/utils/ConfigUtils.java#L186

Expected Result

dubbo.properties 占位符表达式能够支持默认值

Actual Result

What actually happens?

dubbo.properties占位符表达式不支持默认值

上面的单元测试运行失败:

Expected :1:defaultA}2:defaultB}3
Actual   :1defaultA2defaultB3
bq-xiao commented 3 years ago

https://github.com/apache/dubbo/blob/d98d48914b139d6abb2139ea36e51e536713edfe/dubbo-common/src/test/java/org/apache/dubbo/common/utils/ConfigUtilsTest.java#L113