title: How to flow context in Twitter Future in java
body: <p>Using Twitter <code>Future</code> in Java how can I have the context in one created <code>Future</code> available down a chain of <code>map</code>s?</p>
  
  <p>I've tried the following using <code>Contexts.local()</code>:</p>
  
  <pre><code>LocalContext.Key&lt;String&gt; key = Contexts.local().newKey();
  Contexts.local().let(key, "SomeValue", func(() -&gt; {
      System.out.println("inside let binding " + Contexts.local().get(key));
      return FuturePools.unboundedPool().apply(() -&gt; {
          System.out.println("inside let binding but in other thread " + Contexts.local().get(key));
          return "initial future";
      });
  })).map(v -&gt; {
      // How to get the context here? The line below prints None
      System.out.println("outside let binding " + Contexts.local().get(key));
      return "mapped future";
  });
  </code></pre>
  
  <p>Unfortunately the set value is no longer available in the lambda pased to the <code>map</code>. What do I do to have it available there too? And how do I do this in Java?</p>
  
  <p>In e.g. a Twitter <code>Promise</code> the <code>map</code> implementation does a <code>Local.save()</code> but I don't see a way to add values to <code>Local</code>.</p>