<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> 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" checked=""> 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>DubboX version: 2.8.4</li>
<li>Java version: 1.8.0_191</li>
<li>Spring Boot Version: 2.0.3.RELEASE</li>
<li>Spring Cloud Version: Finchley.SR4</li>
<li>Brave version: 5.4.2</li>
<li>brave-instrumentation-dubbo-rpc:5.4.2</li>
</ul>
<p dir="auto">Starting with version <code class="notranslate">2.0.0</code>, Spring Cloud Sleuth uses <a href="https://github.com/openzipkin/brave">Brave</a> as the tracing library.  This project use Dubbo TraceFilter implemented by brave-instrumentation-dubbo-rpc. The Project configuration as below:</p>
<p dir="auto">application.properties</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="spring.sleuth.web.enabled=true
spring.sleuth.web.client.enabled=true
spring.sleuth.sampler.probability=0.0
spring.sleuth.log.slf4j.enabled=true
spring.application.name=${dubbo.app}"><pre class="notranslate"><code class="notranslate">spring.sleuth.web.enabled=true
spring.sleuth.web.client.enabled=true
spring.sleuth.sampler.probability=0.0
spring.sleuth.log.slf4j.enabled=true
spring.application.name=${dubbo.app}
</code></pre></div>
<p dir="auto">dubbo.xml</p>
<div class="highlight highlight-text-xml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    &lt;dubbo:provider filter=&quot;tracing&quot;/&gt;
    &lt;dubbo:consumer filter=&quot;tracing&quot;/&gt;"><pre class="notranslate">    &lt;<span class="pl-ent">dubbo</span><span class="pl-ent">:</span><span class="pl-ent">provider</span> <span class="pl-e">filter</span>=<span class="pl-s"><span class="pl-pds">"</span>tracing<span class="pl-pds">"</span></span>/&gt;
    &lt;<span class="pl-ent">dubbo</span><span class="pl-ent">:</span><span class="pl-ent">consumer</span> <span class="pl-e">filter</span>=<span class="pl-s"><span class="pl-pds">"</span>tracing<span class="pl-pds">"</span></span>/&gt;</pre></div>
<p dir="auto">we found that some time we lost the tracing information when invoke dubbo service from ServiceB to ServiceC.<br>
the two service log infomation as below:</p>
<p dir="auto">serviceB<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/2460207/78625105-b9d33480-78bd-11ea-9016-d510cb36f82a.png"><img src="https://user-images.githubusercontent.com/2460207/78625105-b9d33480-78bd-11ea-9016-d510cb36f82a.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">serviceC<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/2460207/78625121-c9eb1400-78bd-11ea-8dcf-2ee7c993a011.png"><img src="https://user-images.githubusercontent.com/2460207/78625121-c9eb1400-78bd-11ea-8dcf-2ee7c993a011.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">the tracing infomation of the first and second invocation is lost, and the third is passed. and we also found that the thread name of  the invocation which is lost tracing is all start with [http-nio], but the thread name start with [DubboServerHandler-] got the tracing infomation. We don't know the underlying mechanism between this two invocation.</p>
<p dir="auto">the tracing infomation is injected into the attachments of the RpcInvocation. We debug and found that<br>
<code class="notranslate">AbstractProxyInvoker</code> is not get and pass down the attachments<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/2460207/78625319-585f9580-78be-11ea-8f7a-16b0c245ca06.png"><img src="https://user-images.githubusercontent.com/2460207/78625319-585f9580-78be-11ea-8f7a-16b0c245ca06.png" alt="image" style="max-width: 100%;"></a></p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> 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" checked=""> 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>
<p dir="auto">branch: master</p>
<p dir="auto">functions take &amp; put in org.apache.dubbo.common.utils.Stack consider no the situation that index plus mSize is negative .</p>
<div class="highlight highlight-source-java notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="public E get(int index) {
        if (index &gt;= mSize) {
            throw new IndexOutOfBoundsException(&quot;Index: &quot; + index + &quot;, Size: &quot; + mSize);
        }

        return index &lt; 0 ? mElements.get(index + mSize) : mElements.get(index);
    }

