<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have searched the <a href="https://github.com/apache/dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the <a href="https://github.com/apache/dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: 2.7.3/master</li>
<li>Operating System version: mac</li>
<li>Java version: 1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<h2 dir="auto">问题描述</h2>
<blockquote>
<p dir="auto">简写属性</p>
</blockquote>
<div class="highlight highlight-source-ini notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="embedded.zookeeper.port=2181
dubbo.registry.address=zookeeper://127.0.0.1:${embedded.zookeeper.port}
dubbo.metadata-report.address=zookeeper://127.0.0.1:${embedded.zookeeper.port}
dubbo.config-center.address=zookeeper://127.0.0.1:${embedded.zookeeper.port}"><pre class="notranslate"><span class="pl-k">embedded.zookeeper.port</span>=2181
<span class="pl-k">dubbo.registry.address</span>=zookeeper://127.0.0.1:${embedded.zookeeper.port}
<span class="pl-k">dubbo.metadata-report.address</span>=zookeeper://127.0.0.1:${embedded.zookeeper.port}
<span class="pl-k">dubbo.config-center.address</span>=zookeeper://127.0.0.1:${embedded.zookeeper.port}</pre></div>
<blockquote>
<p dir="auto">程序启动后，在<code class="notranslate">dubbo-master</code>分支${embedded.zookeeper.port}值为NULL。</p>
</blockquote>
<h2 dir="auto">原因分析</h2>
<blockquote>
<p dir="auto">dubbo-master代码</p>
</blockquote>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    @Override
    public Object getProperty(String key, Object defaultValue) {
        Object value = null;
        if (StringUtils.isNotEmpty(prefix)) {
            if (StringUtils.isNotEmpty(id)) {
                value = getInternalProperty(prefix + id + &quot;.&quot; + key);
            }
            if (value == null) {
                value = getInternalProperty(prefix + key);
            }
        } else {
            value = getInternalProperty(key);
        }
        return value != null ? value : defaultValue;
    }"><pre class="notranslate">    <span class="pl-c1">@</span><span class="pl-c1">Override</span>
    <span class="pl-k">public</span> <span class="pl-smi">Object</span> <span class="pl-s1">getProperty</span>(<span class="pl-smi">String</span> <span class="pl-s1">key</span>, <span class="pl-smi">Object</span> <span class="pl-s1">defaultValue</span>) {
        <span class="pl-smi">Object</span> <span class="pl-s1">value</span> = <span class="pl-c1">null</span>;
        <span class="pl-k">if</span> (<span class="pl-smi">StringUtils</span>.<span class="pl-en">isNotEmpty</span>(<span class="pl-s1">prefix</span>)) {
            <span class="pl-k">if</span> (<span class="pl-smi">StringUtils</span>.<span class="pl-en">isNotEmpty</span>(<span class="pl-s1">id</span>)) {
                <span class="pl-s1">value</span> = <span class="pl-en">getInternalProperty</span>(<span class="pl-s1">prefix</span> + <span class="pl-s1">id</span> + <span class="pl-s">"."</span> + <span class="pl-s1">key</span>);
            }
            <span class="pl-k">if</span> (<span class="pl-s1">value</span> == <span class="pl-c1">null</span>) {
                <span class="pl-s1">value</span> = <span class="pl-en">getInternalProperty</span>(<span class="pl-s1">prefix</span> + <span class="pl-s1">key</span>);
            }
        } <span class="pl-k">else</span> {
            <span class="pl-s1">value</span> = <span class="pl-en">getInternalProperty</span>(<span class="pl-s1">key</span>);
        }
        <span class="pl-k">return</span> <span class="pl-s1">value</span> != <span class="pl-c1">null</span> ? <span class="pl-s1">value</span> : <span class="pl-s1">defaultValue</span>;
    }</pre></div>
