title: Callback with CompletableFuture
body: <p>I'm trying to create a really simple callback using some Strings. The IDE's code sense is  is moaning about an unchecked call to exceptionally. Can anyone give me a fix for this? The idea in the end is to wrap a network call so that the promised result is returned and I can tack on additional functions as needed.</p>
  
  <pre><code>import java.util.concurrent.*;
  import java.util.function.BiConsumer;
  import java.util.function.Function;
  import java.util.function.Supplier;
  
  public class FuturesTest {
  
      public static void main(String[] args) throws Exception {
          new FuturesTest().go();
      }
  
      private void go() throws ExecutionException, InterruptedException {
          CompletableFuture.supplyAsync(new MakesANetworkCall())
                  .whenComplete(new BiConsumer&lt;String, String&gt;() {
                      @Override
                      public void accept(String result, String s) {
                          System.out.println(result.toString());
                      }
                  })
                  .exceptionally(new Function&lt;Exception, Exception&gt;() {
                                     @Override
                                     public Exception apply(Exception e) {
                                         e.printStackTrace();
                                         return e;
                                     }
                                 }
                  ).thenApplyAsync(new Function&lt;String, String&gt;() {
                      @Override
                      public String apply(String o) {
                          System.out.println("Last action of all!");
                          return null;
                      }
                  });
  
          System.out.println("Main thread will sleep");
          Thread.sleep(2500);
          System.out.println("Program over");
      }
  
      class MakesANetworkCall implements Supplier {
  
          @Override
          public String get() {
              try {
                  System.out.println("Ground control to Major Tom");
                  Thread.sleep(2000);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
  //            int i = 2/0;
              return new String("Major Tom reporting!");
          }
      }
  }
  </code></pre>