public E set(int index, E value) {
        if (index &gt;= mSize) {
            throw new IndexOutOfBoundsException(&quot;Index: &quot; + index + &quot;, Size: &quot; + mSize);
        }

        return mElements.set(index &lt; 0 ? index + mSize : index, value);
    }

public E remove(int index) {
        if (index &gt;= mSize) {
            throw new IndexOutOfBoundsException(&quot;Index: &quot; + index + &quot;, Size: &quot; + mSize);
        }

        E ret = mElements.remove(index &lt; 0 ? index + mSize : index);
        mSize--;
        return ret;
    }"><pre class="notranslate"><span class="pl-k">public</span> <span class="pl-smi">E</span> <span class="pl-s1">get</span>(<span class="pl-smi">int</span> <span class="pl-s1">index</span>) {
        <span class="pl-k">if</span> (<span class="pl-s1">index</span> &gt;= <span class="pl-s1">mSize</span>) {
            <span class="pl-k">throw</span> <span class="pl-k">new</span> <span class="pl-smi">IndexOutOfBoundsException</span>(<span class="pl-s">"Index: "</span> + <span class="pl-s1">index</span> + <span class="pl-s">", Size: "</span> + <span class="pl-s1">mSize</span>);
        }

        <span class="pl-k">return</span> <span class="pl-s1">index</span> &lt; <span class="pl-c1">0</span> ? <span class="pl-s1">mElements</span>.<span class="pl-en">get</span>(<span class="pl-s1">index</span> + <span class="pl-s1">mSize</span>) : <span class="pl-s1">mElements</span>.<span class="pl-en">get</span>(<span class="pl-s1">index</span>);
    }

<span class="pl-k">public</span> <span class="pl-smi">E</span> <span class="pl-s1">set</span>(<span class="pl-smi">int</span> <span class="pl-s1">index</span>, <span class="pl-smi">E</span> <span class="pl-s1">value</span>) {
        <span class="pl-k">if</span> (<span class="pl-s1">index</span> &gt;= <span class="pl-s1">mSize</span>) {
            <span class="pl-k">throw</span> <span class="pl-k">new</span> <span class="pl-smi">IndexOutOfBoundsException</span>(<span class="pl-s">"Index: "</span> + <span class="pl-s1">index</span> + <span class="pl-s">", Size: "</span> + <span class="pl-s1">mSize</span>);
        }

        <span class="pl-k">return</span> <span class="pl-s1">mElements</span>.<span class="pl-en">set</span>(<span class="pl-s1">index</span> &lt; <span class="pl-c1">0</span> ? <span class="pl-s1">index</span> + <span class="pl-s1">mSize</span> : <span class="pl-s1">index</span>, <span class="pl-s1">value</span>);
    }

<span class="pl-k">public</span> <span class="pl-smi">E</span> <span class="pl-s1">remove</span>(<span class="pl-smi">int</span> <span class="pl-s1">index</span>) {
        <span class="pl-k">if</span> (<span class="pl-s1">index</span> &gt;= <span class="pl-s1">mSize</span>) {
            <span class="pl-k">throw</span> <span class="pl-k">new</span> <span class="pl-smi">IndexOutOfBoundsException</span>(<span class="pl-s">"Index: "</span> + <span class="pl-s1">index</span> + <span class="pl-s">", Size: "</span> + <span class="pl-s1">mSize</span>);
        }

        <span class="pl-smi">E</span> <span class="pl-s1">ret</span> = <span class="pl-s1">mElements</span>.<span class="pl-en">remove</span>(<span class="pl-s1">index</span> &lt; <span class="pl-c1">0</span> ? <span class="pl-s1">index</span> + <span class="pl-s1">mSize</span> : <span class="pl-s1">index</span>);
        <span class="pl-s1">mSize</span>--;
        <span class="pl-k">return</span> <span class="pl-s1">ret</span>;
    }</pre></div>
<p dir="auto">the implementations are not strict.</p>