<blockquote>
<p dir="auto"><code class="notranslate">InmemoryConfiguration</code>里面的store存取的值是没有前缀的，如："address" -&gt; "zookeeper://127.0.0.1:2181"、"prefix" -&gt; "dubbo.config-center"、"namespace" -&gt; "henry1"等。所以在<code class="notranslate">getInternalProperty(prefix + key);</code>获取失败的。然后会进入<code class="notranslate">PropertiesConfiguration</code>获取，但是里面的数据结构为，如："dubbo.registry.address" -&gt; "zookeeper://127.0.0.1:${embedded.zookeeper.port}"。但是解析${embedded.zookeeper.port}时，参数集合里是没有的，因为<code class="notranslate">OverrideDubboConfigApplicationListener</code>将所有非dubbo.开头的全部过滤掉了，除非将embedded.zookeeper.port改成dubbo.embedded.zookeeper.port就可以了。</p>
</blockquote>
<blockquote>
<p dir="auto">2.7.3代码</p>
</blockquote>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    @Override
    public Object getProperty(String key, Object defaultValue) {
        Object value = null;
        if (StringUtils.isNotEmpty(prefix) &amp;&amp; StringUtils.isNotEmpty(id)) {
            value = getInternalProperty(prefix + id + &quot;.&quot; + key);
        }
        if (value == null &amp;&amp; StringUtils.isNotEmpty(prefix)) {
            value = getInternalProperty(prefix + key);
        }

        if (value == null) {
            value = getInternalProperty(key);
        }
        return value != null ? value : defaultValue;
    }"><pre class="notranslate">    <span class="pl-c1">@</span><span class="pl-c1">Override</span>
    <span class="pl-k">public</span> <span class="pl-smi">Object</span> <span class="pl-s1">getProperty</span>(<span class="pl-smi">String</span> <span class="pl-s1">key</span>, <span class="pl-smi">Object</span> <span class="pl-s1">defaultValue</span>) {
        <span class="pl-smi">Object</span> <span class="pl-s1">value</span> = <span class="pl-c1">null</span>;
        <span class="pl-k">if</span> (<span class="pl-smi">StringUtils</span>.<span class="pl-en">isNotEmpty</span>(<span class="pl-s1">prefix</span>) &amp;&amp; <span class="pl-smi">StringUtils</span>.<span class="pl-en">isNotEmpty</span>(<span class="pl-s1">id</span>)) {
            <span class="pl-s1">value</span> = <span class="pl-en">getInternalProperty</span>(<span class="pl-s1">prefix</span> + <span class="pl-s1">id</span> + <span class="pl-s">"."</span> + <span class="pl-s1">key</span>);
        }
        <span class="pl-k">if</span> (<span class="pl-s1">value</span> == <span class="pl-c1">null</span> &amp;&amp; <span class="pl-smi">StringUtils</span>.<span class="pl-en">isNotEmpty</span>(<span class="pl-s1">prefix</span>)) {
            <span class="pl-s1">value</span> = <span class="pl-en">getInternalProperty</span>(<span class="pl-s1">prefix</span> + <span class="pl-s1">key</span>);
        }

        <span class="pl-k">if</span> (<span class="pl-s1">value</span> == <span class="pl-c1">null</span>) {
            <span class="pl-s1">value</span> = <span class="pl-en">getInternalProperty</span>(<span class="pl-s1">key</span>);
        }
        <span class="pl-k">return</span> <span class="pl-s1">value</span> != <span class="pl-c1">null</span> ? <span class="pl-s1">value</span> : <span class="pl-s1">defaultValue</span>;
    }</pre></div>
<blockquote>
<p dir="auto">为什么2.7.3代码可以的，因为<code class="notranslate">getInternalProperty(prefix + key);</code>获取为NULL后，会继续走<code class="notranslate">getInternalProperty(key)</code>，所以值取出来了。</p>
</blockquote>
<blockquote>
<p dir="auto">但是master 这样写是为了解决在windows下获取环境变量path，长度超长(之前我遇到的问题是这样)。</p>
</blockquote>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">我不知道这个算不算BUG，但是怕后面的人会遇到，还是建了一个issue。</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">What actually happens?</p>
<p dir="auto">If there is an exception, please attach the exception trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Just put your stack trace here!"><pre class="notranslate"><code class="notranslate">Just put your stack trace here!
</code></pre></div>
<p dir="auto">AcceLogFilter message creation and last and current check was performing by each time simple date formate object creation. In this version of code I have use the ThreadLocal for each thread wise to create simple date format object instead of each call.</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have searched the <a href="https://github.com/apache/incubator-dubbo/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the <a href="https://github.com/apache/incubator-dubbo/blob/master/FAQ.md">FAQ</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>Dubbo version: 2.7.0</li>
<li>Operating System version: xxx</li>
<li>Java version: xxx</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li>xxx</li>
<li>xxx</li>
<li>xxx</li>
</ol>
<p dir="auto">Pls. provide [GitHub address] to reproduce this issue.</p>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">What do you expected from the above steps？</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">What actually happens?<br>
AcceLogFilter message creation and last and current check was performing by each time simple date formate object creation. In this version of code I have use the ThreadLocal for each thread wise to create simple date format object instead of each call.<br>
If there is an exception, please attach the exception trace:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Just put your stack trace here!"><pre class="notranslate"><code class="notranslate">Just put your stack trace here!
</code></pre></div>