title: Is it a good idea to use WeakHashMap in ThreadLocal
body: <p>For my usecase, I have to pass quite a few context information from different layers/components of the application. Since few of the components are discrete, I am thinking to use <code>ThreadLocal</code> to store such context information. I have an interceptor/filter in place to clean it before the the response is written back to the user. Now, my question is, is it a good idea to use <code>WeakHashMap</code> inside <code>ThreadLocal</code> (see the code snippet below)?</p>
  
  <pre><code>
      private static final ThreadLocal&lt;Map&lt;String, Object&gt;&gt; context = new ThreadLocal&lt;WeakHashMap&lt;String, Object&gt;&gt;();
  </code></pre>
  
  <p>The doubt in my mind (with my limited knowledge of Weak references in Java) is, the weak references can return NULL (because GC collects them as per its own will).</p>
  
  <p>Please help me in understanding this. Should I use a strong reference like <code>HashMap</code> or <code>ConcurrentHashMap</code> or my implementation is good to go?</p>