title: ThreadLocal get() returning null sometimes after spring boot upgrade from 2.1.4 to 3.4.3
body: <p>This is the code:</p>
  <pre><code>public class ContextManagerImpl implements ContextManager {
  
      private static final ThreadLocal&lt;Context&gt; ctx = new ThreadLocal&lt;Context&gt;();
      @Override
      public Context getContext() {
          if(ctx.get() == null) {
              ctx.set(new Context(&quot;&quot;, &quot;&quot;));   // Dummy context. This should never happen
          }
          return ctx.get();
      }
  
      @Override
      public void begin(Context context){
          ctx.set(context);                            // Verified context passed is never null or blank 
      }
  
      @Override
      public void end() {
          if(ctx!= null) {
              ctx.remove();
          }
      }
  }
  
  public final class Context implements Serializable {
      private String s1;
      private String s2;
  }
  </code></pre>
  <p>There are 2 threads which are using this class with different threadlocal context. It works fine most of the time, however sometimes even when begin() sets the value in ctx properly, getContext() returns dummy context.
  I suspect there is a race condition somewhere which is causing this but given that threadlocal set() and get() are threadsafe and initialisation of ctx is done during declaration this should never happen.
  Note: I have upgraded spring boot to 3.4.3 but still using JDK 8.</p>