title: HystrixRequestContext.getContextForCurrentThread() becoming null
body: <p>In my springboot app, I am wrapping a code block with HystrixCommand annotation to indicate that the code block is protected. 
  Also I am using THREAD as hystrix execution isolation strategy. Since the code block runs in a separate thread(hystrix-{protected method's commandKey}-x), I'm injecting MDC by writing a custom HystrixCommandExecutionHook to add the unique id in all the logs to make debugging easier. And I've registered the custom plugin when the app starts.
  <br>
  I am initialising HystrixRequestContext in <em>onStart()</em> method of HystrixCommandExecutionHook.
  <br></p>
  
  <p><br>
  In the code block, I also have a call to cache service before calling remote service which runs again on a <em>separate hystrix thread. I got to know this by checking the thread name(hystrix-{cacheService's commandKey}-x)</em> from the logs.
  <br></p>
  
  <pre><code>@Override
   public &lt;T&gt; void onStart(HystrixInvokable&lt;T&gt; commandInstance) {
     HystrixRequestContext.initializeContext();
     Map&lt;String, String&gt; originalMDCContext = MDC.getCopyOfContextMap();
     if (originalMDCContext != null &amp;&amp; !originalMDCContext.isEmpty()) {
        mdcContextVariable.set(originalMDCContext);
      }
    }
  </code></pre>
  
  <p>The challenge I am facing is , when the call to cache service is complete and control comes back to the next line in the code block, the value of <em>HystrixRequestContext.getContextForCurrentThread()</em> will be <em>null</em>. I saw <em>HystrixRequestContext.isCurrentThreadInitialized()</em> will have <em>FALSE</em> value. If code block throws an exception, cleanup in onExecutionFailure method fails with NPE. The cleanup code is like below:
  <br></p>
  
  <pre><code>private void cleanup() {
    HystrixRequestContext.getContextForCurrentThread().shutdown();
  }
  </code></pre>
  
  <p>Since I am getting null in <em>HystrixRequestContext.getContextForCurrentThread()</em>, <em>cleanup()</em> is failing with NPE on executionSuccess/ executionFailure.
  <br>
  Can anybody please shed some lights on what is happening here? Why is the <strong>HystrixRequestContext.getContextForCurrentThread()</strong> becoming <strong>null</strong> or why the <strong>HystrixRequestContext.isCurrentThreadInitialized()</strong> becomes <strong>false</strong> after returning from other service call?</p>
  
  <h3>Workaround</h3>
  
  <p>Currently I am checking in cleanup method if HystrixRequestContext.isCurrentThreadInitialized() is TRUE and then invoke the <em>shutdown()</em> method. If it's FALSE, don't do anything.</p>
  
  <pre><code>private void cleanup() {
  if(HystrixRequestContext.isCurrentThreadInitialized() == Boolean.TRUE)
    HystrixRequestContext.getContextForCurrentThread().shutdown();
  }
  </code></pre>
  
  <h3>Expected</h3>
  
  <p>I expect HystrixRequestContext.getContextForCurrentThread() should contain the state(shouldn't be null) until I invoke <em>shutdown()</em> on it manually.</p>
  
  <h3>Actual</h3>
  
  <p>HystrixRequestContext.getContextForCurrentThread() is having null after call returns from other service</p>