Files
openide/java/java-impl/resources/inspectionDescriptions/ThreadLocalNotStaticFinal.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

18 lines
699 B
HTML

<html>
<body>
Reports fields of type <code>java.lang.ThreadLocal</code> that are not declared <code>static final</code>.
<p>
In the most common case, a <code>java.lang.ThreadLocal</code> instance associates state with a thread.
A non-static non-final <code>java.lang.ThreadLocal</code> field associates state with an instance-thread combination.
This is usually unnecessary and quite often is a bug that can cause memory leaks and incorrect behavior.
</p>
<p>
A quick-fix is suggested to make the field <code>static final</code>.
<p>
<p><b>Example:</b></p>
<pre><code>
private ThreadLocal tl = ThreadLocal.withInitial(() -> Boolean.TRUE);
</code></pre>
<!-- tooltip end -->
</body>
</html>