<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/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" checked=""> 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: master branch</li>
<li>Operating System version: macos</li>
<li>Java version: 1.8</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<ol dir="auto">
<li><code class="notranslate">./mvnw test -pl dubbo-cluster -Dtest=org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalanceTest</code></li>
</ol>
<h3 dir="auto">Expected Result</h3>
<p dir="auto">What do you expected from the above steps？</p>
<p dir="auto">UT passed</p>
<h3 dir="auto">Actual Result</h3>
<p dir="auto">What actually happens?</p>
<p dir="auto">OOME thrown</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="Running org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalanceTest
[29/11/18 12:24:27:027 CST] main  INFO logger.LoggerFactory: using logger: org.apache.dubbo.common.logger.log4j.Log4jLoggerAdapter
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread &quot;Thread-6&quot;
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread &quot;surefire-forkedjvm-command-thread&quot;
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread &quot;last-ditch-daemon-shutdown-thread-30sec&quot;
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread &quot;Thread-5&quot;
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread &quot;Thread-1&quot;
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread &quot;Thread-10&quot;
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread &quot;Thread-7&quot;
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread &quot;Thread-9&quot;
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread &quot;Thread-2&quot;
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread &quot;Thread-3&quot;
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread &quot;Thread-8&quot;
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread &quot;Thread-4&quot;
Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 158.071 sec &lt;&lt;&lt; FAILURE! - in org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalanceTest
org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalanceTest  Time elapsed: 145.903 sec  &lt;&lt;&lt; ERROR!
java.lang.OutOfMemoryError: Java heap space


Results :

Tests in error: 
  RoundRobinLoadBalanceTest.org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalanceTest » OutOfMemory
"><pre class="notranslate"><code class="notranslate">Running org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalanceTest
[29/11/18 12:24:27:027 CST] main  INFO logger.LoggerFactory: using logger: org.apache.dubbo.common.logger.log4j.Log4jLoggerAdapter
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-6"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "surefire-forkedjvm-command-thread"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "last-ditch-daemon-shutdown-thread-30sec"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-5"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-1"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-10"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-7"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-9"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-2"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-3"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-8"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-4"
Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 158.071 sec &lt;&lt;&lt; FAILURE! - in org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalanceTest
org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalanceTest  Time elapsed: 145.903 sec  &lt;&lt;&lt; ERROR!
java.lang.OutOfMemoryError: Java heap space


Results :

Tests in error: 
  RoundRobinLoadBalanceTest.org.apache.dubbo.rpc.cluster.loadbalance.RoundRobinLoadBalanceTest » OutOfMemory

</code></pre></div>
<h3 dir="auto">Root cause analysis</h3>
<p dir="auto">Our mocked weightInvoker is recoding details of every single invocation which will consuming a lot of memory. please ref <a href="https://stackoverflow.com/questions/17437660/mockito-throws-an-outofmemoryerror-on-a-simple-test/28833727#28833727" rel="nofollow">Mockito throws an OutOfMemoryError on a simple test</a><br>
The maximum heap size of our test process specified in pom.xml is <strong>512MB</strong> which is not enough for this test case (<strong>RoundRobinLoadBalanceTest#testSelectByWeight</strong>)</p>
<h3 dir="auto">Solutions</h3>
<ul dir="auto">
<li>Option A, simply increase <code class="notranslate">-Xmx</code> in <code class="notranslate">argline</code></li>
<li>Option B, mock weightInvoker$ with MockSettings <code class="notranslate">stubOnly </code></li>
</ul>
<p dir="auto">In my view, if the invoking details is not that necessary we can choose Option B.<br>
And I will send a PR later.</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/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" checked=""> 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: xxx</li>
<li>Operating System version: xxx</li>
<li>Java version: xxx</li>
</ul>
<h3 dir="auto">Steps to reproduce this issue</h3>
<p dir="auto"><code class="notranslate">org.apache.dubbo.remoting.etcd.jetcd.JEtcdClientWrapper#doClose</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="if (globalLeaseId &gt; 0) {
        revokeLease(this.globalLeaseId);
}"><pre class="notranslate"><code class="notranslate">if (globalLeaseId &gt; 0) {
        revokeLease(this.globalLeaseId);
}
</code></pre></div>
<p dir="auto">should be change to :</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="if (globalLeaseId != 0) {
        revokeLease(this.globalLeaseId);
}"><pre class="notranslate"><code class="notranslate">if (globalLeaseId != 0) {
        revokeLease(this.globalLeaseId);
}
</code></pre></div>
<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?</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>