private static void assertAsynchronousClose(Future<?> future) throws Throwable {
    try {
      future.get(10, SECONDS);
      fail("no exception was thrown");
    } catch (ExecutionException expected) {
      Throwable t = expected.getCause();
      if (!(t instanceof AsynchronousCloseException || t instanceof ClosedChannelException)) {
        fail(
            "expected AsynchronousCloseException (or in rare cases ClosedChannelException); got "
                + t);
      }
    }
  }
Assert that the future fails, with the failure caused by either {@code
AsynchronousCloseException} or (rarely) {@code ClosedChannelException}.
jimfs/src/test/java/com/google/common/jimfs/JimfsAsynchronousFileChannelTest.java