private static <T> CompletionHandler<T, Object> setFuture(final SettableFuture<T> future) {
    return new CompletionHandler<T, Object>() {
      @Override
      public void completed(T result, Object attachment) {
        future.set(result);
      }

      @Override
      public void failed(Throwable exc, Object attachment) {
        future.setException(exc);
      }
    };
  }
Returns a {@code CompletionHandler} that sets the appropriate result or exception on the given
{@code future} on completion.
jimfs/src/test/java/com/google/common/jimfs/JimfsAsynchronousFileChannelTest.java