mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
22 lines
856 B
HTML
22 lines
856 B
HTML
<html>
|
|
<body>
|
|
Reports <code>java.lang.ThreadLocal.set()</code> with null as an argument.
|
|
<p>This call does not free the resources, and it may cause a memory leak.</p>
|
|
It may happen because:
|
|
<ul>
|
|
<li>Firstly, <code>ThreadLocal.set(null)</code> finds a map associated with the current Thread. If there is no such a map, it will be created</li>
|
|
<li>It sets key and value: <code>map.set(this, value)</code>, where <code>this</code> refers to instance of <code>ThreadLocal</code></li>
|
|
</ul>
|
|
<p><code>java.lang.ThreadLocal.remove()</code> should be used to free the resources.</p>
|
|
<p>Example:</p>
|
|
<pre><code>
|
|
ThreadLocal<Integer> threadLocal = new ThreadLocal<>();
|
|
threadLocal.set(null);
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
threadLocal.remove();
|
|
</code></pre>
|
|
<p><small>New in 2023.2</small></p>
|
|
</body>
|
|
</html> |